Port of the FreeModbus Libary for mbed

Dependencies:   mbed

Committer:
cam
Date:
Thu Apr 15 12:10:34 2010 +0000
Revision:
0:0453a0a7e500

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cam 0:0453a0a7e500 1 /*
cam 0:0453a0a7e500 2 * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
cam 0:0453a0a7e500 3 * Copyright (c) 2006 Christian Walter <wolti@sil.at>
cam 0:0453a0a7e500 4 * All rights reserved.
cam 0:0453a0a7e500 5 *
cam 0:0453a0a7e500 6 * Redistribution and use in source and binary forms, with or without
cam 0:0453a0a7e500 7 * modification, are permitted provided that the following conditions
cam 0:0453a0a7e500 8 * are met:
cam 0:0453a0a7e500 9 * 1. Redistributions of source code must retain the above copyright
cam 0:0453a0a7e500 10 * notice, this list of conditions and the following disclaimer.
cam 0:0453a0a7e500 11 * 2. Redistributions in binary form must reproduce the above copyright
cam 0:0453a0a7e500 12 * notice, this list of conditions and the following disclaimer in the
cam 0:0453a0a7e500 13 * documentation and/or other materials provided with the distribution.
cam 0:0453a0a7e500 14 * 3. The name of the author may not be used to endorse or promote products
cam 0:0453a0a7e500 15 * derived from this software without specific prior written permission.
cam 0:0453a0a7e500 16 *
cam 0:0453a0a7e500 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
cam 0:0453a0a7e500 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
cam 0:0453a0a7e500 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
cam 0:0453a0a7e500 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
cam 0:0453a0a7e500 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
cam 0:0453a0a7e500 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
cam 0:0453a0a7e500 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
cam 0:0453a0a7e500 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
cam 0:0453a0a7e500 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
cam 0:0453a0a7e500 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cam 0:0453a0a7e500 27 *
cam 0:0453a0a7e500 28 * File: $Id: mbproto.h,v 1.14 2006/12/07 22:10:34 wolti Exp $
cam 0:0453a0a7e500 29 */
cam 0:0453a0a7e500 30
cam 0:0453a0a7e500 31 #ifndef _MB_PROTO_H
cam 0:0453a0a7e500 32 #define _MB_PROTO_H
cam 0:0453a0a7e500 33
cam 0:0453a0a7e500 34 #ifdef __cplusplus
cam 0:0453a0a7e500 35 PR_BEGIN_EXTERN_C
cam 0:0453a0a7e500 36 #endif
cam 0:0453a0a7e500 37 /* ----------------------- Defines ------------------------------------------*/
cam 0:0453a0a7e500 38 #define MB_ADDRESS_BROADCAST ( 0 ) /*! Modbus broadcast address. */
cam 0:0453a0a7e500 39 #define MB_ADDRESS_MIN ( 1 ) /*! Smallest possible slave address. */
cam 0:0453a0a7e500 40 #define MB_ADDRESS_MAX ( 247 ) /*! Biggest possible slave address. */
cam 0:0453a0a7e500 41 #define MB_FUNC_NONE ( 0 )
cam 0:0453a0a7e500 42 #define MB_FUNC_READ_COILS ( 1 )
cam 0:0453a0a7e500 43 #define MB_FUNC_READ_DISCRETE_INPUTS ( 2 )
cam 0:0453a0a7e500 44 #define MB_FUNC_WRITE_SINGLE_COIL ( 5 )
cam 0:0453a0a7e500 45 #define MB_FUNC_WRITE_MULTIPLE_COILS ( 15 )
cam 0:0453a0a7e500 46 #define MB_FUNC_READ_HOLDING_REGISTER ( 3 )
cam 0:0453a0a7e500 47 #define MB_FUNC_READ_INPUT_REGISTER ( 4 )
cam 0:0453a0a7e500 48 #define MB_FUNC_WRITE_REGISTER ( 6 )
cam 0:0453a0a7e500 49 #define MB_FUNC_WRITE_MULTIPLE_REGISTERS ( 16 )
cam 0:0453a0a7e500 50 #define MB_FUNC_READWRITE_MULTIPLE_REGISTERS ( 23 )
cam 0:0453a0a7e500 51 #define MB_FUNC_DIAG_READ_EXCEPTION ( 7 )
cam 0:0453a0a7e500 52 #define MB_FUNC_DIAG_DIAGNOSTIC ( 8 )
cam 0:0453a0a7e500 53 #define MB_FUNC_DIAG_GET_COM_EVENT_CNT ( 11 )
cam 0:0453a0a7e500 54 #define MB_FUNC_DIAG_GET_COM_EVENT_LOG ( 12 )
cam 0:0453a0a7e500 55 #define MB_FUNC_OTHER_REPORT_SLAVEID ( 17 )
cam 0:0453a0a7e500 56 #define MB_FUNC_ERROR ( 128 )
cam 0:0453a0a7e500 57 /* ----------------------- Type definitions ---------------------------------*/
cam 0:0453a0a7e500 58 typedef enum
cam 0:0453a0a7e500 59 {
cam 0:0453a0a7e500 60 MB_EX_NONE = 0x00,
cam 0:0453a0a7e500 61 MB_EX_ILLEGAL_FUNCTION = 0x01,
cam 0:0453a0a7e500 62 MB_EX_ILLEGAL_DATA_ADDRESS = 0x02,
cam 0:0453a0a7e500 63 MB_EX_ILLEGAL_DATA_VALUE = 0x03,
cam 0:0453a0a7e500 64 MB_EX_SLAVE_DEVICE_FAILURE = 0x04,
cam 0:0453a0a7e500 65 MB_EX_ACKNOWLEDGE = 0x05,
cam 0:0453a0a7e500 66 MB_EX_SLAVE_BUSY = 0x06,
cam 0:0453a0a7e500 67 MB_EX_MEMORY_PARITY_ERROR = 0x08,
cam 0:0453a0a7e500 68 MB_EX_GATEWAY_PATH_FAILED = 0x0A,
cam 0:0453a0a7e500 69 MB_EX_GATEWAY_TGT_FAILED = 0x0B
cam 0:0453a0a7e500 70 } eMBException;
cam 0:0453a0a7e500 71
cam 0:0453a0a7e500 72 typedef eMBException( *pxMBFunctionHandler ) ( UCHAR * pucFrame, USHORT * pusLength );
cam 0:0453a0a7e500 73
cam 0:0453a0a7e500 74 typedef struct
cam 0:0453a0a7e500 75 {
cam 0:0453a0a7e500 76 UCHAR ucFunctionCode;
cam 0:0453a0a7e500 77 pxMBFunctionHandler pxHandler;
cam 0:0453a0a7e500 78 } xMBFunctionHandler;
cam 0:0453a0a7e500 79
cam 0:0453a0a7e500 80 #ifdef __cplusplus
cam 0:0453a0a7e500 81 PR_END_EXTERN_C
cam 0:0453a0a7e500 82 #endif
cam 0:0453a0a7e500 83 #endif