mbconfig.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
  3. * Copyright (c) 2006-2018 Christian Walter <cwalter@embedded-solutions.at>
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. The name of the author may not be used to endorse or promote products
  15. * derived from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  18. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  20. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  21. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  22. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. *
  28. */
  29. #ifndef _MB_CONFIG_H
  30. #define _MB_CONFIG_H
  31. #ifdef __cplusplus
  32. PR_BEGIN_EXTERN_C
  33. #endif
  34. /* ----------------------- Defines ------------------------------------------*/
  35. /*! \defgroup modbus_cfg Modbus Configuration
  36. *
  37. * Most modules in the protocol stack are completly optional and can be
  38. * excluded. This is specially important if target resources are very small
  39. * and program memory space should be saved.<br>
  40. *
  41. * All of these settings are available in the file <code>mbconfig.h</code>
  42. */
  43. /*! \addtogroup modbus_cfg
  44. * @{
  45. */
  46. /*! \brief If Modbus ASCII support is enabled. */
  47. #define MB_ASCII_ENABLED ( 0 )
  48. /*! \brief If Modbus RTU support is enabled. */
  49. #define MB_RTU_ENABLED ( 1 )
  50. /*! \brief If Modbus TCP support is enabled. */
  51. #define MB_TCP_ENABLED ( 0 )
  52. /*! \brief The character timeout value for Modbus ASCII.
  53. *
  54. * The character timeout value is not fixed for Modbus ASCII and is therefore
  55. * a configuration option. It should be set to the maximum expected delay
  56. * time of the network.
  57. */
  58. #define MB_ASCII_TIMEOUT_SEC ( 1 )
  59. /*! \brief Timeout to wait in ASCII prior to enabling transmitter.
  60. *
  61. * If defined the function calls vMBPortSerialDelay with the argument
  62. * MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS to allow for a delay before
  63. * the serial transmitter is enabled. This is required because some
  64. * targets are so fast that there is no time between receiving and
  65. * transmitting the frame. If the master is to slow with enabling its
  66. * receiver then he will not receive the response correctly.
  67. */
  68. #ifndef MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS
  69. #define MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS ( 0 )
  70. #endif
  71. /*! \brief Maximum number of Modbus functions codes the protocol stack
  72. * should support.
  73. *
  74. * The maximum number of supported Modbus functions must be greater than
  75. * the sum of all enabled functions in this file and custom function
  76. * handlers. If set to small adding more functions will fail.
  77. */
  78. #define MB_FUNC_HANDLERS_MAX ( 13 )//( 16 )
  79. /*! \brief Number of bytes which should be allocated for the <em>Report Slave ID
  80. * </em>command.
  81. *
  82. * This number limits the maximum size of the additional segment in the
  83. * report slave id function. See eMBSetSlaveID( ) for more information on
  84. * how to set this value. It is only used if MB_FUNC_OTHER_REP_SLAVEID_ENABLED
  85. * is set to <code>1</code>.
  86. */
  87. #define MB_FUNC_OTHER_REP_SLAVEID_BUF ( 32 )
  88. /*! \brief If the <em>Report Slave ID</em> function should be enabled. */
  89. #define MB_FUNC_OTHER_REP_SLAVEID_ENABLED ( 1 )
  90. /*! \brief If the <em>Read Input Registers</em> function should be enabled. */
  91. #define MB_FUNC_READ_INPUT_ENABLED ( 1 )
  92. /*! \brief If the <em>Read Holding Registers</em> function should be enabled. */
  93. #define MB_FUNC_READ_HOLDING_ENABLED ( 1 )
  94. /*! \brief If the <em>Write Single Register</em> function should be enabled. */
  95. #define MB_FUNC_WRITE_HOLDING_ENABLED ( 1 )
  96. /*! \brief If the <em>Write Multiple registers</em> function should be enabled. */
  97. #define MB_FUNC_WRITE_MULTIPLE_HOLDING_ENABLED ( 1 )
  98. /*! \brief If the <em>Read Coils</em> function should be enabled. */
  99. #define MB_FUNC_READ_COILS_ENABLED ( 1 )
  100. /*! \brief If the <em>Write Coils</em> function should be enabled. */
  101. #define MB_FUNC_WRITE_COIL_ENABLED ( 1 )
  102. /*! \brief If the <em>Write Multiple Coils</em> function should be enabled. */
  103. #define MB_FUNC_WRITE_MULTIPLE_COILS_ENABLED ( 1 )
  104. /*! \brief If the <em>Read Discrete Inputs</em> function should be enabled. */
  105. #define MB_FUNC_READ_DISCRETE_INPUTS_ENABLED ( 1 )
  106. /*! \brief If the <em>Read/Write Multiple Registers</em> function should be enabled. */
  107. #define MB_FUNC_READWRITE_HOLDING_ENABLED ( 1 )
  108. /*! \brief If the <em>Update</em> function should be enabled. */
  109. #define MB_FUNC_UPDATE_ENABLED ( 1 )
  110. /*! \brief If the <em>Set modbus address by STM ID</em> function should be enabled. */
  111. #define MB_FUNC_SET_ADDR_ID_ENABLED ( 1 )
  112. /*! \brief If the <em>Set modbus address by serial number</em> function should be enabled. */
  113. #define MB_FUNC_SET_ADDR_SERIAL_ENABLED ( 1 )
  114. /*! @} */
  115. #ifdef __cplusplus
  116. PR_END_EXTERN_C
  117. #endif
  118. #endif