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

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

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

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




10. 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

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;

}