Small Protocol commands

1. Commands / data send to module

This protocol command transfers data to the display. Several graphics commands can be packaged in a protocol package. If the data is larger than the maximum packet size, the data can be split into several packets. The module reassembles the individual data packets.


Module receives

DC1

0x11

length (8 Bit)

0xXX

Data.......

0x....

bcc (8 Bit)

0xXX

Module sends

ACK

0x06





Example: #XCB25 changes the brightness into 25%. The command need to be terminated with [LF] which is 0x0A.

So the Small Protocol packet starts with DC1 followed by the length (count of data). At the end there's a bcc (8 bit summary, modulo 256) necessary, calculated with all bytes.  Here's a link to an Online-CRC-Calculator.

Hex: 11 07 23 58 43 42 32 35 0A 89 (here you get it as a file; this may be put to terminal.exe via drag-n-drop)


Example: #XCB75 changes the brightness into 75%.

Hex: 11 07 23 58 43 42 37 35 0A 8E (here you get it as a file)

2. Request data of send buffer

If data is generated in the module, it is stored in the module's send buffer. The data can be requested via the serial interfaces. Whether data is available can be monitored via the pin 20 SBUF, or the higher-level controller can cyclically poll the data.


Module receives

DC2

0x12

length (8 Bit)

0x01

'S'

0x53

bcc (8 Bit)

0x66

Module sends

ACK

0x06





Module sends

DC1

0x11

length (8 Bit)

0xXX

Data.......

0x....

bcc (8 Bit)

0xXX

3. Repeat last data packet

If a received packet of the module is faulty (wrong length or checksum) it can be requested again:


Module receives

DC2

0x12

length (8 Bit)

0x01

'R'

0x52

bcc (8 Bit)

0x65

Module sends

ACK

0x06




Module sends

DC1

0x11

length (8 Bit)

0xXX

Data.......

0x....

bcc (8 Bit)

0xXX

4. Request buffer information

This command queries whether user data is ready (= Pin20 SBUF) and also indicates how much free space is left in the device's receive buffer.


Module receives

DC2

0x12

length (8 Bit)

0x01

'I'

0x49

bcc (8 Bit)

0x5C

Module sends

ACK

0x06




Module sends


DC2

0x12

length (8 Bit)

0x02

send buffer bytes ready (8 Bit)

0xXX

receive buffer bytes free (8 Bit)

0xXX

bcc (8 Bit)

0xXX

5. Protocol settings

This can be used to limit the maximum packet size that the display may send. As default a packet size with up to 2042 bytes of user data is set. Furthermore, the time-out can be set in 1 / 1000s. The time-out is activated when individual bytes have been lost. After the timeout, the entire packet must be retransmitted.


Module receives

Default values

DC2

0x12

length (8 Bit)

0x03

'D'

0x44

packet size send buffer (8 Bit)

0xFF

Time-out (8 Bit) in 1/100s

0xC8 (=2 seconds)

bcc (8 Bit)

0x20

Module sends

ACK

0x06




6. Protocol information

Request protocol settings (see 5.).


Module receives

DC2

0x12

length (8 Bit)

0x01

'P'

0x50

bcc (8 Bit)

0x63

Module sends

ACK

0x06




Module sends


DC2

0x12

length (8 Bit)

0x03

maximum packet size send buffer (8 Bit)

0xFF

packet size send buffer (8 Bit)

0xXX

Time-out (8 Bit) in ms

0xXX

bcc (8 Bit)

0xXX

7. RS485 address select / deselect

With this command, a module can be selected or deselected on the RS485 bus. By default, the module with address 7 is always active.


Module receives


Default values

DC2


0x12

length (8 Bit)


0x03

'A'


0x41

'S' (=select)

'D' (=deselect)

0x53 or 0x44

RS485-address


0xXX

bcc (8 Bit)


0xXX

Module sends


ACK

0x06

----

select


deselect



8. RS485 enable signal - delay

Some RS485 masters take some time to change the enable signal, e.g. to switch from write to read mode. In order to enable successful communication with these devices, this command can be used to delay switching to write mode.


Module receives

Default values

DC2

0x12

length (8 Bit)

0x03

'T'

0x54

Delay in 10 us

0x00 0x00

bcc (8 Bit)

0x69

Module sends


ACK

0x06



9. Request interface exclusively

All 4 serial ports are handled in parallel and equivalently after reset. To ensure that a sequence of protocol packets is executed without interruption, the other serial interfaces can be disabled so the active interface can communicate with the module exclusively. This is useful, for example, for a project update via USB.


Module receives

DC2

0x12

length (8 Bit)

0x02

'G'

0x47

0x00 = Release

0x01 = Request

bcc (8 Bit)

0xXX

Module sends

ACK

0x06




Module sends


DC2

0x12

length (8 Bit)

0x01

active (8 Bit)

0x00 = all

0x01 = RS232

0x02 = SPI

0x03 = I²C

0x04 = USB

bcc (8 Bit)

0xXX

10. Break-Command, Break / Stop execution

If a continuous loop has been programmed in a macro or if a normal process flow is blocked, this command can be used to interrupt and quit. This command is also suitable for update processes.


Module receives

Default values

DC2

0x12

length (8 Bit)

0x02

'C'

0x43

break

0x01 = Wait command

0x02 = actual macro file

0x04 = Clear send buffer

0x08 = Clear receive buffer

0x10 = Delete macro definitions (e.g. port macros)

0xFF = Stop everything

bcc (8 Bit)

0xXX

Module sends

ACK

0x06




11. Hardware Reset

The module is restarted with this protocol command. Depending on the parameter, various start options can be selected to automatically run after the reset.


Module receives

Default values

DC2

0x12

length (8 Bit)

0x02

'B'

0x42

Option

0x00 = normal restart

0x01 = Restart with test mode

0x02 = Restart without running 'start.emc'

0x03 = Restart without loading default styles

0x04 = Show boot-menu (project selection)

0x05 = Reserved

0x06 = Mass Storage Mode (from V1.2)

bcc (8 Bit)

0xXX

Module sends

ACK

0x06




BCC-Calculation

The calculation of the checksum requires a simple 8-bit sum test (modulo 256). The following is a typical C implementation.


//----------------------------------------------------------------------------

//function: buffer2bcc()

//input:    ptr data, block length

//output:   Byte bcc

//descr:    calculate bcc for a buffer

//----------------------------------------------------------------------------

UBYTE buffer2bcc(UBYTE *dat, UBYTE len)

{

 UBYTE bcc = 0;

 while(len--)

   bcc += *dat++;

 return bcc;

}