1 /* 2 * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. 3 * Copyright (c) 2006 Christian Walter <[email protected]> 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 * File: $Id: mbconfig.h,v 1.14 2006/12/07 22:10:34 wolti Exp $ 29 * $Id: mbconfig.h,v 1.60 2013/08/13 21:19:55 Armink Add Master Functions $ 30 */ 31 32 #ifndef _MB_CONFIG_H 33 #define _MB_CONFIG_H 34 35 #ifdef __cplusplus 36 PR_BEGIN_EXTERN_C 37 #endif 38 /* ----------------------- Defines ------------------------------------------*/ 39 /*! \defgroup modbus_cfg Modbus Configuration 40 * 41 * Most modules in the protocol stack are completly optional and can be 42 * excluded. This is specially important if target resources are very small 43 * and program memory space should be saved.<br> 44 * 45 * All of these settings are available in the file <code>mbconfig.h</code> 46 */ 47 /*! \addtogroup modbus_cfg 48 * @{ 49 */ 50 /*! \brief If Modbus Master ASCII support is enabled. */ 51 #define MB_MASTER_ASCII_ENABLED ( 0 ) 52 /*! \brief If Modbus Master RTU support is enabled. */ 53 #define MB_MASTER_RTU_ENABLED ( 1 ) 54 /*! \brief If Modbus Master TCP support is enabled. */ 55 #define MB_MASTER_TCP_ENABLED ( 0 ) 56 /*! \brief If Modbus Slave ASCII support is enabled. */ 57 #define MB_SLAVE_ASCII_ENABLED ( 0 ) 58 /*! \brief If Modbus Slave RTU support is enabled. */ 59 #define MB_SLAVE_RTU_ENABLED ( 1 ) 60 /*! \brief If Modbus Slave TCP support is enabled. */ 61 #define MB_SLAVE_TCP_ENABLED ( 0 ) 62 /*! \brief The character timeout value for Modbus ASCII. 63 * 64 * The character timeout value is not fixed for Modbus ASCII and is therefore 65 * a configuration option. It should be set to the maximum expected delay 66 * time of the network. 67 */ 68 #define MB_ASCII_TIMEOUT_SEC ( 1 ) 69 /*! \brief Maximum number of Modbus functions codes the protocol stack 70 * should support. 71 * 72 * The maximum number of supported Modbus functions must be greater than 73 * the sum of all enabled functions in this file and custom function 74 * handlers. If set to small adding more functions will fail. 75 */ 76 #define MB_FUNC_HANDLERS_MAX ( 16 ) 77 /*! \brief Number of bytes which should be allocated for the <em>Report Slave ID 78 * </em>command. 79 * 80 * This number limits the maximum size of the additional segment in the 81 * report slave id function. See eMBSetSlaveID( ) for more information on 82 * how to set this value. It is only used if MB_FUNC_OTHER_REP_SLAVEID_ENABLED 83 * is set to <code>1</code>. 84 */ 85 #define MB_FUNC_OTHER_REP_SLAVEID_BUF ( 32 ) 86 /*! \brief If the <em>Report Slave ID</em> function should be enabled. */ 87 #define MB_FUNC_OTHER_REP_SLAVEID_ENABLED ( 1 ) 88 /*! \brief If the <em>Read Input Registers</em> function should be enabled. */ 89 #define MB_FUNC_READ_INPUT_ENABLED ( 1 ) 90 /*! \brief If the <em>Read Holding Registers</em> function should be enabled. */ 91 #define MB_FUNC_READ_HOLDING_ENABLED ( 1 ) 92 /*! \brief If the <em>Write Single Register</em> function should be enabled. */ 93 #define MB_FUNC_WRITE_HOLDING_ENABLED ( 1 ) 94 /*! \brief If the <em>Write Multiple registers</em> function should be enabled. */ 95 #define MB_FUNC_WRITE_MULTIPLE_HOLDING_ENABLED ( 1 ) 96 /*! \brief If the <em>Read Coils</em> function should be enabled. */ 97 #define MB_FUNC_READ_COILS_ENABLED ( 1 ) 98 /*! \brief If the <em>Write Coils</em> function should be enabled. */ 99 #define MB_FUNC_WRITE_COIL_ENABLED ( 1 ) 100 /*! \brief If the <em>Write Multiple Coils</em> function should be enabled. */ 101 #define MB_FUNC_WRITE_MULTIPLE_COILS_ENABLED ( 1 ) 102 /*! \brief If the <em>Read Discrete Inputs</em> function should be enabled. */ 103 #define MB_FUNC_READ_DISCRETE_INPUTS_ENABLED ( 1 ) 104 /*! \brief If the <em>Read/Write Multiple Registers</em> function should be enabled. */ 105 #define MB_FUNC_READWRITE_HOLDING_ENABLED ( 1 ) 106 /*! @} */ 107 #ifdef __cplusplus 108 PR_END_EXTERN_C 109 #endif 110 111 #if MB_MASTER_RTU_ENABLED > 0 || MB_MASTER_ASCII_ENABLED > 0 112 /*! \brief If master send a broadcast frame,the master will wait time of convert to delay, 113 * then master can send other frame */ 114 #define MB_MASTER_DELAY_MS_CONVERT (200 ) 115 /*! \brief If master send a frame which is not broadcast,the master will wait sometime for slave. 116 * And if slave is not respond in this time,the master will process this timeout error. 117 * Then master can send other frame */ 118 #define MB_MASTER_TIMEOUT_MS_RESPOND (100 ) 119 /*! \brief The total slaves in Modbus Master system. Default 16. 120 * \note : The slave ID must be continuous from 1.*/ 121 #define MB_MASTER_TOTAL_SLAVE_NUM ( 16 ) 122 #endif 123 124 #endif 125