Data Transmission

When the terminal module and the two dashboards have been set up as described in the previous sections, the ADP example goes into a mode where it is continuously sending data to the host computer and receiving data from the host computer according to the configured streams. Below are examples of data messages being transmitted from the ATSAMD21 target to the host computer.

Table 1. Light Sensor ADC Stream
Field Values Description
Token 0xFF  
Message ID 0x40  
Data length 6  
Number of streams (N) 1  
Stream ID 0x0002 ID of ADC value stream
Num bytes (Xn) 2 Number of bytes from the stream
Stream X data sample M 634 (0x027A) The data of the stream (uint_16)
Table 2. Night Mode Stream
Field Values Description
Token 0xFF  
Message ID 0x40  
Data length 5  
Number of streams (N) 1  
Stream ID 0x0029 ID of Night mode stream
Num bytes (Xn) 1 Number of bytes from the stream
Stream X data sample M 0x01 (Bright light, day mode) The data of the stream (uint_8)

When the Night mode changes, the example also changes the background color of the terminal module by sending another MSG_CONF_TERMINAL.

Table 3. MSG_CONF_TERMINAL to update Terminal Background Color to White
Field Values Description
Token 0xFF  
Message ID 0x26  
Data length 26  
ID 0x0000 ID of terminal
Label “Status terminal\0” Terminal label
Width 80 Number of characters wide
Height 50 Number of lines high
Background color 0xFFFFFF RGB background color
Foreground color 0x008000 RGB foreground color
Table 4. Status Message Stream
Field Values Description
Token 0xFF  
Message ID 0x40  
Data length 44  
Number of streams (N) 1  
Stream ID 0x0000 ID of status message stream
Num bytes (Xn) 40 Number of bytes from the stream
Stream X data samples

“It's bright again... Entered day mode!\r\n”

{0x49, 0x74, 0x27, 0x73, 0x20, 0x62, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x61, 0x67, 0x61, 0x69, 0x6E, 0x2E, 0x2E, 0x2E, 0x20, 0x45, 0x6E, 0x74, 0x65, 0x72, 0x65, 0x64, 0x20, 0x64, 0x61, 0x79, 0x20, 0x6D, 0x6F, 0x64, 0x65, 0x21, 0x0D, 0x0A}

The data of the stream (uint_8)

Examples of data messages for the various streams from the computer to the target can be found in the tables below.

Table 5. Hysteresis Low Value Stream Data Message
Field Values Description
Token 0xFF  
Message ID 0x14 MSG_RES_DATA
Data length 5  
Stream ID 0x0011 ID of hysteresis low value stream
Bytes sent 2 Number of bytes in the data payload
Data bytes 0x07C6 The data (uint_16)
Table 6. Hysteresis High Value Stream Data Message
Field Values Description
Token 0xFF  
Message ID 0x14 MSG_RES_DATA
Data length 5  
Stream ID 0x0002 ID of hysteresis high value stream
Bytes sent 2 Number of bytes in the data payload
Data bytes 0x0BB7 The data (uint_16)
Table 7. LED Toggle Stream Data Message
Field Values Description
Token 0xFF  
Message ID 0x14 MSG_RES_DATA
Data length 5  
Stream ID 0x0030 ID of LED toggle stream
Bytes sent 1 Number of bytes in the data payload
Data bytes 0x00 The data (uint_8)