Доброго дня. Подскажите, опросом какого регистра по Модбас через WB-MIO можно будет получить маску входов этого модуля?
Или передаются только состояния каждого входа?
Можно одной командой прочитать все coil для входа:
modbus_client --debug -mrtu -pnone -s2 /dev/ttyMOD1 -a98 -t0x01 -r1000 -c16
В “ответе” в обдом байте будут значения 8 coil’ов.
Function 01 (01hex) Read Coils
Reads the ON/OFF status of discrete coils in the slave.
Request
The request message specifies the starting coil and quantity of coils to be read.
Example of a request to read 10…22 (Coil 11 to 23) from slave device address 4:
Field Name | RTU (hex) | ASCII Characters |
---|---|---|
Header | None | : (Colon) |
Slave Address | 04 | 0 4 |
Function | 01 | 0 1 |
Starting Address Hi | 00 | 0 0 |
Starting Address Lo | 0A | 0 A |
Quantity of Coils Hi | 00 | 0 0 |
Quantity of Coils Lo | 0D | 0 D |
Error Check Lo | DD | LRC (E 4) |
Error Check Hi | 98 | |
Trailer | None | CR LF |
Total Bytes | 8 | 17 |
Response
The coil status response message is packed as one coil per bit of the data field. Status is indicated as: 1 is the value ON, and 0 is the value OFF. The LSB of the first data byte contains the coil addressed in the request. The other coils follow toward the high-order end of this byte and from low order to high order in subsequent bytes. If the returned coil quantity is not a multiple of eight, the remaining bits in the final data byte will be padded with zeroes (toward the high-order end of the byte). The byte count field specifies the quantity of complete bytes of data.
Example of a response to the request:
Field Name | RTU (hex) | ASCII Characters |
---|---|---|
Header | None | : (Colon) |
Slave Address | 04 | 0 4 |
Function | 01 | 0 1 |
Byte Count | 02 | 0 2 |
Data (Coils 7…10) | 0A | 0 A |
Data (Coils 27…20) | 11 | 1 1 |
Error Check Lo | B3 | LRC (D E) |
Error Check Hi | 50 | None |
Trailer | None | CR LF |
Total Bytes | 7 | 15 |
Спасибо. Но это скорее чтение группы регистров, а не маска состояний дискретных входов, которая представляет из себя один регистр, содержащий целочисленное, являющееся суммой чисел 2 возведенных в степени от 0 до 15 по порядку - 65535, когда все биты = 1.
Я понял, что тут этого нет. Ну и ладно, буду 16 регистров читать.
Coil - не регистр. Это бит. И вернется как раз байт в котором биты - состояния входов.