Instructions
How to interact with the robot
Each of your serial device must be associated to a class inheriting from the Board class, defined in the module devices.boards.base
.
In order to associate the class instance with the serial device, a condition must be met: your serial board must respond to the message "I" by giving the name of the custom Board class.
How to use a fake serial devices
You can fake a connection by creating a json config file in the directory settings/fake
.
The id field specify the associated Board class, the messages field the fake request and responses.
Example
Here we specify a fake connection associated with the Dummy Board
{
"id": "Dummy",
"messages": {
"Hello": "World!"
}
}
class Dummy(Board):
def hello(self):
self.connection.send_message("Hello")
return self.connection.receive_message()
In order to associate the two files, we need to add this dummy board to the required boards in settings/robot.json
{
"required_boards": [
"Dummy"
]
}
Interacting with your board
You can now access
python3
>>> from robot.robot import Robot
>>> r = Robot()
>>> r.load_boards()
>>> r.available_methods["Hello"]()
World!