Project

General

Profile

Previous

Up

Communication protocol

Serial port

Communication with the board is established through the serial port, with a 2Mbps baud rate, 8bits, no parity, one stop bit (8N1).

Message format

Messages sent to and received from the microcontrollers are byte oriented streams. All messages start with a caret sign ^ (0x5e) and end with a dollar sign $ (0x24).

Table 1. Message format
Bytes 1 n 1

^

n unsigned bytes

$

An exclamation mark ! inside a message body indicates a transmission error and invalidates the whole message. The characters ^, $, ! and \ are special and must be escaped with a backslash \ followed by the two’s complement of the escaped character (they are thus encoded on two successive bytes).

Table 2. Special characters
Special character Escaped version inside a message body

^

\ 0xa2

$

\ 0xdb

!

\ 0xde

\

\ 0xa3

All messages may embed signed or unsigned integers. They are encoded on 1, 2 or 4 bytes (depending on the message format decribred later), in big-endian format (most significative byte first).

Table 3. Integer encoding
Bytes 1 2 3 4

8 bits integer

n

16 bits integer

n >> 8

n

32 bits integer

n >> 24

n >> 16

n >> 8

n

Messages

ID

This message queries the softwareversion.

Table 4. ID query message
Bytes 1 1 1

^

?

$

Table 5. ID reply message
Bytes 1 1 n>6 (string) 1

^

?

arduioX.Y

$

X.Y represent the software version running on board.

GPIO direction

This message configures the given GPIO for input, with or without pullups, output or PWM.

Table 6. GPIO direction message
Bytes 1 1 1 1 1

^

d

n

direction

$

n is the GPIO number, direction is an integer mapped according to the following table:

direction input/output type

0

input

1

input + pullup

2

digital output

3

~31kHz PWM output

4

~122Hz PWM output

5

~31Hz PWM output

16

WS28XX RGB led output

GPIO out

This message sets the output state of a GPIO.

Table 7. GPIO out message
Bytes 1 1 1 2 1

^

o

n

v

$

n is the GPIO number, v is interpreted as

  • a boolean for digital outputs,

  • the PWM duty cycle (65535 is 100%) for PWM,

  • the led index/color for WS28XX (see Modes of operation).

GPIO out array

This message sets the output state of the first n GPIOs.

Table 8. GPIO out message
Bytes 1 1 1..2n 1

^

O

v

$

For each GPIO starting from 0, v is interpreted as

  • a boolean for digital outputs,

  • the PWM duty cycle (65535 is 100%),

  • the led index/color for WS28XX (see Modes of operation).

GPIO in

This message returns the state of a GPIOs.

Table 9. GPIO in message
Bytes 1 1 1 1

^

i

n

$

n is the GPIO number. The reply has the following format:

Table 10. GPIO in reply
Bytes 1 1 1 2 1

^

i

n

v

$

n is the GPIO number, v is the state (0 or 0xffff for digital I/Os, or the PWM duty cycle for PWM, or the led #0 color.

Analog I/O in

This message returns the state of an analog input.

Table 11. Analog in message
Bytes 1 1 1 1

^

a

n

$

n is the I/O number. The reply has the following format:

Table 12. Analog in reply
Bytes 1 1 1 1 1

^

a

n

v

$

n is the pin number, v is the analog state value.

State request

This message returns the state of all GPIOs and analog input.

Table 13. Analog in message
Bytes 1 1 1

^

s

$

The reply contains two messages, with the state of digital I/O and analog pins.

Table 14. State reply
Bytes 1 1 1..n 1

^

I

v

$

^

A

v

$

The 'I' array is for all GPIOs, the 'A' array for analog inputs.