UART Communication Settings/en: различия между версиями

Нет описания правки
(Новая страница: «The device now transmits and receives data at 115200 bps.»)
 
(не показано 6 промежуточных версий этого же участника)
Строка 4: Строка 4:




== RS-485 data exchange parameters registers==
== Registers of parameters of data exchange via RS-485 ==


In the factory configuration, all Wiren Board devices are supplied with the following RS-485 settings: 9600 bps, no parity bit (none), stop bit count — 2. However, the firmware of almost all modern  Wiren Board devices supports additional registers, which set parameters of data exchange via RS-485:
In the factory configuration, all Wiren Board devices are supplied with the following RS-485 settings: 9600 bps, no parity bit (none), stop bit count — 2. However, the firmware of almost all modern  Wiren Board devices supports additional registers, which set parameters of data exchange via RS-485:
Строка 43: Строка 43:
The device now transmits and receives data at 115200 bps.
The device now transmits and receives data at 115200 bps.


Записью в соответствующие регистры изменяется четность и количество стоп-битов.
Writing to the appropriate registers changes the parity and the number of stop bits.


При этом возникает парадоксальная ситуация: мы не можем узнать значение скорости, если мы заранее не укажем её значение при обращении к устройству! Поэтому стоит внимательно относиться к тому, какие коммуникационные параметры вы устанавливайте. Наклейте на устройство наклейку с новыми параметрами. В случае, если все коммуникационные параметры неизвестны, найти их можно только перебором:
In this case, a paradoxical situation arises: we can not know the value of the speed, if we do not specify its value in advance when referring to the device! Therefore, you should pay attention to what communication parameters you set. Stick a sticker with the new settings on the device. If all communication parameters are unknown, you can find them only by searching:


     #/bin/bash
     #/bin/bash
Строка 61: Строка 61:
     done
     done


В этом [[Special:MyLanguage/Media:Perebor.sh.tar.gz|скрипте]] мы обращаемся к регистру 0x80, в котором во всех modbus-устройствах Wiren Board хранится modbus-адрес. Вывод скрипта будет содержать строки, подобные этим:
In this [[Media:Perebor.sh.tar.gz|script]] we refer to the 0x80 register, which stores the modbus address in all Wiren Board Modbus devices. The output of the script will contain lines like these:
  Speed:9600      Stop bits:1    Parity:none    Modbus address:0x0001
  Speed:9600      Stop bits:1    Parity:none    Modbus address:0x0001
  Speed:9600      Stop bits:2    Parity:none    Modbus address:0x0001
  Speed:9600      Stop bits:2    Parity:none    Modbus address:0x0001


Для стоп-битов, скорее всего, вы получите два значения: 1 и 2. Уточнить настройку можно считав значение из регистра 112 с уже известным адресом, скоростью, четностью:
For stop bits, you will likely get two values: 1 and 2. You can refine the setting by reading the value from the register 112 with the already known address, speed, parity:


  modbus_client --debug -mrtu -b'''9600''' -p'''none''' -s'''2''' /dev/ttyAPP1 -a'''0x01''' -t0x03 -r112
  modbus_client --debug -mrtu -b'''9600''' -p'''none''' -s'''2''' /dev/ttyAPP1 -a'''0x01''' -t0x03 -r112


или
or


  modbus_client --debug -mrtu -b'''9600''' -p'''none''' -s'''1''' /dev/ttyAPP1 -a'''0x01''' -t0x03 -r112
  modbus_client --debug -mrtu -b'''9600''' -p'''none''' -s'''1''' /dev/ttyAPP1 -a'''0x01''' -t0x03 -r112
Строка 76: Строка 76:
     Data: 0x0002
     Data: 0x0002


Если при чтении из регистра 112 вы получаете ошибку, то устройство не поддерживает установку коммуникационных параметров. В этом случае для коммуникации используется значение по умолчанию,2 стоп-бита.
If you receive an error while reading from register 112, the device does not support setting communication parameters. In this case,the default value of 2 stop bits is used for communication.
12 063

правки