Short Protocol commands

1. Commands / sending data to display

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

The 16 Bit data are defined as little-endian (Intel format), means that the lower byte need to be sent first.


Module receives

DC3

0x13

length (16 Bit)

0xXX 0xXX

Data.......

0x....

crc (16 Bit)

0xXX 0xXX

Module sends

ACK

0x06





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

So the Short Protocol packet starts with DC3 followed by the length (count of data). At the end there's a  CRC16 (CCITT) necessary, calculated with all bytes. Here's a link to an Online-CRC-Calculator.

Hex: 13 07 00 23 58 43 42 32 30 0A 3D CD (here you get it as a file; this may be put to terminal.exe via drag-n-drop)


Example: #XCB80 changes the brightness to 80%.

Hex: 13 07 00 23 58 43 42 38 30 0A FC 0A (here you get it as a file)

2. Request data of send buffer

If data are generated in display (e.g. touching the touch panel) they will be stored in internal send buffer. Those data can be requested via the serial interfaces.

Refer also to 4. Request buffer information.


Module receives

DC4

0x14

length (16 Bit)

0x01 0x00

'S'

0x53

crc (16 Bit)

0x30 0x08

Module sends

ACK

0x06





Module sends

DC3

0x13

length (16 Bit)

0xXX 0xXX

Data.......

0x....

crc (16 Bit)

0xXX 0xXX

3. Repeat last data packet

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


Module receives

DC4

0x14

length (16 Bit)

0x01 0x00

'R'

0x52

crc (16 Bit)

0x11 0x18

Module sends

ACK

0x06




Module sends

DC3

0x13

length (16 Bit)

0xXX 0xXX

Data.......

0x....

crc (16 Bit)

0xXX 0xXX

4. Request buffer information

This can be done by polling cyclically or better connecting the pin "SBUF" to an interrupt input line. "SBUF" (pin 20) shows with a L that send buffer contains some data to be read out.

The command queries whether there are some user data to be read out and it also indicates how many free space is left in the device receive buffer.


Module receives

DC4

0x14

length (16 Bit)

0x01 0x00

'I'

0x49

crc (16 Bit)

0x4B 0xBB

Module sends

ACK

0x06




Module sends


DC4

0x14

length (16 Bit)

0x04 0x00

send buffer bytes ready (16 Bit)

0xXX 0xXX

receive buffer bytes free (16 Bit)

0xXX 0xXX

crc (16 Bit)

0xXX 0xXX

5. Protocol settings

This can be used to limit the maximum packet size that the display may send. The default maximum packet size is 2042 bytes. 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

DC4

0x14

length (16 Bit)

0x05 0x00

'D'

0x44

packet size send buffer (16 Bit)

0xFA 0x07 (=2042 Byte)

Time-out (16 Bit) in ms

0xD0 0x07 (=2 seconds)

crc (16 Bit)

0x98 0xF5

Module sends

ACK

0x06




6. Protocol information

Request protocol settings (see 5.).


Module receives

DC4

0x14

length (16 Bit)

0x01 0x00

'P'

0x50

crc (16 Bit)

0x53 0x38

Module sends

ACK

0x06




Module sends


DC4

0x14

length (16 Bit)

0x06 0x00

maximum packet size send buffer (16 Bit)

0xFA 0x07 (=2042 Byte)

packet size Send buffer (16 Bit)

0xXX 0xXX

Time-out (16 Bit) in ms

0xXX 0xXX

crc (16 Bit)

0xXX 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

DC4


0x14

length (16 Bit)


0x03 0x00

'A'


0x41

'S' (=select)

'D' (=deselect)

0x53 or 0x44

RS485-address


0xXX

crc (16 Bit)


0xXX 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

DC4

0x14

length (16 Bit)

0x03 0x00

'T'

0x54

Delay in 10 us

0x00 0x00

crc (16 Bit)

0xE9 0x7E

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

DC4

0x14

length (16 Bit)

0x02 0x00

'G'

0x47

0x00 = Release

0x01 = Request

crc (16 Bit)

0xXX 0xXX

Module sends

ACK

0x06




Module sends


DC4

0x14

length (16 Bit)

0x01 0x00

active (16 Bit)

0x00 = all

0x01 = RS232

0x02 = SPI

0x03 = I²C

0x04 = USB

crc (16 Bit)

0xXX 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.

Note that the command "clear buffer" doesn't delete whole command package in intelligent way. It simply deletes bytes in buffer. So there's a risk that command package may dismembered.



Module receives

Default values

DC4

0x14

length (16 Bit)

0x02 0x00

'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

crc (16 Bit)

0xXX 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

DC4

0x14

Länge (16 Bit)

0x02 0x00

'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)

crc (16 Bit)

0xXX 0xXX

Module sends

ACK

0x06




CRC-Calculation

A cyclic redundancy check (CRC) is used to calculate the checksum. A common and well known CRC exam is the CRC-CCITT. The starting value is 0xFFFF. The following is a typical C implementation. The functions must be called externally. The checksum must be preallocated with the starting value.


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

//function: buffer2crc16()

//input:    ptr data, ptr CRC, block length

//output:   ---

//descr:   CRC-CCITT of a buffer

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

void buffer2crc16(UBYTE *dat, UINT16 *pCRC, UINT32 len)

{

 while(len--)

   crc16(*dat++, pCRC);

}


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

//function: sp_crc16()

//input:    data, ptr  CRC

//output:   ---

//descr:   CRC_CCITT (x^16+x^12+x^5+1 = 1 0001 0000 0010 0001 = 0x1021

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

void crc16 (UBYTE dat, volatile UINT16 * crc)

{

 register UINT16 lcrc = *crc;

 lcrc = (lcrc >> 8) | (lcrc << 8);

 lcrc ^= dat;

 lcrc ^= (lcrc & 0xFF) >> 4;

 lcrc ^= lcrc << 12;

 lcrc ^= (lcrc & 0xFF) << 5;

 *crc = lcrc;

}