Перейти к содержанию

Навигация

Modbus-client/en: различия между версиями

Новая страница: «More detailed description of the request and response data structure can be found on the Modbus Protocol page.»
(Новая страница: «---- 6. Turn on all the odd relays and turn off all the even ones. To do this, use the function 15 (Write Multiple Coils). There are only 14 relays in the module,…»)
(Новая страница: «More detailed description of the request and response data structure can be found on the Modbus Protocol page.»)
 
(не показано 5 промежуточных версий этого же участника)
Строка 147: Строка 147:


<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyAPP1 -a1 -t0x0f -r0x00 -c 14 0x00FF 0x0000 0x00FF 0x0000 0x00FF 0x0000 0x00FF 0x0000 0x00FF 0x0000 0x00FF 0x0000 0x00FF 0x0000</syntaxhighlight>
<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyAPP1 -a1 -t0x0f -r0x00 -c 14 0x00FF 0x0000 0x00FF 0x0000 0x00FF 0x0000 0x00FF 0x0000 0x00FF 0x0000 0x00FF 0x0000 0x00FF 0x0000</syntaxhighlight>
Ответ:
Answer:
<syntaxhighlight lang="bash">Data to write: 0xff 0x00 0xff 0x00 0xff 0x00 0xff 0x00 0xff 0x00 0xff 0x00 0xff 0x00  
<syntaxhighlight lang="bash">Data to write: 0xff 0x00 0xff 0x00 0xff 0x00 0xff 0x00 0xff 0x00 0xff 0x00 0xff 0x00  
Opening /dev/ttyAPP1 at 9600 bauds (N, 8, 2)
Opening /dev/ttyAPP1 at 9600 bauds (N, 8, 2)
Строка 156: Строка 156:




Обратите внимание на структуру данных запроса:
Note the structure of the query data:


*[01] — адрес
*[01] — address
*[0F] — код функции Write Multiple Coils
*[0F] — write Multiple Coils function code
*[00][00] — адрес первого регистра флагов для записи
*[00][00] — address of the first flag register to be recorded
*[00][0E] — количество элементов для записи (14)
*[00][0E] — number of items to record (14)
*[02] — количество байт данных (14 бит помещаются в 2 байтах)
*[02] — number of data bytes (14 bits are placed in 2 bytes)
*[55][15] — 01010101 00010101 (первое реле — младший бит первого байта, 8 реле — старший бит первого байта, 9 реле — младший бит второго байта)
*[55][15] — 01010101 00010101 (the first relay is the lowest bit of the first byte, 8th relay is the highest bit of the first byte, 9th relay is the lowest bit of the second byte)
*[1A][97] — CRC16
*[1A][97] — CRC16


А так же на структуру ответа:
As well as note the structure of the answer:


*<01> — адрес
*<01> — address
*<0F> — код функции Write Multiple Coils
*<0F> — write Multiple Coils function code
*<00><00> — адрес первого регистра флагов для записи
*<00><00> — address of the first flag register to be recorded
*<00><0E> — количество записанных регистров флагов
*<00><0E> — number of recorded flag registers
*<D4><0F> — CRC16
*<D4><0F> — CRC16


Подробнее описание структуры данных запросов и ответов можно найти на странице [[Special:MyLanguage/Протокол Modbus|Протокол Modbus]].
More detailed description of the request and response data structure can be found on the [[Протокол Modbus/en|Modbus Protocol]] page.
12 063

правки