Serial Communication - ovgu-FINken/FINken-EYE GitHub Wiki

UART

In the UART communication there is two devices (odroid and paparazzi) transmitting and receiving data that goes through two independent lines which are TX transmission and RX reception, the figure below illustrates the communication model.

Odroid

In this method Odroid sends a data through the serial port (UART, tx and rx pins) and it waits for the same data to be echoed back by the other device, the receive data is pint on the screen, in case that is not received you will see the message "No data found. Timeout reached. Trying again…"

Usually in Linux the serial devices names are:

/dev/ttys0 - First native serial port /dev/ttys0 - Second native serial port

PySerial (https://pypi.python.org/pypi/pyserial) is a library that allows you to send commands, strings and information varied by Serial. Using this library is the simplest way we have to send the data.

sudo apt-get install python-serial

In the following link you can either download the file or copy paste the content to a text editor, just verify the corresponding tty from the devices that you are using. https://github.com/Adu143/SVO/blob/master/serial_recv_py.py

Run the python file python fileName.py

If everything is working fine, you will see the data coming from Odroid.

Paparazzi

It is possible to configure Paparazzi in order to receive data from USB-Serial. All the messages must have the following structure, Example:

PPRZ-message: ABCxxxxxxxDE
A PPRZ_STX (0x99)
B LENGTH (PPRZ_STX->PPRZ_CHECKSUM_B)
C PPRZ_DATA
  0 SENDER_ID
  1 MSG_ID
  2 MSG_PAYLOAD
  . DATA (messages.xml)
D PPRZ_CHECKSUM_A (sum[B->C])
E PPRZ_CHECKSUM_B (sum[ck_a])

https://github.com/paparazzi/pprzlink/tree/hacl-c http://wiki.paparazziuav.org/wiki/Messages_Format

PprzMessage

It is defined in ivy.py. There is also a serial version of the interface in serial.py. https://github.com/paparazzi/pprzlink/blob/hacl-c/lib/v1.0/python/pprzlink/serial.py

Bind callback to Ivy messages matching regex (without any extra parsing)

Parameters: callback: function called on new message with agent, message, from as params regex: regular expression for matching message

bind_raw(callback, regex='(.*)')

Parse an Ivy message into a PprzMessage. :param callback: function to call with ac_id and parsed PprzMessage as params :param ivy_msg: Ivy message string to parse into PprzMessage.

static parse_pprz_msg(callback, ivy_msg)

Send a message

msg: PprzMessage or simple string ac_id – Needed if sending a PprzMessage of telemetry msg_class.

Returns: Number of clients the message sent to, None if msg was invalid

send(msg, ac_id=None)

Send a PprzMessage of datalink msg_class embedded in RAW_DATALINK message

Parameters: msg – PprzMessage

Returns: Number of clients the message sent to, None if msg was invalid

 send_raw_datalink(msg)

http://pprzlink.readthedocs.io/en/latest/python/ivy.html

There is an example in the following link to see how the PprzMessage works. https://github.com/Adu143/SVO/blob/master/serial_send_paparazzi.py

Additionally, there is another file in the ros package (scommunication) called encoder.py which is not completely finished but it is designed according to the requirements to implement the communication and also it could work as a guide to develop future communications.

https://github.com/Adu143/FINken-EYE/blob/master/scommunication/encoder.py