robertalab-ev3dev
robertalab-ev3dev copied to clipboard
refactor lab.py to make the server protocol code portable
We'd like to refactor https://github.com/OpenRoberta/robertalab-ev3dev/blob/develop/roberta/lab.py to not import ev3dev and Hal anymore. Instead when initializing the roberta.lab.Service() we'd like to pass a device module.
The device module will have function such as:
def updateDeviceState(): # set firmware name, update battery status
def notifyConnect(): # eg play a beep, or toggle a led
def notifyDisconnect():
def reset(): # resets actors, sensors
...
Should create a communication library(pull out lab.py and refactoring it) somewhat similar to ev3dev library??
Yes, the idea is to start a new git repository 'openroberta' and extract the code from lab.py. Lab.py contains multiple things (the actual protocol state machine, a dbus service, the code execution sandbox). Ideally those will be split into separate files and will be covered by separate tests. But step by step :)
should Hal(Hardware Abstraction Library) also be included in new library ('openroberta') as previously Hal is an import into lab.py but now after refactoring no more imports into the library as mentioned above.
No, the hal will stay here (robertalab-ev3dev) and there will be a separate hal.py for eg robertalab-raspberrypi. Whenever the current lab.py calls function from hal.py we need an interface instead.
OK got it for each separate hardware separate Hal file
FYI: a 2nd use for the new library could be the naoclient: https://github.com/OpenRoberta/robertalab-naoclient/tree/master/oraclient-choreographe-app/app/scripts
@ensonic what do you mean by an interface through which lab.py calls hal.py functions at some instants.
See my answer in gitter.