Before using this driver in the PROMOTIC application it is highly recommended to read the chapter:
protocol can serve as a cheap connection of two PROMOTIC applications via the computer's serial port. Some HW producers implemented this protocol into their devices and in this case it is possible to communicate with these devices very easily and cheaply (see for example
- for communication via the computer's serial port between PCs where PROMOTIC application are ran. This method is not quite common because the connection of separate computers by the LAN network is simpler and more common.
Description of the NET0 protocol
Message format of the NET0 protocol:
STX: (=02H) code of the message start
DST: number of destination computer
SRC: number of source computer
: message properties in the form of bitmask values:
08H: network communication used
20H: response to request for sending data
40H: request for sending data
80H: message requiring acknowledgement (ACK)
NCO: connection number (to distinguish separate message types)
data: transmitted data themselves
ETX: (=03H) code of the message end
SUM: checksum, i.e. mathematical xor of bytes from DST (including) to the last "data" byte (inclusive). Xor is made over values that are not encoded by DLE char (see Note 1)
values can be of any values except:
STX = 02H: code of the message start
ETX = 03H: code of the message end
ACK = 06H: positive acknowledgement
DLE = 10H: change prefix
NAK = 15H: negative acknowledgement
If the transmitted data contains one of the above mentioned characters then this character is encoded into two characters in the protocol:
(DLE) and (X+80H)
It means that the protocol has a variable length of the message depending on message values!
We want to transfer 1 byte of the value 02H
in the data. Instead of that we send 2 bytes: DLE
and then 82H
. By this encoding using the DLE
character we can achieve that STX
occur only on those positions of the message where its real function is.
In general it goes about the network protocol, it means that there is the number of the computer that receives the message (DST
=destination) and the computer that sends the message (SRC
=source), in the message. DST
fields can hold values from 1 to 253. If the DST
fields have the value of 0, then it goes about the non-network protocol that differs from the network one the rather that the DST
bytes are not included into the protocol at all. If the DST
field has the value 254
, then it goes about the "broadcast"
message, it means that is sent to all computers in the network.
The format of the "data"
field equals to the format of the data types on the computer. It means that for example Integer
is transferred on 2 bytes (at first LOW
and then HIGH
is transferred on 1 byte (value 0 and 1). Values in the "data"
field are in such order, in which the message variables were specified in the PROMOTIC system.
After the data receipt the receiving station has to do the following:
- if the message was received wrong (e.g. bad checksum or bad content of data) and the acknowledgement is required (bit 80H is set in CMD), then send one NAK character (=15H) as the negative acknowledgement.
- if the message was received all right and:
- a) it is the "response to sending data" (bit 20H is set in CMD), then don't response
- b) it isn't the "request for sending data" (bit 40H isn't set in CMD) and the acknowledgement is required (bit 80H is set in CMD), then send one ACK character (=06H).
- c) it is the "request for sending data" (bit 40H is set in CMD), then send the response in the same (described above) format.
In other situations there is no answer to the receipt.
We send two values: integer with value 258
) and byte with value 3
). The message has to be acknowledged, the connection number NCO
= 0 and it goes about the non-network protocol (i.e. DST
chars are missing).
The receiving station receives bytes in the following order:
02H: STX character = message start
80H: CMD character = message requiring acknowledgement
00H: NCO connection number
10H: DLE character = low byte of the 1st value is the same as STX
82H: low byte of the 1st value + 80H
01H: high byte of the 1st value
10H: DLE character = 2nd value is the same as ETX
83H: 2nd value + 80H
03H: ETX character = message end
80H: SUM = checksum (80H = 80H xor 00H xor 02H xor 01H xor 03H)