README for groov EPIC Secure Shell (SSH) Demo
To get secure shell access to your groov EPIC processor, first get a free shell license key by contacting Preferred Customer Specialists at firstname.lastname@example.org, then go to manage.groov.com, select the PR-1 you want to apply the shell access key to, and then download the license file for that device.
After you have the file, go to the groov Manage System menu in a web browser, select License > Upload License, and upload the file you downloaded from manage.groov. Next, you create a shell user through the System > Shell menu, which will also open port 22 for remote access.
To access your groov EPIC using SSH over Windows use the PuTTY SSH client.
After the client is installed, put your hostname into the connection destination, with the default port 22 and SSH connection type, then click
Open. You will need to trust the new connection by saying yes to the warning that pops up, and log in with the user you created in groov Manage, then you're good to go!
To get this entire folder onto your groov EPIC run the following command in the folder you want to download it to:
git clone https://github.com/optodeveloper/SSH-Demo.git
Then navigate into the new folder with:
And to view the files:
OptoMMP: Python Scripts
The following Python scripts use OptoMMP thru the socket interface to communicate groov EPIC, and don't require any prior setup:
"mmpgetuptime" returns the uptime (ms) of the controller: one optional parameter for host.
python mmpgetuptime.pywill default to localhost.
python mmpgetuptime.py <hostname or IP address>will get the given host's uptime.
"mmpreaddigmodch" returns the state of the given module and channel: two required parameters for module and channel number.
python mmpreaddigmodch.py 0 1will read the digital state of localhost module 0, channel 1, and output the result.
"mmpwritedigmodch0or1" sets the state of the given module and channel: three required parameters for module number, channel number, and state 1 or 0
python mmpwritedigmodch0or1.py 0 1 1will write the digital state of localhost module 0, channel 1 to be = 1 (on/true) and attempt confirmation.
OptoMMP: Executable file compiled from C++ code
"pulseprogram" Flashes output 22 on module 0 twenty two times. Source code is pulseprogram.cpp, uses the OptoMMP C++ SDK.
./pulseprogramto run the program.
REST API: Python Scripts
The following Python Scripts use RESTful APIs thru the requests package to communicate with groov EPIC.
NOTE: Updating API KEY
Before using any of the following RESTful scripts you will need to install Python-pip, the Python HTTP requests package, and update the API key in the
To install the requests package on groov EPIC:
sudo apt-get update
sudo apt-get install python-pip
sudo pip install requests
To get and update the API key:
- In the shell type
nano apiKey.pyexactly, make sure there's a capital K and leave the rest lowercase. Leave this text editor open.
nano apiand then push the
tabkey and it will auto complete the file name.
- In a browser go to https://hostname/manage, replacing "hostname" with your device's unique hostname.
- Select Accounts from the main menu.
- Select or create an account with Admin permissions.
- Copy the long string under API Key at the bottom of the page, it will look like "
- Go back to the shell and replace the
keyvariable string value with the key from the Admin user, just using arrow keys (left clicking with your mouse will not work) go to the end of the key and backspace to remove the old string.
- With the cursor in between the completely empty quotes
apiKey = ''right click anywhere on the screen to paste the copied API key into PuTTY.
ctrl + oto write out (save) the changes, and press
enterto keep the same file name. You should see "wrote lines" at the bottom of the screen.
ctrl + xto exit the nano text editor. There should be no prompt since you just saved the changes.
"pulsePython_Output" will pulse Python_Output on module 0, digital output channel 22, using the Manage REST API.
python pulsePython_Output.pywill pulse the output twenty-two times.
"writePython_Output" will toggle Python_Output on module 0, digital output channel 22, using the Manage REST API.
python writePython_Output.py onwill turn the output on.
python writePython_Output.py offwill turn the output off.
"readtc" returns the decimal value of analog input channel 0, module 2, which should have a thermocouple installed, using the Manage REST API.
python readtc.pywill read the input channel and output the result.
"restreaddigmodch" returns the state of the given module and channel: two required parameters for module and channel number using the Manage API.
python restreaddigmodch.py 0 1will read the digital state of localhost module 0, channel 1, and output the result.
"restwritedigmodch0or1" sets the state of the given module and channel: three required parameters for module number, channel number, and state 1 or 0 using the Manage API.
python restwritedigmodch0or1.py 0 1 1will write the digital state of localhost module 0, channel 1 to be = 1 (on/true) and attempt confirmation.
"writePython_Var" will write the given value to the Python_Var int32 variable using the PAC Control REST API.
python writePython_Var.py 22will write 22 to the variable.
"readLPTvar" returns the decimal value of PAC Control float variable "Presure_Transducer_1" using the PAC Control REST API.
python readLPTvar.pywill read the variable and output the result.