Download Technical documentation - ISY
Transcript
Autonomous mine sweeper - Balrog 4.1 LiTH 2014-12-11 Communication All data sent and received is encapsulated as shown in Table 4.1. There are messages with no payload, such as manual mode, and there are messages with payload, such as all sensor data messages were the payload is a serialized version if the sensor data object. Note that the payload can’t exceed a length of 216 = 65536 characters. Table 4.1: Data format for a message ID uint16 t id Payload length uint16 t len Payload char payload[len] To receive a data message there are functions in the NetCom class which peaks the TCP sockets buffer to see if there are a whole message to be received and parsed, and a function that receives the data and calls the registered decoder of that particular ID. There is also a legacy implementation in which the id and stream are sent if no id and decoder and/or encoder pair is registered. 4.1.1 Balrog On Balrog there is a system where one can register encoders and decoders. Using the sendDataMessage method in the Communications class the encoder of the data message is called and a data message is sent. On Balrog there is a communication thread which peaks and parses messages and after that sends States, Maps and Mines in a fixed tick. 4.1.2 Base station On the base station the implementation is a bit different although using the same parent class(NetCom). The parsing is done using the legacy implementation, which is due to the use of signals. It would not be possible to register a signal if the instantiated objects were not known. The parsing is done aperiodicly using a socket to signal bridge. The signal is activated as long as there is data to read in the receive buffer of the socket. 4.1.3 Messages In Table 4.2 and 4.3 is a summary of the data sent from Balrog to base station and base station to Balrog respectively. TSRT10 Marcus Bäck Invenire Periculosa balrog-2014@googlegroups.com Lips Page 12