Modified version of ModbusTCP

Dependencies:   EthernetNetIf mbed

Committer:
paleskyjp
Date:
Thu Mar 15 15:28:14 2012 +0000
Revision:
3:d7d7c67f21fa
Parent:
0:62be54b8975d
eMBRegCoilsCB was corrected.
(Implementation of writing single coil was wrong.)

Who changed what in which revision?

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