The peripheral manager is a daemon that runs on the workstation that allows cloud based applications to connect to the workstation and acts as the middleware that allows tools to control the hardware connected to the workstation. This communication link is achieved using web-sockets and and then transferred to a serial communication link.
This project uses poetry
to manage dependencies and the runtime (Python 3.8 and above). The following commands will can be used to set up the development environment. You can follow one of the many installation options shown one the poetry website (https://python-poetry.org/docs/#osx--linux--bashonwindows-install-instructions). We recommend installing pyenv to manage your python environments (https://github.com/pyenv/pyenv)
# This assumes you clone the repo and have python installed on your machine
cd <project directory>
poetry install #Creates sandbox runtime env and downloads all dependencies
pipenv shell #Changes the terminal environment into the sandbox env, <ctrl + D> to exit
python server.py #Runs the primary application
The HTTP and SocketIO endpoint is available on port 3000
. To check if the server is working correctly, type localhost:3000
in the browser address bar.
The API for managing the peripheral manager uses the SocketIO events to communicate with the peripheral manager
Sends the command and the list of arguments that go with the command to be converted to the standard command frame.
device name
command id
list of command arguments
{
"name" : STRING,
"command-id": INT
"args" : [ INT ]
}
Note ! - Not yet implemented
Sends the raw binary command that is sent to the hardware device.
device name
binary command
{
"name" : STRING,
"payload": Buffer()
}
Returns the list of devices that are connected to the workstation on which the peripheral manager is running.
nil
Changes the name of the device/connection reference that is in the memory of the peripheral manager.
old
new
{
"old" : STRING,
"new": STRING
}
Returns the list of active connections in the peripheral manager.
nil
Creates the serial-socketio connection.
device name
device address
{
"name" : STRING,
"address": STRING
}
Ends the serial-socketio connection.
device name
{
"name" : STRING
}
The rx
channels (identified by the name of the connection <name>
) allow the user to monitor the outputs from the peripherals that are generated in the device.
socket.on('<name>', function(data){
console.log(data);
})
BSD-3