api.go 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2014 Quoc-Viet Nguyen. All rights reserved.
  2. // This software may be modified and distributed under the terms
  3. // of the BSD license. See the LICENSE file for details.
  4. package modbus
  5. type Client interface {
  6. // Bit access
  7. // ReadCoils reads from 1 to 2000 contiguous status of coils in a
  8. // remote device and returns coil status.
  9. ReadCoils(address, quantity uint16) (results []byte, err error)
  10. // ReadDiscreteInputs reads from 1 to 2000 contiguous status of
  11. // discrete inputs in a remote device and returns input status.
  12. ReadDiscreteInputs(address, quantity uint16) (results []byte, err error)
  13. // WriteSingleCoil write a single output to either ON or OFF in a
  14. // remote device and returns output value.
  15. WriteSingleCoil(address, value uint16) (results []byte, err error)
  16. // WriteMultipleCoils forces each coil in a sequence of coils to either
  17. // ON or OFF in a remote device and returns quantity of outputs.
  18. WriteMultipleCoils(address, quantity uint16, value []byte) (results []byte, err error)
  19. // 16-bit access
  20. // ReadInputRegisters reads from 1 to 125 contiguous input registers in
  21. // a remote device and returns input registers.
  22. ReadInputRegisters(address, quantity uint16) (results []byte, err error)
  23. PackReadHoldingRegisters(address, quantity uint16) (results []byte, err error)
  24. DePackRegisters(aduResponse []byte) (results []byte, err error)
  25. // ReadHoldingRegisters reads the contents of a contiguous block of
  26. // holding registers in a remote device and returns register value.
  27. ReadHoldingRegisters(address, quantity uint16) (results []byte, err error)
  28. // WriteSingleRegister writes a single holding register in a remote
  29. // device and returns register value.
  30. WriteSingleRegister(address, value uint16) (results []byte, err error)
  31. // WriteMultipleRegisters writes a block of contiguous registers
  32. // (1 to 123 registers) in a remote device and returns quantity of
  33. // registers.
  34. WriteMultipleRegisters(address, quantity uint16, value []byte) (results []byte, err error)
  35. // ReadWriteMultipleRegisters performs a combination of one read
  36. // operation and one write operation. It returns read registers value.
  37. ReadWriteMultipleRegisters(readAddress, readQuantity, writeAddress, writeQuantity uint16, value []byte) (results []byte, err error)
  38. // MaskWriteRegister modify the contents of a specified holding
  39. // register using a combination of an AND mask, an OR mask, and the
  40. // register's current contents. The function returns
  41. // AND-mask and OR-mask.
  42. MaskWriteRegister(address, andMask, orMask uint16) (results []byte, err error)
  43. //ReadFIFOQueue reads the contents of a First-In-First-Out (FIFO) queue
  44. // of register in a remote device and returns FIFO value register.
  45. ReadFIFOQueue(address uint16) (results []byte, err error)
  46. }