User Tools

Site Tools


custom_protocols

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
custom_protocols [2022/01/16 08:58] – ↷ Links adapted because of a move operation 127.0.0.1custom_protocols [2023/02/21 17:52] (current) – [writeRegister] emozolyak
Line 2: Line 2:
 ====== Custom protocols ====== ====== Custom protocols ======
  
-There are a lot of different automation devices with non-standard communication protocols. To solve the problem of data collection from such devices in WebHMI, it is possible to create custom protocols in [[ https://www.lua.org/ | Lua ]]. This function is available in WebHMI since version 1.10.0.3420.+There are a lot of different automation devices with non-standard communication protocols. To solve the problem of data collection from such devices in WebHMI, it is possireble to create custom protocols in [[ https://www.lua.org/ | Lua ]]. This function is available in WebHMI since version 1.10.0.3420.
  
 ===== About Lua ===== ===== About Lua =====
Line 90: Line 90:
 The function readRegister should read the specified register. The function readRegister should read the specified register.
  
-In case of successful reading, the function readRegister should return an array of bytes, with length corresponding to the specified data type (1, 2 or 4) or the number. In case of failure, you must return false.+In case of successful reading, the function readRegister should return an //(lua table)// **array of bytes, with length corresponding to the specified data type** (1, 2 or 4) or the number. In case of failure, you must return **boolean false**.
  
 Three parameters are passed to it as arguments: Three parameters are passed to it as arguments:
Line 97: Line 97:
   ***device** - Table (structure) with register type parameters (that were defined in createDevices)   ***device** - Table (structure) with register type parameters (that were defined in createDevices)
   ***unitId** – device ID for the bus or other ID. For instance, Slave ID in ModBus RTU or Unit ID in ModBus TCP.   ***unitId** – device ID for the bus or other ID. For instance, Slave ID in ModBus RTU or Unit ID in ModBus TCP.
-There are such attributes in the __reg__ structure:+ 
 +=== Attributes of the REG structure ===
  
   *internalAddr - Recalculated register address. This number is recalculated from the specified number system with shift added to it.   *internalAddr - Recalculated register address. This number is recalculated from the specified number system with shift added to it.
   *addr - The original address of the register that the user entered.   *addr - The original address of the register that the user entered.
   *dataType – The type of data that the user specified for the register. 0 = Bit, 1 = Byte, 2 = Word, 3 = Double Word, 4 = UnixTime   *dataType – The type of data that the user specified for the register. 0 = Bit, 1 = Byte, 2 = Word, 3 = Double Word, 4 = UnixTime
-There are such attributes in the __device__ structure:+ 
 +=== Attributes of the DEVICE structure ===
  
   *shift - The shift value from the corresponding row in createDevices   *shift - The shift value from the corresponding row in createDevices
Line 262: Line 264:
 The writeRegister function should write a new value to the specified register. If the record is successful, it should return true. In case of an error, false. The writeRegister function should write a new value to the specified register. If the record is successful, it should return true. In case of an error, false.
  
-Ей передаются все те же параметры, что и для readRegister, а также дополнительно четвертый параметр - новое значение. It has all the same arguments as for readRegister, as well as an additional fourth argument, a new value.+It has the same arguments as the readRegister, as well as fourth parameter which is a new value. 
  
 The writeRegister function may use the same methods of reading from and writing bytes to the port. The writeRegister function may use the same methods of reading from and writing bytes to the port.
custom_protocols.1642323514.txt.gz · Last modified: 2022/01/16 08:58 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki