Skip to content

MessageIO

chameau5050 edited this page Apr 5, 2021 · 1 revision

MessageIO


Description :

MessageIO is a class used to centralise all communication between device and use a unified message format. All message send by the MessageIO use the ControlMessage format.

code exemple :

create a MessageIO object :

To create an object, you only need to call the messageIO constructor :

msgManager = MessageIO

add a communication devide :

you can use any comm device interface as long as they provide a sendJSon(Json), readJSon() and isMessageAvailable() methode for example to add a serial device :

msgManager.addDevice(SerialDevice)

the package currently support two type of device the SerialComm and EthernetComm

send a ControlMessage :

To send a controlMessage you only need to use the methode MessageIO.sendMessage(deviceIndex,ControlMessage) where de deviceIndex is simply the index of the device you want to communicate with.

msg = ControlMessage(7,[3,5])

msgManager.sendMessage(0,msg)

read a controlMessage :

To read a controlMessage you only need to use the methode MessageIO.readMessage(deviceIndex) where de deviceIndex is simply the index of the device you want to communicate with.

msg = msgManager.sendMessage(0)

if there is currently no message the readMessage methode will return None otherwise it will return a ControlMessage