项目作者: chipkin

项目描述 :
A basic Modbus TCP Slave example written in CSharp using the CAS Modbus Stack
高级语言: C#
项目地址: git://github.com/chipkin/ModbusTCPSlaveExampleCSharp.git
创建时间: 2019-07-16T20:50:35Z
项目社区:https://github.com/chipkin/ModbusTCPSlaveExampleCSharp

开源协议:

下载


Modbus TCP Slave Example CSharp

A basic Modbus TCP Slave example written in CSharp using the CAS Modbus Stack

User input

Below is the user input for this application.

  • Q - Quit
  • UP Arror - Increase 40,001 by 1
  • Down Arror - Decrease 40,001 by 1

Example output

  1. Starting Modbus TCP Slave Example version 0.0.1.0
  2. https://github.com/chipkin/ModbusTCPMasterExampleCSharp
  3. FYI: CAS Modbus Stack version: 2.3.11.0
  4. FYI: CAS Modbus Stack Setup, successfuly
  5. FYI: Binding tcp port. port=[502]...
  6. FYI: Waiting on TCP connection TCP port=[502]...
  7. FYI: Got a connection from IP address=[192.168.1.77:53786]
  8. FYI: Recived 12 bytes from 192.168.1.77:53786
  9. 00 02 00 00 00 06 FF 03 00 00 00 6E
  10. FYI: GetModbusValue slaveAddress=[0], function=[3], startingAddress=[0], length=[110]
  11. FYI: Sending 229 bytes to 192.168.1.77:53786
  12. 00 02 00 00 00 DF 00 03 DC 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  13. FYI: Key UpArrow pressed.
  14. FYI: Increase 40001 by 1. Before=0, After=1
  15. FYI: Key UpArrow pressed.
  16. FYI: Increase 40001 by 1. Before=1, After=2
  17. FYI: Key UpArrow pressed.
  18. FYI: Increase 40001 by 1. Before=2, After=3
  19. FYI: Recived 12 bytes from 192.168.1.77:53786
  20. 00 02 00 00 00 06 FF 03 00 00 00 6E
  21. FYI: GetModbusValue slaveAddress=[0], function=[3], startingAddress=[0], length=[110]
  22. FYI: Sending 229 bytes to 192.168.1.77:53786
  23. 00 02 00 00 00 DF 00 03 DC 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  24. FYI: Key DownArrow pressed.
  25. FYI: Decrease 40001 by 1. Before=3, After=2
  26. FYI: Recived 12 bytes from 192.168.1.77:53786
  27. 00 02 00 00 00 06 FF 03 00 00 00 6E
  28. FYI: GetModbusValue slaveAddress=[0], function=[3], startingAddress=[0], length=[110]
  29. FYI: Sending 229 bytes to 192.168.1.77:53786
  30. 00 02 00 00 00 DF 00 03 DC 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  31. FYI: Recived 12 bytes from 192.168.1.77:53786
  32. 00 02 00 00 00 06 FF 06 00 00 00 71
  33. FYI: SetModbusValue slaveAddress=[0], function=[6], startingAddress=[0], length=[1], dataSize=[2]
  34. FYI: Sending 12 bytes to 192.168.1.77:53786
  35. 00 02 00 00 00 06 00 06 00 00 00 71
  36. FYI: Recived 12 bytes from 192.168.1.77:53786
  37. 00 02 00 00 00 06 FF 03 00 00 00 6E
  38. FYI: GetModbusValue slaveAddress=[0], function=[3], startingAddress=[0], length=[110]
  39. FYI: Sending 229 bytes to 192.168.1.77:53786
  40. 00 02 00 00 00 DF 00 03 DC 00 71 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  41. FYI: Key Spacebar pressed.
  42. FYI: Modbus Stack version: 2.3.11.0
  43. Help:
  44. Q - Quit
  45. UP Arror - Increase 40,001 by 1
  46. Down Arror - Decrease 40,001 by 1
  47. FYI: Key Q pressed.
  48. FYI: Quit

Building

  1. Copy CASModbusStack_Win32_Debug.dll, CASModbusStack_Win32_Release.dll, CASModbusStack_x64_Debug.dll, and CASModbusStack_x64_Release.dll from the CAS Modbus Stack project into the /bin/ folder.
  2. Use Visual Studios 2019 to build the project. The solution can be found in the /ModbusTCPSlaveExampleCSharp/ folder.

Note: The project is automaticly build on every checkin using GitlabCI.