ST-IGG-0207:2015
GazModem3 - short version, including reading of archival data
The GAZ-MODEM3 (GM3) protocol has been provided for communication between any
control and measuring device and a data collecting system. Data exchange is carried out in
accordance with the question-answer principle. The measuring device can only send a
response if it has received a correctly addressed command beforehand.
Table 1 - GM3 protocol frame format
68h Bajt startowy Start byte
L0 Długość ramki L=DA+SA+F+P
L1 Frame length L = DA + SA + F + P
DA0 Adres adresata (odbiorcy)
DA1 Addressee (recipient) address
SA0 Adres nadawcy
SA1 The sender's address
F Rodzaj komunikatu (jeden bajt) Message type (one byte)
…
…
Przesyłana informacja (dowolny ciąg bajtów o długości L minus 5)
P Transmitted information (any sequence of bytes with a length of L
minus 5)
…
…
CRC1 Znaki kontrolne CRC-CCITT obejmujące L, DA, SA, F, DANE,
wygenerowane w oparciu o wielomian x16+x12+x5+1 control characters
CRC0
including L, DA, SA, F, DATA, generated based on x16 + x12 + x5 + 1
polynomial
16h Bajt stopu Stop byte
At the data link level, it is assumed that there is no gap between individual bytes. This means
that after sending the last stop bit of byte I, the start bit of byte I + 1 appears. The device must
send the first byte of the frame within no more than 1500 ms from detecting the end of the
frame, unless the manufacturer stated otherwise in the documentation.
In the event that the device detects an error in the frame format or a mismatch between the
recipient's addresses
with its own, the frame is not forwarded to the upper layers and as a result no response will
be generated.
The GM3 protocol allows two modes of device addressing:
- direct addressing (unicast),
- broadcast mode.
In the case of direct addressing, the DA field of the frame contains the address of the device
to which the frame is addressed. In broadcast mode, the DA field should contain the FFFFh
address.
In response, the GAZ-MODEM3 address should be in the SA field. This allows sending
2 ST-IGG-0207:2015
and executing the command (e.g. setting the time) on all devices that are able to receive the
frame, or detecting the GM address of the device.
The GM3 protocol does not provide for special session layer mechanisms. It is assumed that
the data downloading device is the transmission initiator.
7.1 Data formats
Each of the parameters sent from or to the measuring device is a derivative of one of the
types shown in Table 2.
Table 2 - GM 3 data types
Typ Type Liczba Zakres Range Ilość cyfr Kod
bajtów znaczącyc Code
Numbe h Number
r of of
bytes significant
digits
Nie - - - 0
zdefiniowany
SHORT INT 1 -128 .. +127 3 1
INT 2 -32768 .. +32767 5 2
LONG INT 4 -2147483648 .. +2147483647 10 3
BYTE 1 0 .. 255 3 4
WORD 2 0 .. 65535 5 5
DWORD 4 0 .. 4294967295 10 6
SHORT REAL 4 3,4E-38 .. 3,4E+38 7-8 7
Typ Type Liczba Zakres Range Ilość cyfr Kod
bajtów znaczącyc Code
Numbe h Number
r of of
bytes significant
digits
Niezdefiniowan - - 8
y
LONG REAL 8 1,7E-308 .. 1,7E+308 15-16 9
BOOLEAN 1 0,1 1 10
BCD dowoln Bez ograniczeń Unlimited 11
a any
STRING dowoln 12
a any
INT 64 8 - 19 13
9223372036854775808..+9223372036854775
807
UINT 64 8 0 .. 18446744073709551615 20 14
ST-IGG-0207:2015 3
7.1.1 SHORT INT
An integer with a sign in the range -128 .. +127 encoded on one byte, e.g.
0 00000000
5 00000101
-5 11111011
127 01111111
-128 10000000
7.1.2 INT
An integer with a sign in the range -32768 .. 32767 coded on 2 bytes, e.g .:
0 00000000
00000000
5 00000101
00000000
-5 11111011
11111111
32767 11111111
01111111
-32768 00000000
10000000
7.1.3 LONG INT
An integer with a sign in the range -2147483648 .. +2147483647 coded on 4 bytes, e.g .:
0 00000000
00000000
00000000
00000000
-5 11111011
11111111
11111111
11111111
7.1.4 INT 64
An integer with a sign in the range -9223372036854775808 .. + 9223372036854775807
coded on 8 bytes, e.g .:
0 00000000
00000000
00000000
00000000
4 ST-IGG-0207:2015
00000000
00000000
00000000
00000000
-5 11111011
11111111
11111111
11111111
11111111
11111111
11111111
11111111
7.1.5 UINT 64
An unsigned integer from the range of 0 .. 18446744073709551615 coded on 8 bytes, e.g
.:
0 00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
5 00000101
00000000
00000000
00000000
00000000
00000000
00000000
00000000
7.1.6 BYTE
An unsigned integer in the range 0 .. 255 coded on one byte, e.g .:
0 00000000
5 00000101
255 11111111
7.1.7 WORD
An unsigned integer in the range 0 .. 65535 encoded in 2 bytes, e.g .:
0 00000000
ST-IGG-0207:2015 5
00000000
65535 11111111
11111111
7.1.8 DWORD
An unsigned integer from the range of 0 .. 4294967295 encoded on 4 bytes, e.g .:
0 00000000
00000000
00000000
00000000
5 00000101
00000000
00000000
00000000
4294967295 11111111
11111111
11111111
11111111
7.1.9 SHORT REAL
The number consists of a sign, mantissas and features
The sign of the number is remembered as a single bit S:
S = 0 positive number,
S = 1 negative number.
Mantissa is a binary number written on 23 bits. One before the dot and the binary dot are not
present in the representation of the mantissa (they are default), only bits from 2-1 to 2-23 are
remembered.
The trait (exponent of number 2) is a binary number 8 bits long written with an offset of 127
(7Fh).
Table 3 shows how to code the SHORT REAL number
Table 3 - Content of bytes making up the SHORT REAL number
Bajt/bit 7 6 5 4 3 2 1 0
Byte /
bit
0 m-16 m-17 m-18 m-19 m-20 m-21 m-22 m-23
1 m-8 m-9 m-10 m-11 m-12 m-13 m-14 m-15
2 e0 m-1 m-2 m-3 m-4 m-5 m-6 m-7
3 S e7 e6 e5 e4 e3 e2 e1
The SHORT REAL representation is in accordance with the IEEE754 standard.
6 ST-IGG-0207:2015
7.1.10 LONG REAL
The number consists of a sign, mantissas and features.
The sign of the number is remembered as a single bit S:
S = 0 positive number
S = 1 negative number
Mantissa is a binary number written in 52 bits. The one before the dot and the binary dot are
not present in the representation of the mantissa (they are default), only bits from 2-1 to 2-52
are remembered.
The trait (exponent of number 2) is a binary number with a length of 11 bits and written with
an offset of 1023 (03FFh).
Table 4 shows how to code the LONG REAL number
Table 4 - Content of bytes making up the LONG REAL number
Bajt/bit 7 6 5 4 3 2 1 0
Byte /
bit
0 m-45 m-46 m-47 m-48 m-49 m-50 m-51 m-52
1 m-37 m-38 m-39 m-40 m-41 m-42 m-43 m-44
2 m-29 m-30 m-31 m-32 m-33 m-34 m-35 m-36
3 m-21 m-22 m-23 m-24 m-25 m-26 m-27 m-28
4 m-13 m-14 m-15 m-16 m-17 m-18 m-19 m-20
5 m-5 m-6 m-7 m-8 m-9 m-10 m-11 m-12
6 e3 e2 e1 e0 m-1 m-2 m-3 m-4
7 S e10 e9 e8 e7 e6 e5 e4
The representation of the LONG REAL number is in accordance with the IEEE754 standard.
7.1.11 BOOLEAN
It is an integer in the range of 0 .. 1 coded per 1 byte, e.g.
0 00000000
1 00000001
7.1.13 STRING
It is a string in ASCIIZ format (i.e. terminated with a character with the code 0), e.g .:
ABC 01000001
01000010
01000011
00000000
The empty string is represented as a single byte with a value of 0.
ST-IGG-0207:2015 7
It is recommended to use the Windows-1250 code page. If the code page used is different,
the manufacturer should specify this in the technical documentation of the device.
7.2 Derivative types
<NRDP> :: = WORD
<NrKWDB> :: = WORD
<NrZD> :: = WORD
<IndeksR> :: = DWORD
<IndeksZ> :: = DWORD
<IndeksC> :: = DWORD
<IndeksD> :: = DWORD
<IndeksZM> :: = DWORD
<number of elements> :: = BYTE
<precise time> :: = <milliseconds> <seconds> <minute> <time> <day> <month> <year>
<Time> :: = <seconds> <minute> <time> <day> <month> <year>
<time of periodic registration> :: = <minute> <time> <day> <month> <year>
<time of daily registration> :: = <time> <day> <month> <year>
<Milliseconds> :: = WORD
<Seconds> :: = BYTE
<Minute> :: = BYTE
<Time> :: = BYTE
<Day> :: = BYTE
<Month> :: = BYTE
<year> :: = BYTE - only 100, e.g. 1996 -> 96 (value <80 means year 20XX)
<parameter value> :: = BOOLEAN | BYTE | SHORT INT | INT | WORD | LONG INT |
DWORD | SHORT REAL | LONG REAL | BCD | STRING | INT64 | UINT64
<absolute value> :: = <parameter value> - always positive or 0
<status> :: = BYTE where
b0 = 1 parameter derived from measurements
b1 = 1 parameter derived from measurements, range exceeded - process alarm
b2 = 1 parameter derived from measurements, range exceeded - system alarm
b3 = 1 (value obtained from calculations)
b4 = 1 constant value (algorithm constant)
b5 = 1 clock correction
b6 not defined
b7 = 1 discontinuity of registration
<STRING ASCII> :: = STRING - string in ASCIIZ format (i.e. terminated with a character with
the code 0) consisting only of printable characters with codes from 32 to 127
<STRING []> - array of type STRING
8 ST-IGG-0207:2015
<brak> - empty field (size 0) - does not contain any data
7.3.1 Data recorded periodically (recording with a fixed time interval)
It is assumed that registration is made every full hour. Registration can be carried out once
an hour or total times per hour. Sample registration periods are given
in Table 5.
Table 5 - Example registration periods
Okres rejestracji Liczba rejestracji na godzinę
Number of registrations per
Registration period
hour
60 min 1
12 min 5
4 min 15
1 min 60
7.3.2 Daily registration
The device can record a set range of data with a 24-hour interval. The recording time can be
modified using the parameter in the DP table (example Table 11).
7.4. Auxiliary structures in the measuring device
The GM3 protocol requires the existence of an array in the measuring device that defines the
method of data exchange in the GM3 protocol. It is:
1. Table of available parameters (DP) of RDP size
7.4.1 Table of available parameters (DP)
The DP table contains information about the parameters that can be obtained from the
measuring device. Each element of the DP array is a structure with the following form:
<parameter description> :: = <designation> <unit> <exponentE> <additional info>
<marking> :: = <STRING ASCII>
e.g. "P"
<unit> :: = <STRING ASCII>
e.g. "Pa"
<exponentE :: :: = SHORT INT
e.g. 3, -3
<Inf.dodatkowe> :: = BYTE,
ST-IGG-0207:2015 9
Where b3-b0 value coding (code from table 2 specifying type)
b4 = 1 parameter can be read
b5 = 1 parameter modification option
b6 = 1 parameter registered periodically
b7 = 1 parameter recorded daily
The recorded data and the DP table are sent in the form of blocks, the size of which is
determined by the device receiving data using the N parameter. Thanks to this, the
maximum size of the message sent by the measuring device can be easily determined from
the data receiving device. The device collecting the data should expect an answer with the
number of parameters equal or less than in the given question. This makes it possible to
adjust the method of information transfer to the quality of the link between the measuring
device and the data downloading device. Due to the method used to protect data against
damage (CRC), it is recommended that the maximum size of the message sent as a
response is not more than 1024 bytes.
The GM3 protocol assumes the following reactions when sending erroneous information to
the measuring device:
1. An attempt to read non-existent data (e.g. exceeding the size of the selected table)
should generate the following answer:
F: = 7Fh
P: = <none>
2. Sending a supported command with incorrect parameters (e.g. day of the month 32)
should generate the following answer:
F: = 7Eh
P: = <none>
Table 6 shows the allowable values of parameter F.
Table 6 - Meaning of byte F - type of message
Polecenie (F) Odpowiedź rodzaj komunikatu message type
Command (F) Answer
01h* 81h odczyt tablicy dostępnych parametrów (DP)
readout of available parameters table (DP)
7Fh
20h A0h Odczyt opisów szczegółowych parametrów
tablicy DP. Reading the descriptions of the
detailed parameters of the DP table.
09h1** 89h odczyt parametrów identyfikujących urządzenia
reading parameters identifying devices
27h1* A7h odczyt stanu struktur urządzenia reading the
status of device structures
41h C1h wyszukanie danych rejestrowanych okresowo
searching for data registered periodically
7Fh
21h A1h wyszukanie danych dobowych searching for
10 ST-IGG-0207:2015
daily data
28h A8h odczyt zestawu próbek wybranych parametrów
rejestrowanych okresowo o tym samym
indeksie reading a set of samples of selected
parameters registered periodically with the
same index
22h A2h odczyt kolejnych próbek danej rejestrowanej
dobowo reading of subsequent samples of the
data recorded daily
48h C8h odczyt zegara clock reading
7Fh** próba odczytu danych nieistniejących lub próba
odczytu danych z nieistniejącego zakresu np.
indeks w DP spoza zakresu, błędnie podana
wartość czasu (godz. 25:88) attempt to read
non-existent data or attempt to read data from
a non-existent range, e.g. index in DP out of
range, incorrect time value (25:88)
7Eh** odpowiedź na nieobsługiwane polecenie lub
znane polecenie z błędną długością bloku
danych response to unsupported command or
known command with incorrect data block
length
68h-6Fh E8h-Efh polecenia diagnostyczne diagnostic commands
* - obligatory frames in the device, other frames are used depending on the needs of the
device.
Frame No. 27h is a determinant of implementation of the Gaz-Modem 3 (GM3) protocol.
** - Frames for GM2 compatibility.
1 - Commands that can be sent in broadcast mode
A sample is called a record of a parameter or parameters with a time stamp assigned to it
and index
7.5.2 Reading the parameters identifying the device
Recommendation
F: 09h =
Q: = <none>
Reply:
F: 89h =
P: = <producer> <device type> <serial number> <DP table version> <ZD table version>
<other information>
ST-IGG-0207:2015 11
<Manufacturer> :: = STRING
<device type> :: = STRING
<serial number> :: = STRING
<version of the DP table> :: = STRING
<version of the ZD table> :: = STRING
<other information> :: = STRING []
The parameter <DP table version> is a counter incremented by 1 for each modification of the
DP table.
The parameter <ZD table version> is a counter incremented by 1 for each modification of the
ZD table. This allows you to easily detect changes in DP and ZD tables.
7.5.3 Reading the status of the device structures
Recommendation
F: 27h =
Reply:
F: = A7h
P: = <producer> <device type> <serial number> <DP table version> <ZD table version>
<GM protocol version> <other information> <current_version of the KWDB table>
<current_indexR> <current_indexD> <current_indexC> <current_indexZ>
<current_indexZM>
<Manufacturer> :: = STRING
<device type> :: = STRING
<serial number> :: = STRING
<version of DP table> :: = STRING
<version of the ZD table> :: = STRING
<GM protocol version> :: = STRING - record in the form "3.0"
<other information> :: = STRING []
<current_version of the KWDB table> :: = DWORD
<Aktualny_indeksR> :: = <indeksR>
12 ST-IGG-0207:2015
<Aktualny_indeksD> :: = <indeksD>
<Aktualny_indeksC> :: = <indeksC>
<Aktualny_indeksZ> :: = <indeksZ>
<Aktualny_indeksZM> :: = <indeksZM>
The parameter <current_version of the KWDB table> is the internal counter of the device
incremented
o 1 for each modification of the KWDB table on a given port. This allows you to easily detect
changes in the KWDB table.
The <current_indexR> parameter is the internal device counter incremented by 1 at each
periodic registration
The <current_indexD> parameter is the internal device counter incremented by 1 at each
daily registration
The parameter <current_indexC> is the internal device counter incremented by 1 at each
momentary registration
The <current_indexZ> parameter is the device's internal counter incremented by 1 at each
event registration
The parameter <current_indexZM> is the internal device counter incremented by 1 for each
event registration or event opening / closing operation
7.5.4 Reading the DP table
Recommendation
F: 01h =
P: = <N> <I>
Possible answers
1. Reading data
F: 81h =
P: = <N> <I> <description of parameter I> ... <description of parameter I + (N-1)>
2. Lack of data or attempt to read non-existent data
F: = 7Fh
Q: = <none>
<N> :: = <number of elements>
ST-IGG-0207:2015 13
<I> :: = <nrDP> - index of the first desired element in the DP table
<description of the parameter I> :: = <description of the parameter>
7.5.5 Reading detailed descriptions of DP table parameters
The command is used to send descriptions of the parameters functionality and, in the case of
modifiable parameters, their allowable range of variability.
Recommendation
F: 20h =
P: = <N> <I>
Reply
F: = A0h
1. Reading data
P: = <N> <I> <detailed description of the parameter I> ... <detailed description of the
parameter I + (N-1)>
2. Lack of data or attempt to read non-existent data
P: = <error code>
<N>: = <number of elements>
<I> :: = <nrDP> - index of the first desired element in the DP table
<detailed description of the parameter I> :: = STRING
<error code> :: = BYTE - error code of the command execution:
7Fh - no data or attempt to read non-existent data
7.5.10 Reading periodically recorded data
7.5.10.1 Searching for data recorded periodically
In the event that the device does not have data from the requested time, the first sample
should be returned
with a time longer than requested, in addition, the sample index should be the lowest (if there
is more than one sample at the found time in memory).
Recommendation
F: 41h =
14 ST-IGG-0207:2015
P: = <time of sample sought>
Possible answers
1. Data found - the time and index of the sample with a time label equal or newer than the
time specified in the command
F: = C1h
P: = <time of sample found> <sample index>
2. There is no recorded data with a time label equal or newer than the time specified in the
command
F: = 7Fh
Q: = <none>
<time of searched sample> :: = <time of periodic registration>
<time of sample found> :: = <periodic registration time>
<sample index> :: = <indexR> - index of the sample found
7.5.10.3 Reading sets of samples of selected parameters registered periodically with
the same index <indexR>
Reading sets of samples registered at the same time of subsequent parameters
according to the table DP.
Command - sending N n-element records registered periodically, starting from the 1st
element from the DP table. The number n denotes the number of consecutive parameters
registered periodically (parameters do not have to be directly adjacent to each other in the
DP table).
F: 28h =
P: = <N> <n> <I> <index of the desired sample>
Reply
F: = A8h
1. Data read out
P: = <N> <n> <I> <registration period> <sample time> <desired sample index> (<status 00>
<value 00> ... <status n-10> <value n-10>) ... ( <status 0N-1> <value 0N-1> ... <status n-1N-
1> <value n 1N-1>)
2. Lack of data or attempt to read non-existent data
P: = <error code>
ST-IGG-0207:2015 15
<N> :: = <number of elements> - number of requested records
<n> :: = BYTE - number of parameters in the record starting from <I>
<I> :: = <nrDP> -index in the DP table of the first requested parameter in the record
<registration period> :: = BYTE
<sample time> :: = <periodic registration time>
<index of the desired sample> :: = <indexR>
<status 0>, ..., <status n> :: = <status>
<value 0>, ..., <value n> :: = <parameter value>
<error code> :: = BYTE - error code of the command execution:
7Fh - no data or attempt to read non-existent data
NOTE 2 - Only the first sample in the block can have the discontinuity status set (b7 = 1)
7.5.11 Searching for daily data
Recommendation
F: 21h =
P: = <time of sample sought>
Reply
F: = A1h
1. Data found - the time and index of the sample with a time label equal or newer than
the time specified in the command
P: = <time of sample found> <sample index>
2. There is no recorded data with a time label equal or newer than the time specified in
the command
P: = <error code>
<time of searched sample> :: = <time of daily registration>
<time of sample found> :: = <time of daily registration>
<sample index> :: = <indexD> - index of the sample found
<error code> :: = BYTE - error code of the command execution:
7Fh - no data or attempt to read non-existent data
16 ST-IGG-0207:2015
7.5.11.1 Reading daily data
The reading of N samples of selected parameters recorded daily can be performed after the
search command has been successfully completed. Parameters, which subsequent samples
will be sent, are determined by indicating the position of the DP table and the number n of
successive read quantities. The number n denotes the number of consecutive parameters
recorded daily (parameters do not have to be directly adjacent in the DP table).
Command - sending N samples of parameter I
F: 22h =
P: = <N> <n> <I> <index of the desired sample>
Reply
F: = A2H
1. Reading data
P: = <N> <n> <I> <index of the desired sample> (<sample date0> <status 00> <value 00> ...
<status 0n-1> <value 0n-1>) ... (<date of sample N -1> <status 0N-1> <value 0N-1>…
<status n-1N-1> <value n-1N-1>)
2. No data available
P: = <error code>
<N> :: = <number of elements> - number of requested records
<n> :: = BYTE - number of parameters in the record starting from <I>
<index of the desired sample> :: = <indexD>
<I> :: = <nrDP> -index in the DP table of the first requested parameter in the record
<sample date> :: = <daily registration time>
<status 0>, ..., <status n> :: = <status>
<value 0>, ..., <value n> :: = <parameter value>
<error code> :: = BYTE - error code of the command execution:
7Fh - no data or attempt to read non-existent data
7.5.18 Reading the clock
The protocol makes it possible to read the clock of the measuring device with an accuracy of
1 s. Time obtained
in response is the moment when the response transmission begins.
Recommendation
F: 48h =
P: = <none>
ST-IGG-0207:2015 17
Reply
F: = C8h
P: = <time>