RM85x Hand-held Terminals User H5834D0003ING
Manual V. 01
Serial Communication
Protocols
DESCRIPTION
The RM85x family of hand-held terminals communicate with a remote controller over an EIA standard
RS-232 serial row at a baud rate of 57.6, 38.4, 19.2 or 9.6 Kb.
RM85x terminals can use two communication protocols: VT100 and CNI proprietary.
CNI Engineering
Via Carpanelli, 24
40011 Anzola dell’Emilia (Bo) Italy
Tel. +39 051 6508911
Fax +39 051 6508912
Info@cnicnc.com
www.cnicnc.com
Downloaded from www.Manualslib.com manuals search engine
Publication Information
Code Date Approval Author ctg
H5834D0003ING 05-10-2007- - UD CNI D
Update List
Revision Added Deleted Modified
V. 01
CNI Engineering S.r.l.
No part of this manual may be reproduced or transmitted in any form or by any means, electronic or
mechanic, including photocopying, without the express written permission of CNI.
Downloaded from www.Manualslib.com manuals search engine
MANUAL ISSUED BY:
Technical Documentation Dept.
CNI Engineering S.r.l.
Via Carpanelli, 24 - 40011 Anzola dell’ Emilia (Bo) Italy
Tel. +39 051 6508911
Fax +39 051 6508912
Info@cnicnc.com
www.cnicnc.com
Document code: H5834D0003ING
Document revision: V. 01
Document issue: 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
Downloaded from www.Manualslib.com manuals search engine
TABLE OF CONTENTS
TABLE OF CONTENTS
1 Installation ....................................................................................................................................... 1
2 Serial communication ...................................................................................................................... 1
2.1 VT100 protocol ........................................................................................................................ 1
2.2 CNI proprietary protocol .......................................................................................................... 1
2.2.1 Control characters ........................................................................................................... 1
2.2.2 Packet checksum (8 bit CRC) ......................................................................................... 2
2.2.3 Packet length................................................................................................................... 2
2.2.4 Node address .................................................................................................................. 2
3 VT100 protocol commands ............................................................................................................. 2
3.1 Cursor control commands ....................................................................................................... 2
3.1.1 Cursor on ......................................................................................................................... 3
3.1.2 Cursor off ......................................................................................................................... 3
3.1.3 Cursor home (Carriage return) ........................................................................................ 3
3.1.4 Cursor down and home ................................................................................................... 4
3.1.5 Cursor down with scroll ................................................................................................... 4
3.1.6 Cursor up with scroll ........................................................................................................ 4
3.1.7 Cursor down without scroll .............................................................................................. 5
3.1.8 Cursor up without scroll ................................................................................................... 5
3.1.9 Cursor right ...................................................................................................................... 6
3.1.10 Cursor left ........................................................................................................................ 6
3.1.11 Backspace ....................................................................................................................... 6
3.1.12 Position cursor................................................................................................................. 7
3.1.13 Tab................................................................................................................................... 7
3.1.14 Save cursor ..................................................................................................................... 7
3.1.15 Restore cursor ................................................................................................................. 8
3.2 Editor commands..................................................................................................................... 8
3.2.1 Send characters to terminal ............................................................................................ 8
3.2.2 Scroll area ..................................................................................................................... 10
3.2.3 Clear screen (Form feed) .............................................................................................. 10
3.2.4 Display fixed characters ................................................................................................ 10
3.2.5 Display blinking characters............................................................................................ 11
3.2.6 Reset character blinking ................................................................................................ 11
3.2.7 Insert characters............................................................................................................ 11
3.2.8 Insert rows ..................................................................................................................... 12
3.3 Character delete commands ................................................................................................. 12
3.3.1 Delete n characters ....................................................................................................... 12
3.3.2 Delete to end of row ...................................................................................................... 13
3.3.3 Delete from start of row ................................................................................................. 13
3.3.4 Delete row ..................................................................................................................... 13
05-10-2007 CNI Engineering S.r.l. i
Downloaded from www.Manualslib.com manuals search engine
TABLE OF CONTENTS
3.3.5 Delete to end of display ................................................................................................. 14
3.3.6 Delete from start of display ............................................................................................ 14
3.3.7 Delete all rows ............................................................................................................... 14
3.3.8 Delete n rows ................................................................................................................. 15
3.4 Information request commands ............................................................................................. 15
3.4.1 Request firmware version .............................................................................................. 15
3.4.2 Request cursor position ................................................................................................. 16
3.4.3 Request communication parameters ............................................................................. 16
3.4.4 Request terminal attributes............................................................................................ 17
3.5 Terminal status commands.................................................................................................... 18
3.5.1 Reset terminal................................................................................................................ 18
3.5.2 Cancel escape sequence .............................................................................................. 18
3.5.3 Self test .......................................................................................................................... 18
3.5.4 Exit VT100 protocol ....................................................................................................... 19
3.6 I/O commands ....................................................................................................................... 19
3.6.1 Switch LEDs................................................................................................................... 19
3.6.2 Monitor keys................................................................................................................... 20
3.6.3 Monitor knob .................................................................................................................. 21
3.6.4 Monitor overrides ........................................................................................................... 22
4 CNI proprietary protocol commands.............................................................................................. 23
4.1.1 Position cursor ............................................................................................................... 23
4.1.2 Write string..................................................................................................................... 24
4.1.3 Delete rows .................................................................................................................... 25
4.1.4 Scroll .............................................................................................................................. 26
4.1.5 Read I/O command........................................................................................................ 27
4.1.6 Read message............................................................................................................... 28
4.1.7 Read character .............................................................................................................. 29
4.1.8 Read version.................................................................................................................. 30
4.1.9 Read type....................................................................................................................... 31
4.1.10 Change parameter ......................................................................................................... 32
4.1.11 Read parameter ............................................................................................................. 33
4.1.12 Restart VT100................................................................................................................ 34
4.1.13 Save parameters to flash memory................................................................................. 35
4.1.14 Read flash memory........................................................................................................ 35
4.1.15 Sample variable ............................................................................................................. 36
4.1.16 Sample address ............................................................................................................. 36
4.1.17 Read samples ................................................................................................................ 37
A Parameters .................................................................................................................................... 38
B Error messages ............................................................................................................................. 42
C Status bits ...................................................................................................................................... 43
05-10-2007 CNI Engineering S.r.l. ii
Downloaded from www.Manualslib.com manuals search engine
Installation
D Invalid command response ........................................................................................................... 43
E I/O.................................................................................................................................................. 44
E.1 The RM851 hand-held terminal............................................................................................. 44
E.1.1 Numbering of keys......................................................................................................... 44
E.1.2 Numbering of LEDs ....................................................................................................... 44
E.1.3 The knob........................................................................................................................ 44
E.2 The RM850 hand held terminal ............................................................................................. 45
E.2.1 Numbering of keys......................................................................................................... 45
E.2.2 Numbering of LEDs ....................................................................................................... 45
E.2.3 Numbering of overrides ................................................................................................. 45
F Calculating the 16 bit CRC............................................................................................................ 46
F.1 MODULE CRC16.H............................................................................................................... 46
F.2 MODULE CRC16.C............................................................................................................... 47
05-10-2007 CNI Engineering S.r.l. iii
Downloaded from www.Manualslib.com manuals search engine
TABLE OF CONTENTS
05-10-2007 CNI Engineering S.r.l. iv
Downloaded from www.Manualslib.com manuals search engine
Installation
1 Installation
Make the settings specified in the relevant User Manual – Technical Specifications and
Connections to ensure correct installation of the RM85x family of hand-held terminals.
2 Serial communication
The minimum size for a transmitted data packet size is 10 bits. These comprise
1 start bit
8 data bits
1 stop bit
Start Data Stop
0 lsb Msb 1
Packet format is as follows:
1 start bit, 8 data bits, no parity, 1 stop bit
2.1 VT100 protocol
RM85x hand-held terminals support a sub-set of commands from the standard VT100 protocol as well
as customised commands for I/O control.
VT100 protocol includes the necessary XON/XOFF communication control. The terminal has a FIFO
buffer in reception and transmission comprising 64 characters.
If the content of the reception buffer reaches more than 48 characters, the terminal sends an XOFF
character (0x13) to the master to request it to stop transmitting as quickly as possible.
Once an XOFF character has been sent and the reception buffer has dropped below 16 characters
again, the terminal sends an XON character (0x11) to tell the master that it can start transmitting
again.
In the same way the master can also send the terminal an XOFF character when so required by its
own control logic. In this case, the terminal stops transmitting as quickly as possible and waits to
receive an XON character before restarting.
For further details on VT100 protocol, visit the following site: http://vt100.net
2.2 CNI proprietary protocol
2.2.1 Control characters
RM85x hand-held terminals send the remote controller commands and data requests in packets
containing a number of characters. Each packet starts with the STX control character and ends with
the ETX control character.
Packets do not normally contain other STX or ETX characters. If STX, ETX, ESC, XON or XOFF
characters have to be transmitted, these must first be split into two characters according to the
following table.
05-10-2007 CNI Engineering S.r.l. 1
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
Character to transmit Characters transmitted
STX (0x02) ESC (0x1B) 0xFF XOR STX (0xFD)
ETX (0x03) ESC (0x1B) 0xFF XOR ETX (0xFC)
ESC (0x1B) ESC (0x1B) 0xFF XOR ESC (0xE4)
XON (0x11) ESC (0x1B) 0xFF XOR XON (0xEE)
XOFF (0x13) ESC (0x1B) 0xFF XOR XOFF (0xEC)
2.2.2 Packet checksum (8 bit CRC)
Each packet also contains a checksum character (CRC), calculated as follows.
STX Datum1 … DatumN CRC ETX
CRC = 0xFF XOR Datum1 XOR … XOR DatumN
N.B.: CRC is calculated on the basis of the bytes in the packet before control characters
are added. This is because control characters must also mask the CRC.
2.2.3 Packet length
The maximum number of data characters that can be transmitted is 68. This number does not include
the control characters in the packet.
2.2.4 Node address
The second byte of each command identifies the target terminal’s node address, as configured on the
terminal’s DIP-switch. If RM85x hand-held terminals communicate over an RS232 connection, this
address must be set to 0x00 to ensure correct functioning. All the switches on the configuration DIP
must be OFF for this setting.
3 VT100 protocol commands
6 groups of VT100 protocol commands are available:
Cursor control commands
Editor commands
Character delete commands
Information request commands
Terminal status commands
I/O commands
3.1 Cursor control commands
This group of command lets you control the position and the characteristics of the cursor.
Whenever the terminal is switched on or reset, the cursor is set off and is positioned at the first column
of the first row of the display.
2 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
VT100 protocol commands
3.1.1 Cursor on
This command makes the cursor blink on the display.
Sequence ESC [ ? 2 5 h
Byte Command Response
01 ESC (0x1b)
02 ‘[‘ (0x5b)
03 ‘?’ (0x3f)
04 ‘2’ (0x32)
05 ‘5’ (0x35)
06 ‘h’ (0x68)
3.1.2 Cursor off
This command stops the cursor blinking, leaving it invisible on the display.
Sequence ESC [ ? 2 5 l
Byte Command Response
01 ESC (0x1b)
02 ‘[‘ (0x5b)
03 ‘?’ (0x3f)
04 ‘2’ (0x32)
05 ‘5’ (0x35)
06 ‘l’ (0x6c)
3.1.3 Cursor home (Carriage return)
This command moves the cursor to the first column of the row on which it is currently positioned.
Sequence CR
Byte Command Response
00 CR (0x0d)
05-10-2007 CNI Engineering S.r.l. 3
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
3.1.4 Cursor down and home
The VT, LF, ESC E character sequence moves the cursor to the first column of the next row after the
row on which it is currently positioned.
If the cursor is already on the last row in the scroll area, all displayed rows are moved up.
Sequence VT
Byte Command Response
00 VT (0x0b)
Sequence LF
Byte Command Response
00 LF (0x0a)
Sequence ESC E
Byte Command Response
00 ESC (0x1b)
01 ‘E’ (0x45)
3.1.5 Cursor down with scroll
This command moves the cursor to the next row after the row on which it is currently positioned,
leaving it in the same column. If the cursor is already on the last row in the scroll area, all displayed
rows are moved up.
Sequence ESC D
Byte Command Response
00 ESC (0x1b)
01 ‘D’ (0x45)
3.1.6 Cursor up with scroll
This command moves the cursor to the next row above the row on which it is currently positioned,
leaving it in the same column. If the cursor is already on the first row in the scroll area, all displayed
rows are moved down.
Sequence ESC M
Byte Command Response
00 ESC (0x1b)
01 ‘M’ (0x4d)
4 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
VT100 protocol commands
3.1.7 Cursor down without scroll
This command moves the cursor down in the same column. The number of rows moved is determined
by the parameter Pn. If Pn is omitted, or if its value is set to 0 or 1, the cursor moves to the next row
after the row on which it is currently positioned. If the value of Pn is set to n, the cursor moves to the
nth row after the row on which it is currently positioned.
If n is greater than the number of rows displayed, the cursor moves to the last row of the display.
Sequence ESC [ Pn B
Example: To move the cursor to the next row after the row on which it is currently positioned (Pn=1).
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x5b)
02 ‘1’ (0x31)
03 ‘B’ (0x42)
3.1.8 Cursor up without scroll
This command moves the cursor up in the same column. The number of rows moved is determined by
the parameter Pn. If Pn is omitted, or if its value is set to 0 or 1, the cursor moves to the next row
above the row on which it is currently positioned. If the value of Pn is set to n, the cursor moves to the
nth row above the row on which it is currently positioned.
If n is greater than the number of rows displayed, the cursor moves to the first row of the display.
Sequence ESC [ Pn A
Example: To move the cursor to the next row above the row on which it is currently positioned (Pn=1).
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x5b)
02 ‘1’ (0x31)
03 ‘A’ (0x41)
05-10-2007 CNI Engineering S.r.l. 5
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
3.1.9 Cursor right
This command moves the cursor to the right along the row on which it is currently positioned. The
number of columns moved is determined by the parameter Pn. If Pn is omitted, or if its value is set to 0
or 1, the cursor moves to the next column to the right. If the value of Pn is set to n, the cursor moves n
columns to the right.
If n is greater than the number of columns between the column in which the cursor is currently
positioned and the right display margin, the cursor moves to the right-most column of the display.
Sequence ESC [ Pn C
Example: To move the cursor 10 columns to the right (Pn=10).
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x5b)
02 ‘1’ (0x31)
03 ‘0’ (0x30)
04 ‘C’ (0x43)
3.1.10 Cursor left
This command moves the cursor to the left along the row on which it is currently positioned. The
number of columns moved is determined by the parameter Pn. If Pn is omitted, or if its value is set to 0
or 1, the cursor moves to the next column to the left. If the value of Pn is set to n, the cursor moves n
columns to the left.
If n is greater than the number of columns between the column in which the cursor is currently
positioned and the left display margin, the cursor moves to the left-most column of the display.
Sequence ESC [ Pn D
Example: To move the cursor 9 columns to the left (Pn=9).
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x5b)
02 ‘9’ (0x39)
03 ‘D’ (0x43)
3.1.11 Backspace
This command moves the cursor one column to the left along the row on which it is currently
positioned. If the command is used when the cursor is already on the first column of the display, the
cursor does not move.
Sequence BS
Byte Command Response
00 BS (0x08)
6 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
VT100 protocol commands
3.1.12 Position cursor
This command moves the cursor to the position determined by the parameters Pn-r, and Pn-c. Pn-r
determines the row to which the cursor moves while Pn-c determines the column.
If Pn-r is omitted or if its value is set to 0 or 1, the cursor moves to the first row of the display. If Pn-c is
omitted or if its value is set to 0 or 1, the cursor moves to the first column of the display.
Display rows are numbered from 1 to 4 starting from the top, and columns are numbered 1 to 20
starting from the left.
Sequence ESC [ Pn-r ; Pn-c H
Example: To move the cursor to row 2, column 12 (Pn-r=2; Pn-c=12).
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x5b)
02 ‘1’ (0x31)
03 ‘;’ (0x3b)
04 ‘1’ (0x31)
05 ‘3’ (0x33)
06 ‘H’ (0x48)
3.1.13 Tab
This command moves the cursor to the first tab position it meets to the right. The contents of the row
are not changed. The fixed tab positions are: column 9, column 17, and column 20. If the cursor is
already positioned on the last column of the display (column 20), is does not move.
Sequence HT
Byte Command Response
00 HT (0x09)
3.1.14 Save cursor
This command saves the position of the cursor (its row and column) and its attributes (off or on).
Sequence ESC 7
Byte Command Response
00 ESC (0x1b)
01 ‘7’ (0x37)
05-10-2007 CNI Engineering S.r.l. 7
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
3.1.15 Restore cursor
This command restores the position of the cursor (row and column) and its attributes (off or on),
previously saved with the Save cursor command.
Sequence ESC 8
Byte Command Response
00 ESC (0x1b)
01 ‘8’ (0x38)
3.2 Editor commands
This group of commands lets you:
send characters to the terminal
set character blinking parameters
define the scroll area
N.B.: Whenever the terminal is switched on or reset, the characters are displayed fixed (not
blinking) and the scroll area is set to one display.
3.2.1 Send characters to terminal
This command sends the terminal a sequence of characters to be displayed starting from the current
cursor position. For each character received, the cursor moves one column to the right along the row
on which it is currently positioned until it reaches the last column on the display. If the cursor is already
located on the last column of the display, all characters are displayed at that position and the cursor
itself does not move.
Characters are transmitted using standard ASCII code. The terminal displays all characters apart from
those shown in the following table.
Code Description
0x05 version request command
0x07
0x08 backspace
0x09 tab
0x0a cursor down and home
0x0b cursor down and home
0x0c form feed
0x0d carriage return
0x0e
0x0f
0x11 XON
0x13 XOFF
0x18 cancel escape sequence
0x1a cancel escape sequence
0x1b start escape sequence
The characters encoded as 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe and 0xff are customisable.
These characters can be modified by changing the corresponding parameters described in Appendix
A.
8 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
VT100 protocol commands
Example: To send the string “Rm-851”.
Byte Command Response
00 ‘R’ (0x52)
01 ‘m’ (0x6d)
02 ‘-’ (0x2d)
03 ‘8’ (0x38)
04 ‘5’ (0x35)
05 ‘1’ (0x31)
The figure below shows what characters are available.
05-10-2007 CNI Engineering S.r.l. 9
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
3.2.2 Scroll area
This command sets the scroll area,. i.e. the area by which the display scrolls at one time. The
parameter Pn-r1 determines the first row of the scroll area and parameter Pn-r2 determines the last
row. If Pn-r1 is set to a value greater than parameter Pn-r2, the entire display scrolls.
This command also moves the cursor to the first column of the first row of the next scroll area.
Sequence ESC [ Pn-r1 ; Pn-r2 r
Example: To set the end of the scroll area between the second and third rows.
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x5b)
02 ‘2’ (0x32)
03 ‘;’ (0x3b)
04 ‘3’ (0x33)
05 ‘r’ (0x72)
3.2.3 Clear screen (Form feed)
This command displays a screen full of blank characters (0x32) and moves the cursor to the first
column of the first row.
Sequence FF
Byte Command Response
00 FF (0x0c)
3.2.4 Display fixed characters
This command sets characters to appear fixed (not blinking).
The terminal displays all characters sent after this command as fixed.
Sequence ESC [ 0 m
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x5b)
02 ‘0’ (0x30)
03 ‘m’ (0x6d)
10 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
VT100 protocol commands
3.2.5 Display blinking characters
This command sets characters to appear blinking.
The terminal displays all characters sent after this command as blinking.
Sequence ESC [ 5 m
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x5b)
02 ‘5’ (0x35)
03 ‘m’ (0x6d)
3.2.6 Reset character blinking
This command cancels character blinking.
Sequence ESC [ 2 5 m
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x5b)
02 ‘2’ (0x32)
03 ‘5’ (0x35)
04 ‘m’ (0x6d)
3.2.7 Insert characters
This command inserts the number of blank characters (0x32) determined by the parameter Pn. Blank
characters are inserted starting from the current cursor position.
Characters present to the right of the cursor on the same row are moved to the right by the number of
blank characters inserted. If Pn is omitted or if its value set to 0, just one blank character is inserted.
This command does not change the position of the cursor.
Sequence ESC [ Pn @
Example: To insert 5 blank characters.
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x5b)
02 ‘5’ (0x35)
03 ‘@’ (0x40)
05-10-2007 CNI Engineering S.r.l. 11
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
3.2.8 Insert rows
This command inserts the number of blank rows determined by the parameter Pn. Blank rows are
inserted starting from the row on which the cursor is currently positioned. All rows beneath the row the
cursor is on are moved down accordingly.
This command does not take the current scroll area setting into account.
If Pn is omitted or if its value is set to 0, just one blank row is inserted.
This command does not change the position of the cursor.
Sequence ESC [ Pn L
Example: To insert 1 row below the row on which the cursor is currently positioned.
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x5b)
02 ‘1’ (0x31)
03 ‘L’ (0x4c)
3.3 Character delete commands
This group of command lets you delete characters, parts of rows or even a complete display.
3.3.1 Delete n characters
This command deletes the number of characters determined by the parameter Pn. Characters are
deleted rightwards starting from the current cursor position. If Pn is omitted or if its value is set to 0,
just one character is deleted. No more characters can be deleted than the number present between
the cursor position and the last character in the row.
This command does not change the position of the cursor.
Sequence ESC [ Pn P
Example: To delete 2 characters starting from the current cursor position.
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x5b)
02 ‘2’ (0x32)
03 ‘P’ (0x50)
12 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
VT100 protocol commands
3.3.2 Delete to end of row
This command deletes all characters from the current cursor position to the end of the row.
It does not change the position of the cursor.
Sequence ESC [ 0 K
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x5b)
02 ‘0’ (0x30)
03 ‘K’ (0x4b)
3.3.3 Delete from start of row
This command deletes all characters from the start of the row to the current cursor position.
It does not change the position of the cursor.
Sequence ESC [ 1 K
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x5b)
02 ‘1’ (0x31)
03 ‘K’ (0x4b)
3.3.4 Delete row
This command deletes the entire row on which the cursor is currently positioned.
It does not change the position of the cursor.
Sequence ESC [ 2 K
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x5b)
02 ‘2’ (0x32)
03 ‘K’ (0x4b)
05-10-2007 CNI Engineering S.r.l. 13
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
3.3.5 Delete to end of display
This command deletes all characters from the current cursor position to the last character in the
display (last row, last column).
It does not change the position of the cursor.
Sequence ESC [ 0 J
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x5b)
02 ‘0’ (0x30)
03 ‘J’ (0x4a)
3.3.6 Delete from start of display
This command deletes all characters from the start of the display (first row, first column) to the current
cursor position (inclusive).
It does not change the position of the cursor.
Sequence ESC [ 1 J
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x5b)
02 ‘1’ (0x31)
03 ‘J’ (0x4a)
3.3.7 Delete all rows
This command deletes all characters from all rows of the display.
It does not change the position of the cursor.
Sequence ESC [ 2 J
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x5b)
02 ‘2’ (0x32)
03 ‘J’ (0x4a)
14 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
VT100 protocol commands
3.3.8 Delete n rows
This command deletes the number of rows determined by the parameter Pn, starting from the row on
which the cursor is currently positioned. If Pn is omitted or if its value is set to 0, just one row is
deleted.
This command does not change the position of the cursor.
Sequence ESC [ Pn M
Example: To delete 2 rows starting from the row on which the cursor is currently positioned.
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x5b)
02 ‘2’ (0x32)
03 ‘M’ (0x4d)
3.4 Information request commands
3.4.1 Request firmware version
This command requests the terminal to return the firmware version.
Sequence 0x05
Example: To request the firmware version, receiving the response from the terminal that its firmware
is version 4.
Byte Command Response
00 (0x05) ‘R’ (0x52)
01 ‘M’ (0x4d)
02 ‘8’ (0x38)
03 ‘5’ (0x35)
04 ‘x’ (0x78)
05 ‘-‘ (0x2d)
06 ‘4’ (0x34)
05-10-2007 CNI Engineering S.r.l. 15
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
3.4.2 Request cursor position
This command requests the terminal to return the numbers of the row and column on which the cursor
is currently positioned.
Sequence ESC [ 6 n
Terminal response ESC [ Pn-r ; Pn-c R
sequence
In the terminal’s response sequence, the first parameter (Pn-r) identifies the number of the row on
which the cursor is positioned, while the second (Pn-c) identifies the number of the column.
Example: To request the cursor position, receiving the response from the terminal that the cursor is
on row 2, column 9.
Byte Command Response
00 ESC (0x1b) ESC (0x1b)
01 ‘[‘ (0x5b) ‘[’ (0x5b)
02 ‘6’ (0x36) ‘2’ (0x32)
03 ‘n’ (0x6e) ‘;’ (0x3b)
04 ‘9’ (0x39)
05 ‘R’ (0x52)
3.4.3 Request communication parameters
This command requests the terminal to return the current communication parameters.
Sequence ESC [<sol> x
Terminal ESC [ <sol> ; <par> ; <nbits> ; <xspeed> ;
response <rspeed> ; <clkmul> ; <flags> x
sequence
The following table explains the meanings of the parameters returned.
Parameter Value Meaning
1 This message is a request. After it, the terminal will
return reports in response to requests.
<sol>
3 This message is a report (DECREPTPARM) which
terminal creates only on request.
1 No Parity
<par> 4 Odd parity
5 Even parity
1 8 bits per character
<nbits>
2 7 bits per character
112 9600 bits per second
<xspeed>, 120 19200 bits per second
<rspeed> 240 38400 bits per second
360 57600 bits per second
<clkmul> 1 Bit multiplication ratio is 16
<flags> 0
16 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
VT100 protocol commands
Example: If baud rate is 57.6 Kb, the terminal provides the following response.
Byte Command Response
00 ESC (0x1b) ESC (0x1b)
01 ‘[‘ (0x5b) ‘[’ (0x5b)
02 ‘1’ (0x31) ‘3’ (0x33)
03 ‘x’ (0x78) ‘;’ (0x3b)
04 ‘1’ (0x31)
05 ‘;’ (0x3b)
06 ‘1’ (0x31)
07 ‘;’ (0x3b)
08 ‘3’ (0x37)
09 ‘6’ (0x32)
10 ‘0’ (0x30)
11 ‘;’ (0x3b)
12 ‘3’ (0x37)
13 ‘6’ (0x32)
14 ‘0’ (0x30)
15 ‘;’ (0x3b)
16 ‘1’ (0x31)
17 ‘;’ (0x3b)
18 ‘0’ (0x30)
19 ‘x’ (0x78’
3.4.4 Request terminal attributes
This command requests the terminal to return its identifying attributes.
Sequence ESC [ c
Terminal ESC [ 1 ; 2 c
response
sequence
Example: To request the terminal’s attributes, receiving the response [c, showing that the terminal is
an “advanced video option” terminal.
Byte Command Response
00 ESC (0x1b) ESC (0x1b)
01 ‘[‘ (0x5b) ‘[’ (0x5b)
02 ‘c’ (0x63) ‘1’ (0x31)
03 ‘;’ (0x3b)
04 ‘2’ (0x32)
04 ‘c’ (0x63)
05-10-2007 CNI Engineering S.r.l. 17
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
3.5 Terminal status commands
3.5.1 Reset terminal
This command resets the terminal to its initial state, characterised by:
cursor off, at position row 1, column 1
display empty
scroll area set between first and last rows of display
fixed (non-blinking) characters
Sequence ESC c
Byte Command Response
00 ESC (0x1b)
01 ‘c’ (0x63)
3.5.2 Cancel escape sequence
This command cancels any escape sequence still active on the terminal.
Sequence CAN
Byte Command Response
00 CAN (0x18)
3.5.3 Self test
This command fills the display with ‘E’s and moves the cursor to row 1, column 1.
Sequence ESC # 8
Byte Command Response
00 ESC (0x1b)
01 ‘#’ (0x23)
02 ‘8’ (0x38)
18 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
VT100 protocol commands
3.5.4 Exit VT100 protocol
This command makes the terminal exit VT100 protocol and start using CNI proprietary protocol
instead. To re-start using VT100 protocol, you must either switch the terminal off and back on again, or
send the VT100 selection command in CNI proprietary protocol.
Sequence ESC [ ? J
Byte Command Response
00 ESC (0x1b)
01 ‘[’ (0x3b)
02 ‘?’ (0x3f)
03 ‘J’ (0x4a)
3.6 I/O commands
3.6.1 Switch LEDs
This command switches the terminal’s LEDs on or off. The first parameter (Pn-e) switches the LED on
and off. The second parameter (Pn-l) selects what LED to switch.
If the value of Pn-e is 1, the LED selected by Pn-l is switched on.
If the value of Pn-e is 0, the LED selected by Pn-l is switched off.
Sequence ESC [ Pn-e ; Pn-l k
Example: To switch LED number 3 on.
Byte Command Response
00 ESC (0x1b)
01 ‘[‘ (0x5b)
02 ‘1’ (0x31)
03 ‘;’ (0x3b)
04 ‘3’ (0x33)
05 ‘k’ (0x6b)
05-10-2007 CNI Engineering S.r.l. 19
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
3.6.2 Monitor keys
Whenever one of its keys changes state, the terminal sends the following sequence.
Sequence ESC [ Pn-1 ; Pn-2 ; Pn-3 t
Parameter Pn-1 identifies the state of the key. Value 1 means that the key is pressed, 0 means it is
released.
Parameter Pn-2 identifies the key that has changed state. This parameter can have any value from 1
to 32.
Parameter Pn-3 is the 16 bit CRC for all characters sent up to and including the second ‘;’.
See Appendix F for further information.
Example: Key 3 has been pressed.
Byte Sequence sent Response
00 ESC (0x1b)
01 ‘[‘ (0x5b)
02 ‘1’ (0x31)
03 ‘;’ (0x3b)
04 ‘3’ (0x33)
05 ‘;’ (0x3b)
06 ‘3’ (0x33)
07 ‘8’ (0x38)
08 ‘9’ (0x39)
09 ‘4’ (0x34)
10 ‘0’ (0x30)
11 ‘t’ (0x74)
20 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
VT100 protocol commands
3.6.3 Monitor knob
Whenever its control knob changes state, the terminal sends the following sequence.
Sequence ESC [ Pn-1 ; Pn-2 ; Pn-3 q
Parameter Pn-1 identifies the state of the control knob. This parameter can have any value from 0 to
65535.
If the parameter value is currently 0 and the knob is turned anti-clockwise, the value becomes 65535.
If the parameter value is 65535 and the knob is turned clockwise, the value becomes 0.
Parameter Pn-2 identifies the knob that has changed state. This parameter can only have the value 1.
Parameter Pn-3 is the 16 bit CRC for all characters sent up to and including the second ‘;’.
See Appendix F for further information.
Example: The current value of the knob is 32. The following sequence is sent when the knob is
turned.
Byte Sequence sent Response
00 ESC (0x1b)
01 ‘[‘ (0x5b)
02 ‘2’ (0x32)
03 ‘3’ (0x33)
04 ‘;’ (0x3b)
05 ‘1’ (0x31)
06 ‘;’ (0x3b)
07 ‘4’ (0x34)
08 ‘6’ (0x36)
09 ‘3’ (0x33)
10 ‘2’ (0x32)
11 ‘2’ (0x32)
12 ‘q’ (0x71)
05-10-2007 CNI Engineering S.r.l. 21
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
3.6.4 Monitor overrides
Whenever one of its overrides changes state, the terminal sends the following sequence.
Sequence ESC [ Pn-1 ; Pn-2 ; Pn-3 p
Parameter Pn-1 identifies the state of the override. This parameter can have any value from 0 to 255.
Parameter Pn-2 identifies the override that has just changed state. This parameter can have a value
of either 1 or 2.
Parameter Pn-3 is the 16 bit CRC for all characters sent up to and including the second ‘;’.
See Appendix F for further information.
Example: The current override value is 190. The following sequence is sent when the override is
turned.
Byte Command Response
00 ESC (0x1b)
01 ‘[‘ (0x5b)
02 ‘1’ (0x31)
03 ‘9’ (0x39)
04 ‘0’ (0x30)
05 ‘;’ (0x3b)
06 ‘2’ (0x32)
07 ‘;’ (0x3b)
08 ‘3’ (0x33)
09 ‘1’ (0x31)
10 ‘0’ (0x30)
11 ‘8’ (0x38)
12 ‘7’ (0x37)
13 ‘p’ (0x70)
22 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
CNI proprietary protocol commands
4 CNI proprietary protocol commands
Packets sent in response to CNI proprietary commands always contain 4 Status Bits. See
Appendix C for the meanings of these bits.
4.1.1 Position cursor
This command positions the cursor at the CursorPosition, which varies from 0 to 79, and assigns it
CursorAttributes with the following meaning.
Cursor attribute Meaning
0 Cursor off
1 Cursor on
2 Cursor blinking
Byte Command Response
01 STX STX
02 Node Node
03 0x08 0x0 StatusBit
04 CmdCursorPosit CmdCursorPosit
05 0x00 0x00
06 CursorAttribute CursorAttribute
07 CursorPosition CursorPosition
08 CRC CRC
09 ETX ETX
Example: To position the cursor of the terminal at node address 0 at position 16 with the cursor on.
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x08 0x0 0x04
(StatusBit)
04 0x28 (CmdCursorPosit) 0x28 (CmdCursorPosit)
05 0x00 0x00
06 0x01 (CursorAttribute) 0x01 (CursorAttribute)
07 0x10 (CursorPosition) 0x10 (CursorPosition)
08 0xce (CRC) 0xc2 (CRC)
09 0x03 (ETX) 0x03 (ETX)
05-10-2007 CNI Engineering S.r.l. 23
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
4.1.2 Write string
This command writes a string of characters NumberCharacters long, with blinking characters if
CharacterBlinking is set to 1.
The string is displayed at position PositionCharacters.
Byte Command Response
01 STX STX
02 Node Node
03 0x08 0x0 StatusBit
04 CmdWriteStr CmdWriteStr
05 NumberCharacters NumberCharacters
06 CharacterBlinking CharacterBlinking
07 PositionCharacters PositionCharacters
08 Second character CRC
09 First character ETX
10 Fourth character
11 Third character
…
2*n+6 (2n)th character
2*n+7 (2n-1)th character
2*n+8 CRC
2*n+9 ETX
Example: To write the string “abcde” in blinking characters at position 16 on the terminal at node
address 0.
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x08 0x0 StatusBit
(0x00)
04 0x18 (CmdWriteStr) 0x18 (CmdWriteStr)
05 0x05 (NumberCharacters) 0x05 (NumberCharacters)
06 0x01 (CharacterBlinking) 0x01 (CharacterBlinking)
07 0x10 (PositionCharacters) 0x10 (PositionCharacters)
08 0x62 (Second character =’b’) 0xF3 (CRC)
09 0x61 (First character =’a’) 0x03 (ETX)
10 0x64 (Fourth character =’d’)
11 0x63 (Third character =’c’)
12 0x00 (Sixth character)
13 0x65 (Fifth character =’e’)
14 0x9a (CRC)
15 0x03 (ETX)
24 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
CNI proprietary protocol commands
4.1.3 Delete rows
This command deletes the display rows defined bit by bit in RowsBit. The first bit set to 1 identifies
the first row, the second bit set to 1 the second row and so on.
Byte Command Response
01 STX STX
02 Node Node
03 0x08 0x0 StatusBit
04 CmdDelRow CmdDelRow
05 0x00 0x00
06 0x00 0x00
07 RowsBit RowsBit
08 CRC CRC
09 ETX ETX
Example: To delete the first row from the display of the terminal at node address 0.
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x08 0x0 StatusBit
(0x04)
04 0x20 (CmdDelRow) 0x20 (CmdDelRow)
05 0x00 0x00
06 0x00 0x00
07 0x01 (RowsBit) 0x01 (RowsBit)
08 0xd6 (CRC) 0xda (CRC)
09 0x03 (ETX) 0x03 (ETX)
05-10-2007 CNI Engineering S.r.l. 25
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
4.1.4 Scroll
This command scrolls up (if ScrollUp is set to 1) or scrolls down (if ScrollUp is set to 0) by the
number of rows determined by NRowsScroll
Byte Command Response
01 STX STX
02 Node Node
03 0x08 0x0 StatusBit
04 CmdScroll CmdScroll
05 0x00 0x00
06 NRowsScroll NRowsScroll
07 ScrollUp ScrollUp
08 CRC CRC
09 ETX ETX
Example: To scroll the display of the terminal at node address 0 up 4 rows.
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x08 0x0 0x00
(StatusBit)
04 0x30 (CmdScroll) 0x30 (CmdScroll)
05 0x00 0x00
06 0x04 (NRowsScroll) 0x04 (NRowsScroll)
07 0x01 (ScrollUp) 0x01 (ScrollUp)
08 0xc2 (CRC) 0xca (CRC)
09 0x03 (ETX) 0x03 (ETX)
26 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
CNI proprietary protocol commands
4.1.5 Read I/O command
This command requests the terminal to return data on the states of its I/O devices: knob, override/s,
and keys.
Byte Command Response
01 STX STX
02 Node Node
03 CmdDefault CmdDefault StatusBit
04 0x00 D1
05 CRC D0
06 ETX D3
07 D2
08 CRC
09 ETX
Meaning of returned data
The meaning is determined by the first StatusBit bit according to the following table.
First Meaning D0 Meaning D1 Meaning D2 Meaning D3
StatusBit
0 Bit by bit status for Bit by bit status for keys Bit by bit status for Bit by bit status for
keys 1 to 8 9 to 16 keys 17 to 24 keys 25 to 32
1 1st override status 2nd override status High byte of knob Low byte of knob
status status
Example: To send the read I/O command to the terminal at node address 0 twice, receiving in
response an I/O status showing that key 18 is pressed, override 1 is set to 1, override 2 to 5 and the
knob has been turned to a value of 1063 (0x0427).
First send:
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x00 (CmdDefault) 0xc (CmdDefault) 0x0 (StatusBit)
04 0x00 0x00 (D1)
05 0x00 (CRC) 0x00 (D0)
06 0x03 (ETX) 0x00 (D3)
07 0x02 (D2; [0x1b 0xfd]=0x02)
08 0x3d (CRC)
09 0x03 (ETX)
Second send:
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x00 (CmdDefault) 0xc (CmdDefault) 0x1 (StatusBit)
04 0x00 0x05 (D1)
05 0x00 (CRC) 0x01 (D0)
06 0x03 (ETX) 0x04 (D3)
07 0x27 (D2)
08 0x19 (CRC)
09 0x03 (ETX)
05-10-2007 CNI Engineering S.r.l. 27
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
4.1.6 Read message
This command reads the error message saved in the terminal.
Byte Command Response
01 STX STX
02 Node Node
03 0x08 0x0 StatusBit
04 CmdGetAlarm CmdGetAlarm
05 0x00 0x00
06 0x00 High byte of message code
07 0x00 Low byte of message code
08 CRC CRC
09 ETX ETX
Example: To read the message in the terminal at node address 0, encoded 0x4003 (alarm for
incorrect command received).
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x08 0x0 StatusBit
(0x00)
04 0x48 (CmdGetAlarm) 0x48 (CmdGetAlarm)
05 0x00 0x00
06 0x00 0x40 (High byte of message code)
07 0x00 0x03 (Low byte of message code;
[0x1b 0xfc]=0x03)
08 0xbf (CRC) 0xf4 (CRC)
09 0x03 (ETX) 0x03 (ETX)
28 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
CNI proprietary protocol commands
4.1.7 Read character
This command reads the character currently displayed at the position CharacterPosition. The
character is that actually ‘printed to screen’ when the command is received, so if you wish to read a
character that is blinking, you may read either a blank (0x20) or the character itself, depending on the
instant the command is sent.
Byte Command Response
01 STX STX
02 Node Node
03 0x08 0x0 StatusBit
04 CmdReadChar CmdReadChar
05 0x00 0x00
06 0x00 0x00
07 CharacterPosition CharacterRead
08 CRC CRC
09 ETX ETX
Example: To read the character currently at position 16 on the display of the terminal at node address
0, an ‘a’ (0x61) that is not blinking.
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x08 0x0 0x00
(StatusBit)
04 CmdReadChar (0x38) 0x38 (CmdReadChar)
05 0x00 0x00
06 0x00 0x00
07 CharacterPosition (0x10) 0x61 (CharacterRead)
08 CRC (0xbf) 0xa6 (CRC)
09 ETX (0x03) 0x03 (ETX)
05-10-2007 CNI Engineering S.r.l. 29
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
4.1.8 Read version
This command reads the version of the terminal’s firmware.
Byte Command Response
01 STX STX
02 Node Node
03 0x08 0x0 StatusBit
04 CmdGetVer CmdGetVer
05 0x00 0x00
06 0x00 HighByteVersion
07 0x00 LowByteVersion
08 CRC CRC
09 ETX ETX
Example: To read the version of the firmware in the terminal at node address 0, which is 1029
(0x0405)
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x08 0x0 0x00
(StatusBit)
04 0x50 (CmdGetVer) 0x50 (CmdGetVer)
05 0x00 0x00
06 0x00 0x04 (HighByteVersion)
07 0x00 0x05 (LowByteVersion)
08 CRC (0xbf) 0xae (CRC)
09 ETX (0x03) 0x03 (ETX)
30 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
CNI proprietary protocol commands
4.1.9 Read type
This command reads the terminal type.
Byte Command Response
01 STX STX
02 Node Node
03 0x08 0x0 StatusBit
04 CmdGetType CmdGetType
05 0x00 0x00
06 0x00 HighByteType
07 0x00 LowByteType
08 CRC CRC
09 ETX ETX
Response
The following table summarises the possible meanings of the response.
Type returned Terminal type Bus type
0x0200 RM85x ENET
0x0201 RM85x RS485
0x0202 RM85x CAN
0x0203 RM85x RS232 VT100
Example: To read the type of the terminal at node address 0, which is type 0x0203 (with an RS232
serial bus and VT100 default protocol).
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x08 0x0 0x00 (StatusBit)
04 0xb8 (CmdGetType) 0xb8 (CmdGetType)
05 0x00 0x00
06 0x00 0x02 (HighByteType;
[0x1b 0xfd] = 0x02)
07 0x00 0x03 (LowByteType;
[0x1b 0xfc] = 0x03)
08 0xbf (CRC) 0x46 (CRC)
09 0x03 (ETX) 0x03 (ETX)
05-10-2007 CNI Engineering S.r.l. 31
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
4.1.10 Change parameter
This command changes one of the parameters in the terminal.
Byte Command Response
01 STX STX
02 Node Node
03 0x08 0x0 StatusBit
04 CmdChgPar CmdChgPar
05 0x00 0x00
06 High part of parameter code High part of parameter code
07 Low part of parameter code Low part of parameter code
08 High part of parameter value CRC
09 Low part of parameter value ETX
10 CRC
11 ETX
Example: To assign the value 1200 (0x04b0) to the parameter that determines character blinking
frequency (code 0x010f) on the terminal at node address 0.
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x08 0x0 0x0 (StatusBit)
04 0x68 (CmdChgPar) 0x68 (CmdChgPar)
05 0x00 0x00
06 0x01 (High part of parameter code) 0x01 (High part of parameter code)
07 0x0f (Low part of parameter code) 0x0f (Low part of parameter code)
08 0x04 (High part of parameter value) 0x99 (CRC)
09 0xb0 (Low part of parameter value) 0x03 (ETX)
10 0x25 (CRC)
11 0x03 (ETX)
Example: To assign the value 1100 (0x044c) to the parameter 0x010 and to assign the value 1044
(0x0414) to the parameter 0x010f on the terminal at node address 0.
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x08 0x0 0x00
(StatusBit)
04 0x68 (CmdChgPar) 0x68 (CmdChgPar)
05 0x00 0x00
06 0x01 (High part of parameter code) 0x01 (High part of parameter code)
07 0x0e (Low part of parameter code) 0x0e (Low part of parameter code)
08 0x04 (High part of parameter value) 0x98 (CRC)
09 0x4c (Low part of parameter value) 0x03 (ETX)
10 0x01 (High part of parameter code)
11 0x0f (Low part of parameter code)
12 0x04 (High part of parameter value)
13 0x14 (Low part of parameter value)
14 0xc6 (CRC)
15 0x03 (ETX)
32 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
CNI proprietary protocol commands
4.1.11 Read parameter
This command reads the terminal’s internal parameters.
Byte Command Response
01 STX STX
02 Node Node
03 0x08 0x0 StatusBit
04 CmdGetParN CmdGetParN
05 0x00 0x00
06 High part of parameter code High part of parameter code
07 Low part of parameter code Low part of parameter code
08 0x00 High part of parameter value
09 0x00 Low part of parameter value
10 CRC CRC
11 ETX ETX
Example: To read the value of the parameter that determines character blinking frequency (code
0x010f) from the terminal at node address 0, currently set to 500 (0x1f4).
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x08 0x0 0x0 (StatusBit)
04 0x70 (CmdGetParN) 0x70 (CmdGetParN)
05 0x00 0x00
06 0x01 (High part of parameter code) 0x01 (High part of parameter code)
07 0x0f (Low part of parameter code) 0x0f (Low part of parameter code)
08 0x00 0x01 (High part of parameter value)
09 0x00 0xf4 (Low part of parameter value)
10 0x89 (CRC) 0x74 (CRC)
11 0x03 (ETX) 0x03 (ETX)
05-10-2007 CNI Engineering S.r.l. 33
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
4.1.12 Restart VT100
This command restores VT100 protocol.
Byte Command Response
01 STX STX
02 Node Node
03 0x08 0x0 StatusBit
04 CmdStartVt100 CmdStartVt100
05 0x00 0x00
06 0x00 0x00
07 0x00 0x00
08 CRC CRC
09 ETX ETX
Example: To restore VT100 protocol to the terminal at node address 0.
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x08 0x0 0x00 (StatusBit)
04 0xc0 (CmdStartVt100) 0xc0 (CmdStartVt100)
05 0x00 0x00
06 0x00 0x00
07 0x00 0x00
08 0x37 (CRC) CRC (0x3f)
09 0x03 (ETX) ETX (0x03)
34 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
CNI proprietary protocol commands
4.1.13 Save parameters to flash memory
When the terminal is switched on, it loads its operating parameters from flash memory. This command
saves the terminal’s current parameters into its flash memory so that they will be loaded automatically
the next time the terminal is switched on.
Example
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x08 0x0 0x00 (StatusBit)
04 0x78 (CmdSaveParFl) 0x78 (CmdSaveParFl)
05 0x00 0x00
06 0x00 0x00
07 0x00 0x00
08 CRC CRC
09 0x03 (ETX) 0x03 (ETX)
4.1.14 Read flash memory
This command reads any chosen address in the terminal’s flash memory. The address can range from
0x0000 to 0x7fff.
Example
Byte Command Response
01 STX STX
02 Node Node
03 0x08 0x0 StatusBit
04 CmdReadFlash CmdReadFlash
05 0x00 0x00
06 High byte of address 0x00
07 Low byte of address RowsBit
08 CRC CRC
09 ETX ETX
Example: To read the contents of the address 0x1007 in the flash memory of the terminal at node
address 0, currently containing the value 0x149c.
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x08 0x0 StatusBit
04 0xa0 (CmdReadFlash) 0xa0 (CmdReadFlash)
05 0x00 0x00
06 0x10 (High byte of address) 0x14 (High byte of value read)
07 0x07 (Low byte of address) 0x9c (Low byte of value read)
08 0x40 (CRC) 0xd7 (CRC)
09 0x03 (ETX) 0x03 (ETX)
05-10-2007 CNI Engineering S.r.l. 35
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
4.1.15 Sample variable
This command commences sampling two variables in the terminal’s firmware.
See the appendices for details on the coding of these variables.
Byte Command Response
01 STX STX
02 Node Node
03 0x08 0x0 StatusBit
04 CmdSampleVar CmdSampleVar
05 0x00 0x00
06 Variable 1 code Variable 1 code
07 Variable 2 code Variable 2 code
08 CRC CRC
09 ETX ETX
Example: To sample the two variables coded 0x04 and 0x05 in the terminal at node address 0.
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x08 0x0 0x0
(StatusBit)
04 0xa8 (CmdSampleVar) 0xa8 (CmdSampleVar)
05 0x00 0x00
06 0x04 (Variable 1 code) 0x04 (Variable 1 code)
07 0x05 (Variable 2 code) 0x05 (Variable 2 code)
08 0x5e (CRC) 0x56 (CRC)
09 0x03 (ETX) 0x03 (ETX)
4.1.16 Sample address
This command commences sampling two variable addresses in the terminal’s firmware at a specified
interval.
Example
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x08 0x0 0x08
04 0xb0 (CmdSampleMem) 0xb0 (CmdSampleMem)
05 High part of variable address 1 High part of variable address 1
06 Low part of variable address 1 Low part of variable address 1
07 High part of variable address 2 High part of variable address 2
08 Low part of variable address 2 CRC
09 High part of sampling interval 0x03 (ETX)
10 Low part of sampling interval
11 CRC
12 0x03 (ETX)
36 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
CNI proprietary protocol commands
4.1.17 Read samples
This command downloads sampled values from the terminal.
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x08 0x0 StatusBit
04 0x58 (CmdGetSamp) 0x58 (CmdGetSamp)
05 0x00 0x00
06 0x00 High part of number of samples
07 0x00 Low part of number of samples
08 CRC High part of sample 1, variable 1
09 0x03 (ETX) Low part of sample 1, variable 1
10 High part of sample 1, variable 2
11 Low part of sample 1, variable 2
12 High part of sample 2, variable 1
13 Low part of sample 2, variable 1
14 High part of sample 2, variable 2
15 Low part of sample 2, variable 2
… …
8+4´N High part of sample N, variable 1
8+4´N+1 Low part of sample N, variable 1
8+4´N+2 High part of sample N, variable 2
8+4´N+3 Low part of sample N, variable 2
8+4´N+4 0xXX
8+4´N+5 0xXX
8+4´N+6 CRC
8+4´N+7 0x03 (ETX)
The maximum value of N is limited by the maximum length of the buffer (see section 2.2.3).
05-10-2007 CNI Engineering S.r.l. 37
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
A Parameters
Parameters can be changed using the CMDCHGPAR command(0x68).
Code Meaning Name Size Unit of Default Min/
measure value Max
0x0100 Reserved RESERVED1 16 bit 0 0/
parameter(Increases 32767
cursor display time in
msec)
0x0101 Reserved RESERVED2 16 bit 0 0/
parameter(Increases the 32767
display’s character read
wait time in msec)
0x0102 Reserved RESERVED3 16 bit 0 -50 /
parameter(VT100 only: 32767
increases or decreases
the default I/O refresh
rate of 50 msec)
0x0103 Reserved parameter RESERVED4 16 bit 6 0/
32767
0x0104 Reserved parameter RESERVED5 16 bit 0 -32768 /
32767
0x0105 Reserved parameter RESERVED6 16 bit 0 -32768 /
32767
0x0106 Reserved parameter RESERVED7 16 bit 0 -32768 /
32767
0x0107 Reserved parameter RESERVED8 16 bit 0 -32768 /
32767
0x0108 Reserved parameter RESERVED9 16 bit 0 -32768 /
32767
0x0109 Reserved parameter RESERVED10 16 bit 0 -32768 /
32767
0x010A Reserved parameter RESERVED11 16 bit 0 -32768 /
32767
0x010B Reserved parameter RESERVED12 16 bit 0 -32768 /
32767
0x010C Serial line: minimum TIMFB 16 bit msec 5 VT100 1 / 100
delay before terminal 50 otherwise
responds to a command
0x010D The time taken, starting TIMEOUTFB 16 bit msec 100 EnetX 1 / 1000
from the last message
received, to activate the
watchdog (and therefore
to switch off the key
LEDs and reset the
encoder count)
0x010E The half-period for TIMBLINKCUR 16 bit msec 250 1 / 2000
cursor blinking
0x010F The half-period for TIMBLINKCHAR 16 bit msec 500 1 / 2000
character blinking
0x0110 First row of scroll area INITROWSCROL 16 bit 0 0/3
L
0x0111 The number of rows in NROWSSCROLL 16 bit 0 0/4
the scroll area
38 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
CNI proprietary protocol commands
0x0112 The frequency at which FILTERBUTTON 16 bit msec 20 1 / 1000
the filter is run to check
key state.
0x0113 Display contrast: the CONTRASTON 16 bit 4 0 / 15
lower the value, the
higher the contrast.
0x0114 The low byte forms the FONT0_0 16 bit 0 0 / 7967
first row of pixels of the
first character. The high
byte forms the second
row.
0x0115 The low byte forms the FONT0_1 16 bit 0 0 / 7967
third row of pixels of the
first character. The high
byte forms the fourth
row.
0x0116 The low byte forms the FONT0_2 16 bit 0 0 / 7967
fifth row of pixels of the
first character. The high
byte forms the sixth row.
0x0117 The low byte forms the FONT0_3 16 bit 0 0 / 7967
seventh row of pixels of
the first character. The
high byte forms the
eighth row.
0x0118 The low byte forms the FONT1_0 16 bit 0 0 / 7967
first row of pixels of the
second character. The
high byte forms the
second row.
0x0119 The low byte forms the FONT1_1 16 bit 0 0 / 7967
third row of pixels of the
second character. The
high byte forms the
fourth row.
0x011A The low byte forms the FONT1_2 16 bit 0 0 / 7967
fifth row of pixels of the
second character. The
high byte forms the sixth
row.
0x011B The low byte forms the FONT1_3 16 bit 0 0 / 7967
seventh row of pixels of
the second character.
The high byte forms the
eighth row.
0x011C The low byte forms the FONT2_0 16 bit 0 0 / 7967
first row of pixels of the
third character. The high
byte forms the second
row.
0x011D The low byte forms the FONT2_1 16 bit 0 0 / 7967
third row of pixels of the
third character. The high
byte forms the fourth
row.
0x011E The low byte forms the FONT2_2 16 bit 0 0 / 7967
fifth row of pixels of the
third character. The high
byte forms the sixth row.
05-10-2007 CNI Engineering S.r.l. 39
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
0x011F The low byte forms the FONT2_3 16 bit 0 0 / 7967
seventh row of pixels of
the third character. The
high byte forms the
eighth row.
0x0120 The low byte forms the FONT3_0 16 bit 0 0 / 7967
first row of pixels of the
fourth character. The
high byte forms the
second row.
0x0121 The low byte forms the FONT3_1 16 bit 0 0 / 7967
third row of pixels of the
fourth character. The
high byte forms the
fourth row.
0x0122 The low byte forms the FONT3_2 16 bit 0 0 / 7967
fifth row of pixels of the
fourth character. The
high byte forms the sixth
row.
0x0123 The low byte forms the FONT3_3 16 bit 0 0 / 7967
seventh row of pixels of
the fourth character. The
high byte forms the
eighth row.
0x0124 The low byte forms the FONT4_0 16 bit 0 0 / 7967
first row of pixels of the
fifth character. The high
byte forms the second
row.
0x0125 The low byte forms the FONT4_1 16 bit 0 0 / 7967
third row of pixels of the
fifth character. The high
byte forms the fourth
row.
0x0126 The low byte forms the FONT4_2 16 bit 0 0 / 7967
fifth row of pixels of the
fifth character. The high
byte forms the sixth row.
0x0127 The low byte forms the FONT4_3 16 bit 0 0 / 7967
seventh row of pixels of
the fifth character. The
high byte forms the
eighth row.
0x0128 The low byte forms the FONT5_0 16 bit 0 0 / 7967
first row of pixels of the
sixth character. The high
byte forms the second
row.
0x0129 The low byte forms the FONT5_1 16 bit 0 0 / 7967
third row of pixels of the
sixth character. The high
byte forms the fourth
row.
0x012A The low byte forms the FONT5_2 16 bit 0 0 / 7967
fifth row of pixels of the
sixth character. The high
byte forms the sixth row.
40 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
CNI proprietary protocol commands
0x012B The low byte forms the FONT5_3 16 bit 0 0 / 7967
seventh row of pixels of
the sixth character. The
high byte forms the
eighth row.
0x012C The low byte forms the FONT6_0 16 bit 0 0 / 7967
first row of pixels of the
seventh character. The
high byte forms the
second row.
0x012D The low byte forms the FONT6_1 16 bit 0 0 / 7967
third row of pixels of the
seventh character. The
high byte forms the
fourth row.
0x012E The low byte forms the FONT6_2 16 bit 0 0 / 7967
fifth row of pixels of the
seventh character. The
high byte forms the sixth
row.
0x012F The low byte forms the FONT6_3 16 bit 0 0 / 7967
seventh row of pixels of
the seventh character.
The high byte forms the
eighth row.
0x0130 The low byte forms the FONT7_0 16 bit 0 0 / 7967
first row of pixels of the
eighth character. The
high byte forms the
second row.
0x0131 The low byte forms the FONT7_1 16 bit 0 0 / 7967
third row of pixels of the
eighth character. The
high byte forms the
fourth row.
0x0132 The low byte forms the FONT7_2 16 bit 0 0 / 7967
fifth row of pixels of the
eighth character. The
high byte forms the sixth
row.
0x0133 The low byte forms the FONT7_3 16 bit 0 0 / 7967
seventh row of pixels of
the eighth character. The
high byte forms the
eighth row.
05-10-2007 CNI Engineering S.r.l. 41
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
B Error messages
Error messages can be ‘captured’ using the ‘Read message’ (CmdGetAlarm) command (see section
4.1.6).
The following table describes the meanings of the various error messages.
Code Name Meaning Action required
The terminal is
functioning correctly.
0x0000 NOALARM None
No error messages are
present.
Check the cabling.
If the TIMEOUTFB parameter
Error in communication (0x010D) is set to a value other
0x0008 ALCOMERROR between the terminal than 0, increase this value.
and the master(1). Make sure that the master was not
switched off while the terminal was
on.
Re-send the parameters to the
The parameters saved terminal. If you wish, save them in
0x000A ALNOPARAMINFL in flash memory are flash memory (to avoid the same
incorrect. message appearing the next time
you switch the terminal on).
The application saved
0x000B ALNOPRGINFLASH in flash memory is Download the application.
incorrect.
A flash memory delete
error occurred while the
0x000C ALERASINGFL Download the application again.
application was being
downloaded.
A flash memory write
error occurred while the
0x000D ALPRGMINGFL Download the application again.
application was being
downloaded.
0x0021 ALWRONGIRQ Terminal software error. Contact the supplier.
A non-existent
0x4001 ALPARNONCORR parameter was sent or Check the software in the master.
read.
A non-existent
command or one with
0x4003 ALWRONGCMD Check the software in the master.
an incorrect length was
sent.
A request was made to
write to an area of flash
0x4007 ALFLNOTERASED Contact the supplier.
memory that has not
been deleted.
(1) Serial communications error with CNI proprietary protocol. May be caused by:
Timeout: the master has not sent any more data
A packet of characters received was too long (or the ETX character was missing)
Two STX characters were received without an intervening ETX character
CRC error
An ESC character was received followed by the wrong character (ETX, STX or ESC).
42 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
CNI proprietary protocol commands
C Status bits
Packets sent in response to commands always contain 4 StatusBits. The following table defines
the meanings of these bits.
Bit Name Meaning
3 Not used
2 MASKBITWARNING If the value is 1, a message is waiting for the master.
1 Not used
0 MASKBITNODIN If the value is 1, the terminal is responding to the
default command with the status of its overrides and
control knob. If the value is 0, the terminal is
responding with the status of its keys.
D Invalid command response
Whenever the terminal cannot implement a command, it sends the following response.
Byte Response
01 STX
02 Node
03 0x0 StatusBit
04 CmdNACK
05 Byte 05 of sent command
06 Byte 06 of sent command
07 Byte 07 of sent command
08 CRC
09 ETX
Example: The master sends a read command to the terminal at node address 0, but the command
packet contains an error, e.g. it is too long. The terminal responds with CmdNACK.
Byte Command Response
01 0x02 (STX) 0x02 (STX)
02 0x00 (Node) 0x00 (Node)
03 0x08 0x0 0x04 (StatusBit)
04 0xb8 (CmdGetType) 0x60 (CmdNACK)
05 0x00 0x00 (Byte 05 of sent command)
06 0x00 0x00 (Byte 06 of sent command)
07 0x00 0x00 (Byte 07 of sent command)
08 0x00 0x9b (CRC)
09 0x00 0x03 (ETX)
10 0x00
11 0x00
12 0xbf (CRC)
13 0x03 (ETX)
05-10-2007 CNI Engineering S.r.l. 43
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
E I/O
E.1 The RM851 hand-held terminal
E.1.1 Numbering of keys
The terminal is equipped with a maximum of 32 keys. The keys are numbered starting from the bottom
up and from left to right as shown in Figure 1.
Figure 1: Numbering of keys on the
RM851 hand-held terminal
10
11 19
3
18
2
17
1
9
E.1.2 Numbering of LEDs
The terminal is equipped with a maximum of 12 LEDs. These are numbered in the same way as the
keys.
Figure 2: Numbering of LEDs on the
RM851 hand-held terminal
19
3
1
17
E.1.3 The knob
The terminal is equipped with only one knob, which turns clockwise to increase its value.
44 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
CNI proprietary protocol commands
E.2 The RM850 hand held terminal
E.2.1 Numbering of keys
The terminal is equipped with a maximum of 32 keys. The keys are numbered starting from the bottom
up and from left to right as shown in Figure 3.
Figure 3: Numbering of keys on the
RM850 hand-held terminal
12
20
4
11
19
3
10
18
2
17
1
9
E.2.2 Numbering of LEDs
The terminal is equipped with a maximum of 12 LEDs. These are numbered in the same way as the
keys.
Figure 4: Numbering of LEDs and overrides on the
RM850 hand-held terminal
Override 1
8
Override 2
4 12
1 9
E.2.3 Numbering of overrides
The terminal is equipped with 2 overrides. These are numbered as shown in Figure 4, and turn
clockwise to increase setting.
05-10-2007 CNI Engineering S.r.l. 45
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
F Calculating the 16 bit CRC
VT100 protocol uses a 16 bit CRC in some commands. The source code for these functions is
reproduced below.
F.1 MODULE CRC16.H
/****************************************************************************
Filename: crc16.h
Description: Cyclic Redundancy Check 16 functions
Created: 24-Feb-1999
Copyright (c) 2002-2003, Indigo Systems Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
Neither the name of the Indigo Systems Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
****************************************************************************/
#ifndef __CRC16_H__
#define __CRC16_H__
#ifdef __cplusplus
extern "C"
{
#endif
typedef unsigned short CRC16;
#ifdef _OPT_SIZE
46 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
CNI proprietary protocol commands
int ByteCRC16(int value, int crcin);
#else
CRC16 CalcCRC16Words(unsigned int count, short *buffer);
#endif
#ifdef _CRC16_BYTES
CRC16 CalcCRC16Bytes(unsigned int count, char *buffer);
#endif
#ifdef __cplusplus
}
#endif
#endif /* __CRC16_H__ */
F.2 MODULE CRC16.C
/****************************************************************************
Filename: crc16.c
Description: Cyclic Redundancy Check 16 functions
Created: 24-Feb-1999
Copyright (c) 1999-2003, Indigo Systems Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
Neither the name of the Indigo Systems Corporation nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
****************************************************************************/
#include "crc16.h"
05-10-2007 CNI Engineering S.r.l. 47
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
#ifdef _OPT_SIZE
/*
* ===== ByteCRC16 =====
* Calculate (update) the CRC16 for a single 8-bit byte
*/
int ByteCRC16(int value, int crcin)
{
int k = (((crcin >> 8) ^ value) & 255) << 8;
int crc = 0;
int bits = 8;
do
{
if (( crc ^ k ) & 0x8000)
crc = (crc << 1) ^ 0x1021;
else
crc <<= 1;
k <<= 1;
}
while (--bits);
return ((crcin << 8) ^ crc);
}
#else
const CRC16 ccitt_16Table[] = {
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
48 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine
CNI proprietary protocol commands
0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
};
#define ByteCRC16(v, crc) \
(unsigned short)((crc << 8) ^ ccitt_16Table[((crc >> 8) ^ (v)) & 255])
/*
* ===== CalcCRC16Words =====
* Calculate the CRC for a buffer of 16-bit words. Supports both
* Little and Big Endian formats using conditional compilation.
* Note: minimum count is 1 (0 case not handled)
*/
CRC16 CalcCRC16Words(unsigned int count, short *buffer) {
int crc = 0;
do {
int value = *buffer++;
#ifdef _BIG_ENDIAN
crc = ByteCRC16(value >> 8, crc);
crc = ByteCRC16(value, crc);
#else
crc = ByteCRC16(value, crc);
crc = ByteCRC16(value >> 8, crc);
#endif
}
while (--count);
return (CRC16) crc;
}
#endif /* _OPT_SIZE */
#ifdef _CRC16_BYTES
/*
* ===== CalcCRC16Bytes =====
* Calculate the CRC for a buffer of 8-bit words.
* Note: minimum count is 1 (0 case not handled)
05-10-2007 CNI Engineering S.r.l. 49
Downloaded from www.Manualslib.com manuals search engine
RM85x Hand-held Terminals User Manual
*/
CRC16 CalcCRC16Bytes(unsigned int count, char *buffer) {
int crc = 0;
do {
int value = *buffer++;
crc = ByteCRC16(value, crc);
}
while (--count);
return crc;
}
#endif /* _CRC16_BYTES */
50 CNI Engineering S.r.l. 05-10-2007
Downloaded from www.Manualslib.com manuals search engine