ModbusInfo.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace HslCommunication.ModBus
  6. {
  7. /// <summary>
  8. /// Modbus协议相关的一些信息
  9. /// </summary>
  10. public class ModbusInfo
  11. {
  12. /*****************************************************************************************
  13. *
  14. * 本服务器和客户端支持的常用功能码
  15. *
  16. *******************************************************************************************/
  17. /// <summary>
  18. /// 读取线圈
  19. /// </summary>
  20. public const byte ReadCoil = 0x01;
  21. /// <summary>
  22. /// 读取离散量
  23. /// </summary>
  24. public const byte ReadDiscrete = 0x02;
  25. /// <summary>
  26. /// 读取寄存器
  27. /// </summary>
  28. public const byte ReadRegister = 0x03;
  29. /// <summary>
  30. /// 写单个线圈
  31. /// </summary>
  32. public const byte WriteOneCoil = 0x05;
  33. /// <summary>
  34. /// 写单个寄存器
  35. /// </summary>
  36. public const byte WriteOneRegister = 0x06;
  37. /// <summary>
  38. /// 写多个线圈
  39. /// </summary>
  40. public const byte WriteCoil = 0x0F;
  41. /// <summary>
  42. /// 写多个寄存器
  43. /// </summary>
  44. public const byte WriteRegister = 0x10;
  45. /*****************************************************************************************
  46. *
  47. * 本服务器和客户端支持的异常返回
  48. *
  49. *******************************************************************************************/
  50. /// <summary>
  51. /// 不支持该功能码
  52. /// </summary>
  53. public const byte FunctionCodeNotSupport = 0x01;
  54. /// <summary>
  55. /// 该地址越界
  56. /// </summary>
  57. public const byte FunctionCodeOverBound = 0x02;
  58. /// <summary>
  59. /// 读取长度超过最大值
  60. /// </summary>
  61. public const byte FunctionCodeQuantityOver = 0x03;
  62. /// <summary>
  63. /// 读写异常
  64. /// </summary>
  65. public const byte FunctionCodeReadWriteException = 0x04;
  66. }
  67. }