Modbus RTU/ASCII/TCP with lwip TCP working partial, but with errors (retransmitions)

Dependencies:   EthernetNetIf mbed

Committer:
tmav123
Date:
Mon Dec 05 22:49:02 2011 +0000
Revision:
0:f54e9507171b

        

Who changed what in which revision?

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