9
0
Fork 0

Use NuttX types in FreeModBus port; Add FreeModBus demo at apps/examples/modbus; Add new termios APIs

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4964 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2012-07-21 21:23:18 +00:00
parent 8ec530935d
commit 9af42286d2
44 changed files with 1387 additions and 418 deletions

View File

@ -251,5 +251,9 @@
6.21 2012-xx-xx Gregory Nutt <gnutt@nuttx.org>
* apps/include/: Stylistic clean-up of all header files.
* apps/modbus and apps/include/modbus: The beginnings of a port of
freemodbus-v1.5.0.
* apps/modbus and apps/include/modbus: A port of freemodbus-v1.5.0
has been added to the NuttX apps/ source tree.
* apps/examples/modbus: A port of the freemodbus-v1.5.0 "demo"
program that will be used to verify the FreeModBus port

View File

@ -63,6 +63,10 @@ menu "File system mount example"
source "$APPSDIR/examples/mount/Kconfig"
endmenu
menu "FreeModBus example"
source "$APPSDIR/examples/modbus/Kconfig"
endmenu
menu "Network test example"
source "$APPSDIR/examples/nettest/Kconfig"
endmenu

View File

@ -38,10 +38,10 @@
# Sub-directories
SUBDIRS = adc buttons can cdcacm composite dhcpd ftpc ftpd hello helloxx \
hidkbd igmp lcdrw mm mount nettest nsh null nx nxconsole nxffs nxflat \
nxhello nximage nxlines nxtext ostest pashello pipe poll pwm qencoder \
rgmp romfs serloop telnetd thttpd tiff touchscreen udp uip usbserial \
sendmail usbstorage usbterm watchdog wget wlan
hidkbd igmp lcdrw mm modbus mount nettest nsh null nx nxconsole nxffs \
nxflat nxhello nximage nxlines nxtext ostest pashello pipe poll pwm \
qencoder rgmp romfs serloop telnetd thttpd tiff touchscreen udp uip \
usbserial sendmail usbstorage usbterm watchdog wget wlan
# Sub-directories that might need context setup. Directories may need
# context setup for a variety of reasons, but the most common is because
@ -56,7 +56,7 @@ SUBDIRS = adc buttons can cdcacm composite dhcpd ftpc ftpd hello helloxx \
CNTXTDIRS = pwm
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
CNTXTDIRS += adc can cdcacm composite ftpd dhcpd nettest qencoder telnetd watchdog
CNTXTDIRS += adc can cdcacm composite ftpd dhcpd modbus nettest qencoder telnetd watchdog
endif
ifeq ($(CONFIG_EXAMPLES_HELLO_BUILTIN),y)

View File

@ -483,6 +483,21 @@ examples/mm
advantage that it runs in the actual NuttX tasking environment (the
mm/mm_test.c only runs in a PC simulation environment).
examples/modbus
^^^^^^^^^^^^^^^
This is a port of the FreeModbus Linux demo. It derives from the
demos/LINUX directory of the FreeModBus version 1.5.0 (June 6, 2010)
that can be downloaded in its entirety from http://developer.berlios.de/project/showfiles.php?group_id=6120.
CONFIG_EXAMPLES_MODBUS_REG_INPUT_START, Default 1000
CONFIG_EXAMPLES_MODBUS_REG_INPUT_NREGS, Default 4
CONFIG_EXAMPLES_MODBUS_REG_HOLDING_START, Default 2000
CONFIG_EXAMPLES_MODBUS_REG_HOLDING_NREGS, Default 130
The FreeModBus library resides at apps/modbus. See apps/modbus/README.txt
for additional configuration information.
examples/mount
^^^^^^^^^^^^^^

0
apps/examples/ftpd/ftpd_main.c Executable file → Normal file
View File

View File

View File

@ -0,0 +1,13 @@
#
# For a description of the syntax of this configuration file,
# see misc/tools/kconfig-language.txt.
#
config EXAMPLES_MODBUS
bool "FreeModBus example"
default n
---help---
Enable the FreeModBus example
if EXAMPLES_MODBUS
endif

View File

@ -0,0 +1,105 @@
############################################################################
# apps/examples/modbus/Makefile
#
# Copyright (C) 2012 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# FreeModBus demo built-in application info
APPNAME = modbus
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = 2048
# FreeModBus demo
ASRCS =
CSRCS = modbus_main.c
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
ifeq ($(WINTOOL),y)
BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}"
else
BIN = "$(APPDIR)/libapps$(LIBEXT)"
endif
ROOTDEPPATH = --dep-path .
# Common build
VPATH =
all: .built
.PHONY: clean depend distclean
$(AOBJS): %$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)
$(COBJS): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
.built: $(OBJS)
@( for obj in $(OBJS) ; do \
$(call ARCHIVE, $(BIN), $${obj}); \
done ; )
@touch .built
.context:
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
@touch $@
endif
context: .context
.depend: Makefile $(SRCS)
@$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
@touch $@
depend: .depend
clean:
@rm -f *.o *~ .*.swp .built
$(call CLEAN)
distclean: clean
@rm -f Make.dep .depend
-include Make.dep

View File

@ -0,0 +1,531 @@
/****************************************************************************
* examples/modbus/main.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************
* Leveraged from:
*
* FreeModbus Libary: Linux Demo Application
* Copyright (C) 2006 Christian Walter <wolti@sil.at>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <signal.h>
#include <errno.h>
#include <apps/modbus/mb.h>
#include <apps/modbus/mbport.h>
/****************************************************************************
* Definitions
****************************************************************************/
/* Configuration ************************************************************/
#ifndef CONFIG_EXAMPLES_MODBUS_REG_INPUT_START
# define CONFIG_EXAMPLES_MODBUS_REG_INPUT_START 1000
#endif
#ifndef CONFIG_EXAMPLES_MODBUS_REG_INPUT_NREGS
# define CONFIG_EXAMPLES_MODBUS_REG_INPUT_NREGS 4
#endif
#ifndef CONFIG_EXAMPLES_MODBUS_REG_HOLDING_START
# define CONFIG_EXAMPLES_MODBUS_REG_HOLDING_START 2000
#endif
#ifndef CONFIG_EXAMPLES_MODBUS_REG_HOLDING_NREGS
# define CONFIG_EXAMPLES_MODBUS_REG_HOLDING_NREGS 130
#endif
#ifdef CONFIG_NSH_BUILTIN_APPS
# define MAIN_NAME modbus_main
# define MAIN_NAME_STRING "modbus_main: "
#else
# define MAIN_NAME user_start
# define MAIN_NAME_STRING "user_start: "
#endif
/****************************************************************************
* Private Types
****************************************************************************/
enum modbus_threadstate_e
{
STOPPED = 0,
RUNNING,
SHUTDOWN
};
struct modbus_state_s
{
enum modbus_threadstate_e threadstate;
uint16_t reginput[CONFIG_EXAMPLES_MODBUS_REG_INPUT_NREGS];
uint16_t regholding[CONFIG_EXAMPLES_MODBUS_REG_HOLDING_NREGS];
pthread_t threadid;
pthread_mutex_t lock;
volatile bool quit;
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static inline int modbus_initialize(void);
static void *modbus_pollthread(void *pvarg);
static inline int modbus_create_pollthread(void);
static void modbus_showusage(FAR const char *progname, int exitcode);
/****************************************************************************
* Private Data
****************************************************************************/
static struct modbus_state_s g_modbus;
static const uint8_t g_slaveid[] = { 0xaa, 0xbb, 0xcc };
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: modbus_initialize
*
* Description:
* Called from the ModBus polling thread in order to initialized the
* FreeModBus interface.
*
****************************************************************************/
static inline int modbus_initialize(void)
{
eMBErrorCode mberr;
int status;
/* Verify that we are in the stopped state */
if (g_modbus.threadstate != STOPPED)
{
fprintf(stderr, MAIN_NAME_STRING
"ERROR: Bad state: %d\n", g_modbus.threadstate);
return EINVAL;
}
/* Initialize the ModBus demo data structures */
status = pthread_mutex_init(&g_modbus.lock, NULL);
if (status != 0)
{
fprintf(stderr, MAIN_NAME_STRING
"ERROR: pthread_mutex_init failed: %d\n", status);
return status;
}
status = ENODEV;
/* Initialize the FreeModBus library */
mberr = eMBInit(MB_RTU, 0X0A, 0, 38400, MB_PAR_EVEN);
if (mberr != MB_ENOERR)
{
fprintf(stderr, MAIN_NAME_STRING
"ERROR: eMBInit failed: %d\n", mberr);
goto errout_with_mutex;
}
/* Set the slave ID */
mberr = eMBSetSlaveID(0x34, TRUE, g_slaveid, 3);
if (mberr != MB_ENOERR)
{
fprintf(stderr, MAIN_NAME_STRING
"ERROR: eMBSetSlaveID failed: %d\n", mberr);
goto errout_with_modbus;
}
/* Enable FreeModBus */
mberr = eMBEnable();
if (mberr == MB_ENOERR)
{
fprintf(stderr, MAIN_NAME_STRING
"ERROR: eMBEnable failed: %d\n", mberr);
goto errout_with_modbus;
}
/* Successfully initialized */
g_modbus.threadstate = RUNNING;
return OK;
errout_with_modbus:
/* Release hardware resources. */
(void)eMBClose();
errout_with_mutex:
/* Free/uninitialize data structures */
(void)pthread_mutex_destroy(&g_modbus.lock);
g_modbus.threadstate = STOPPED;
return status;
}
/****************************************************************************
* Name: modbus_pollthread
*
* Description:
* This is the ModBus polling thread.
*
****************************************************************************/
static void *modbus_pollthread(void *pvarg)
{
eMBErrorCode mberr;
int ret;
/* Initialize the modbus */
ret = modbus_initialize();
if (ret != OK)
{
fprintf(stderr, MAIN_NAME_STRING
"ERROR: modbus_initialize failed: %d\n", ret);
return NULL;
}
/* Then loop until we are commanded to shutdown */
do
{
/* Poll */
mberr = eMBPoll();
if (mberr != MB_ENOERR)
{
break;
}
/* Generate some random input */
g_modbus.reginput[0] = (uint16_t)rand();
}
while (g_modbus.threadstate != SHUTDOWN);
/* Disable */
(void)eMBDisable();
/* Release hardware resources. */
(void)eMBClose();
/* Free/uninitialize data structures */
(void)pthread_mutex_destroy(&g_modbus.lock);
g_modbus.threadstate = STOPPED;
return NULL;
}
/****************************************************************************
* Name: modbus_create_pollthread
*
* Description:
* Start the ModBus polling thread
*
****************************************************************************/
static inline int modbus_create_pollthread(void)
{
int ret;
if (g_modbus.threadstate == STOPPED)
{
ret = pthread_create(&g_modbus.threadid, NULL, modbus_pollthread, NULL);
}
else
{
ret = EINVAL;
}
return ret;
}
/****************************************************************************
* Name: modbus_showusage
*
* Description:
* Show usage of the demo program and exit
*
****************************************************************************/
static void modbus_showusage(FAR const char *progname, int exitcode)
{
printf("USAGE: %s [-d|e|s|q|h]\n\n", progname);
printf("Where:\n");
printf(" -d : Disable protocol stack\n");
printf(" -e : Enable the protocol stack\n");
printf(" -s : Show current status\n");
printf(" -q : Quit application\n");
printf(" -h : Show this information\n");
printf("\n");
exit(exitcode);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: user_start/modbus_main
*
* Description:
* This is the main entry point to the demo program
*
****************************************************************************/
int MAIN_NAME(int argc, char *argv[])
{
int option;
int ret;
/* Handle command line arguments */
g_modbus.quit = FALSE;
while ((option = getopt(argc, argv, "desqh")) != ERROR)
{
switch (option)
{
case 'd': /* Disable protocol stack */
(void)pthread_mutex_lock(&g_modbus.lock);
g_modbus.threadstate = SHUTDOWN;
(void)pthread_mutex_unlock(&g_modbus.lock);
break;
case 'e': /* Enable the protocol stack */
{
ret = modbus_create_pollthread();
if (ret != OK)
{
fprintf(stderr, MAIN_NAME_STRING
"ERROR: modbus_create_pollthread failed: %d\n", ret);
exit(EXIT_FAILURE);
}
}
break;
case 's': /* Show current status */
switch (g_modbus.threadstate)
{
case RUNNING:
printf(MAIN_NAME_STRING "Protocol stack is running\n");
break;
case STOPPED:
printf(MAIN_NAME_STRING "Protocol stack is stopped\n");
break;
case SHUTDOWN:
printf(MAIN_NAME_STRING "Protocol stack is shutting down\n");
break;
default:
fprintf(stderr, MAIN_NAME_STRING
"ERROR: Invalid thread state: %d\n",
g_modbus.threadstate);
break;
}
break;
case 'q': /* Quit application */
g_modbus.quit = TRUE;
pthread_kill(g_modbus.threadid, 9);
break;
case 'h': /* Show help info */
modbus_showusage(argv[0], EXIT_SUCCESS);
break;
default:
fprintf(stderr, MAIN_NAME_STRING
"ERROR: Unrecognized option: '%c'\n", option);
modbus_showusage(argv[0], EXIT_FAILURE);
break;
}
}
return EXIT_SUCCESS;
}
/****************************************************************************
* Name: eMBRegInputCB
*
* Description:
* Required FreeModBus callback function
*
****************************************************************************/
eMBErrorCode eMBRegInputCB(uint8_t *buffer, uint16_t address, uint16_t nregs)
{
eMBErrorCode mberr = MB_ENOERR;
int index;
if ((address >= CONFIG_EXAMPLES_MODBUS_REG_INPUT_START) &&
(address + nregs <=
CONFIG_EXAMPLES_MODBUS_REG_INPUT_START +
CONFIG_EXAMPLES_MODBUS_REG_INPUT_NREGS))
{
index = (int)(address - CONFIG_EXAMPLES_MODBUS_REG_INPUT_START);
while (nregs > 0)
{
*buffer++ = (uint8_t)(g_modbus.reginput[index] >> 8);
*buffer++ = (uint8_t)(g_modbus.reginput[index] & 0xff);
index++;
nregs--;
}
}
else
{
mberr = MB_ENOREG;
}
return mberr;
}
/****************************************************************************
* Name: eMBRegHoldingCB
*
* Description:
* Required FreeModBus callback function
*
****************************************************************************/
eMBErrorCode eMBRegHoldingCB(uint8_t *buffer, uint16_t address, uint16_t nregs,
eMBRegisterMode mode)
{
eMBErrorCode mberr = MB_ENOERR;
int index;
if ((address >= CONFIG_EXAMPLES_MODBUS_REG_HOLDING_START) &&
(address + nregs <=
CONFIG_EXAMPLES_MODBUS_REG_HOLDING_START +
CONFIG_EXAMPLES_MODBUS_REG_HOLDING_NREGS))
{
index = (int)(address - CONFIG_EXAMPLES_MODBUS_REG_HOLDING_START);
switch (mode)
{
/* Pass current register values to the protocol stack. */
case MB_REG_READ:
while (nregs > 0)
{
*buffer++ = (uint8_t)(g_modbus.regholding[index] >> 8);
*buffer++ = (uint8_t)(g_modbus.regholding[index] & 0xff);
index++;
nregs--;
}
break;
/* Update current register values with new values from the
* protocol stack.
*/
case MB_REG_WRITE:
while (nregs > 0)
{
g_modbus.regholding[index] = *buffer++ << 8;
g_modbus.regholding[index] |= *buffer++;
index++;
nregs--;
}
break;
}
}
else
{
mberr = MB_ENOREG;
}
return mberr;
}
/****************************************************************************
* Name: eMBRegCoilsCB
*
* Description:
* Required FreeModBus callback function
*
****************************************************************************/
eMBErrorCode eMBRegCoilsCB(uint8_t *buffer, uint16_t address, uint16_t ncoils,
eMBRegisterMode mode)
{
return MB_ENOREG;
}
/****************************************************************************
* Name: eMBRegDiscreteCB
*
* Description:
* Required FreeModBus callback function
*
****************************************************************************/
eMBErrorCode eMBRegDiscreteCB(uint8_t *buffer, uint16_t address, uint16_t ndiscrete)
{
return MB_ENOREG;
}

View File

@ -31,7 +31,8 @@
#ifndef _MB_H
#define _MB_H
#include "port.h"
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
PR_BEGIN_EXTERN_C
@ -121,7 +122,6 @@ typedef enum
MB_ETIMEDOUT /*!< timeout error occurred. */
} eMBErrorCode;
/* ----------------------- Function prototypes ------------------------------*/
/*! \ingroup modbus
* \brief Initialize the Modbus protocol stack.
@ -148,8 +148,8 @@ typedef enum
* slave addresses are in the range 1 - 247.
* - eMBErrorCode::MB_EPORTERR IF the porting layer returned an error.
*/
eMBErrorCode eMBInit( eMBMode eMode, UCHAR ucSlaveAddress,
UCHAR ucPort, ULONG ulBaudRate, eMBParity eParity );
eMBErrorCode eMBInit( eMBMode eMode, uint8_t ucSlaveAddress,
uint8_t ucPort, uint32_t ulBaudRate, eMBParity eParity );
/*! \ingroup modbus
* \brief Initialize the Modbus protocol stack for Modbus TCP.
@ -165,7 +165,7 @@ eMBErrorCode eMBInit( eMBMode eMode, UCHAR ucSlaveAddress,
* slave addresses are in the range 1 - 247.
* - eMBErrorCode::MB_EPORTERR IF the porting layer returned an error.
*/
eMBErrorCode eMBTCPInit( USHORT usTCPPort );
eMBErrorCode eMBTCPInit( uint16_t usTCPPort );
/*! \ingroup modbus
* \brief Release resources used by the protocol stack.
@ -228,7 +228,7 @@ eMBErrorCode eMBPoll( void );
*
* \param ucSlaveID Values is returned in the <em>Slave ID</em> byte of the
* <em>Report Slave ID</em> response.
* \param xIsRunning If TRUE the <em>Run Indicator Status</em> byte is set to 0xFF.
* \param xIsRunning If true the <em>Run Indicator Status</em> byte is set to 0xFF.
* otherwise the <em>Run Indicator Status</em> is 0x00.
* \param pucAdditional Values which should be returned in the <em>Additional</em>
* bytes of the <em> Report Slave ID</em> response.
@ -238,9 +238,9 @@ eMBErrorCode eMBPoll( void );
* is too small it returns eMBErrorCode::MB_ENORES. Otherwise
* it returns eMBErrorCode::MB_ENOERR.
*/
eMBErrorCode eMBSetSlaveID( UCHAR ucSlaveID, BOOL xIsRunning,
UCHAR const *pucAdditional,
USHORT usAdditionalLen );
eMBErrorCode eMBSetSlaveID( uint8_t ucSlaveID, bool xIsRunning,
uint8_t const *pucAdditional,
uint16_t usAdditionalLen );
/*! \ingroup modbus
* \brief Registers a callback handler for a given function code.
@ -262,7 +262,7 @@ eMBErrorCode eMBSetSlaveID( UCHAR ucSlaveID, BOOL xIsRunning,
* case the values in config.h should be adjusted. If the argument was not
* valid it returns eMBErrorCode::MB_EINVAL.
*/
eMBErrorCode eMBRegisterCB( UCHAR ucFunctionCode,
eMBErrorCode eMBRegisterCB( uint8_t ucFunctionCode,
pxMBFunctionHandler pxHandler );
/* ----------------------- Callback -----------------------------------------*/
@ -309,8 +309,8 @@ eMBErrorCode eMBRegisterCB( UCHAR ucFunctionCode,
* - eMBErrorCode::MB_EIO If an unrecoverable error occurred. In this case
* a <b>SLAVE DEVICE FAILURE</b> exception is sent as a response.
*/
eMBErrorCode eMBRegInputCB( UCHAR * pucRegBuffer, USHORT usAddress,
USHORT usNRegs );
eMBErrorCode eMBRegInputCB( uint8_t * pucRegBuffer, uint16_t usAddress,
uint16_t usNRegs );
/*! \ingroup modbus_registers
* \brief Callback function used if a <em>Holding Register</em> value is
@ -344,8 +344,8 @@ eMBErrorCode eMBRegInputCB( UCHAR * pucRegBuffer, USHORT usAddress,
* - eMBErrorCode::MB_EIO If an unrecoverable error occurred. In this case
* a <b>SLAVE DEVICE FAILURE</b> exception is sent as a response.
*/
eMBErrorCode eMBRegHoldingCB( UCHAR * pucRegBuffer, USHORT usAddress,
USHORT usNRegs, eMBRegisterMode eMode );
eMBErrorCode eMBRegHoldingCB( uint8_t * pucRegBuffer, uint16_t usAddress,
uint16_t usNRegs, eMBRegisterMode eMode );
/*! \ingroup modbus_registers
* \brief Callback function used if a <em>Coil Register</em> value is
@ -379,8 +379,8 @@ eMBErrorCode eMBRegHoldingCB( UCHAR * pucRegBuffer, USHORT usAddress,
* - eMBErrorCode::MB_EIO If an unrecoverable error occurred. In this case
* a <b>SLAVE DEVICE FAILURE</b> exception is sent as a response.
*/
eMBErrorCode eMBRegCoilsCB( UCHAR * pucRegBuffer, USHORT usAddress,
USHORT usNCoils, eMBRegisterMode eMode );
eMBErrorCode eMBRegCoilsCB( uint8_t * pucRegBuffer, uint16_t usAddress,
uint16_t usNCoils, eMBRegisterMode eMode );
/*! \ingroup modbus_registers
* \brief Callback function used if a <em>Input Discrete Register</em> value is
@ -408,8 +408,8 @@ eMBErrorCode eMBRegCoilsCB( UCHAR * pucRegBuffer, USHORT usAddress,
* - eMBErrorCode::MB_EIO If an unrecoverable error occurred. In this case
* a <b>SLAVE DEVICE FAILURE</b> exception is sent as a response.
*/
eMBErrorCode eMBRegDiscreteCB( UCHAR * pucRegBuffer, USHORT usAddress,
USHORT usNDiscrete );
eMBErrorCode eMBRegDiscreteCB( uint8_t * pucRegBuffer, uint16_t usAddress,
uint16_t usNDiscrete );
#ifdef __cplusplus
PR_END_EXTERN_C

View File

@ -71,13 +71,13 @@ typedef void ( *pvMBFrameStart ) ( void );
typedef void ( *pvMBFrameStop ) ( void );
typedef eMBErrorCode( *peMBFrameReceive ) ( UCHAR * pucRcvAddress,
UCHAR ** pucFrame,
USHORT * pusLength );
typedef eMBErrorCode( *peMBFrameReceive ) ( uint8_t * pucRcvAddress,
uint8_t ** pucFrame,
uint16_t * pusLength );
typedef eMBErrorCode( *peMBFrameSend ) ( UCHAR slaveAddress,
const UCHAR * pucFrame,
USHORT usLength );
typedef eMBErrorCode( *peMBFrameSend ) ( uint8_t slaveAddress,
const uint8_t * pucFrame,
uint16_t usLength );
typedef void( *pvMBFrameClose ) ( void );

View File

@ -35,43 +35,43 @@
PR_BEGIN_EXTERN_C
#endif
#ifdef CONFIG_MB_FUNC_OTHER_REP_SLAVEID_BUF
eMBException eMBFuncReportSlaveID( UCHAR * pucFrame, USHORT * usLen );
eMBException eMBFuncReportSlaveID( uint8_t * pucFrame, uint16_t * usLen );
#endif
#ifdef CONFIG_MB_FUNC_READ_INPUT_ENABLED
eMBException eMBFuncReadInputRegister( UCHAR * pucFrame, USHORT * usLen );
eMBException eMBFuncReadInputRegister( uint8_t * pucFrame, uint16_t * usLen );
#endif
#ifdef CONFIG_MB_FUNC_READ_HOLDING_ENABLED
eMBException eMBFuncReadHoldingRegister( UCHAR * pucFrame, USHORT * usLen );
eMBException eMBFuncReadHoldingRegister( uint8_t * pucFrame, uint16_t * usLen );
#endif
#ifdef CONFIG_MB_FUNC_WRITE_HOLDING_ENABLED
eMBException eMBFuncWriteHoldingRegister( UCHAR * pucFrame, USHORT * usLen );
eMBException eMBFuncWriteHoldingRegister( uint8_t * pucFrame, uint16_t * usLen );
#endif
#ifdef CONFIG_MB_FUNC_WRITE_MULTIPLE_HOLDING_ENABLED
eMBException eMBFuncWriteMultipleHoldingRegister( UCHAR * pucFrame, USHORT * usLen );
eMBException eMBFuncWriteMultipleHoldingRegister( uint8_t * pucFrame, uint16_t * usLen );
#endif
#ifdef CONFIG_MB_FUNC_READ_COILS_ENABLED
eMBException eMBFuncReadCoils( UCHAR * pucFrame, USHORT * usLen );
eMBException eMBFuncReadCoils( uint8_t * pucFrame, uint16_t * usLen );
#endif
#ifdef CONFIG_MB_FUNC_WRITE_COIL_ENABLED
eMBException eMBFuncWriteCoil( UCHAR * pucFrame, USHORT * usLen );
eMBException eMBFuncWriteCoil( uint8_t * pucFrame, uint16_t * usLen );
#endif
#ifdef CONFIG_MB_FUNC_WRITE_MULTIPLE_COILS_ENABLED
eMBException eMBFuncWriteMultipleCoils( UCHAR * pucFrame, USHORT * usLen );
eMBException eMBFuncWriteMultipleCoils( uint8_t * pucFrame, uint16_t * usLen );
#endif
#ifdef CONFIG_MB_FUNC_READ_DISCRETE_INPUTS_ENABLED
eMBException eMBFuncReadDiscreteInputs( UCHAR * pucFrame, USHORT * usLen );
eMBException eMBFuncReadDiscreteInputs( uint8_t * pucFrame, uint16_t * usLen );
#endif
#ifdef CONFIG_MB_FUNC_READWRITE_HOLDING_ENABLED
eMBException eMBFuncReadWriteMultipleHoldingRegister( UCHAR * pucFrame, USHORT * usLen );
eMBException eMBFuncReadWriteMultipleHoldingRegister( uint8_t * pucFrame, uint16_t * usLen );
#endif
#ifdef __cplusplus

View File

@ -31,6 +31,9 @@
#ifndef _MB_PORT_H
#define _MB_PORT_H
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
PR_BEGIN_EXTERN_C
#endif
@ -60,29 +63,29 @@ typedef enum
} eMBParity;
/* ----------------------- Supporting functions -----------------------------*/
BOOL xMBPortEventInit( void );
bool xMBPortEventInit( void );
BOOL xMBPortEventPost( eMBEventType eEvent );
bool xMBPortEventPost( eMBEventType eEvent );
BOOL xMBPortEventGet( /*@out@ */ eMBEventType * eEvent );
bool xMBPortEventGet( /*@out@ */ eMBEventType * eEvent );
/* ----------------------- Serial port functions ----------------------------*/
BOOL xMBPortSerialInit( UCHAR ucPort, ULONG ulBaudRate,
UCHAR ucDataBits, eMBParity eParity );
bool xMBPortSerialInit( uint8_t ucPort, uint32_t ulBaudRate,
uint8_t ucDataBits, eMBParity eParity );
void vMBPortClose( void );
void xMBPortSerialClose( void );
void vMBPortSerialEnable( BOOL xRxEnable, BOOL xTxEnable );
void vMBPortSerialEnable( bool xRxEnable, bool xTxEnable );
BOOL xMBPortSerialGetByte( CHAR * pucByte );
bool xMBPortSerialGetByte( int8_t * pucByte );
BOOL xMBPortSerialPutByte( CHAR ucByte );
bool xMBPortSerialPutByte( int8_t ucByte );
/* ----------------------- Timers functions ---------------------------------*/
BOOL xMBPortTimersInit( USHORT usTimeOut50us );
bool xMBPortTimersInit( uint16_t usTimeOut50us );
void xMBPortTimersClose( void );
@ -90,7 +93,7 @@ void vMBPortTimersEnable( void );
void vMBPortTimersDisable( void );
void vMBPortTimersDelay( USHORT usTimeOutMS );
void vMBPortTimersDelay( uint16_t usTimeOutMS );
/* ----------------------- Callback for the protocol stack ------------------*/
@ -102,26 +105,26 @@ void vMBPortTimersDelay( USHORT usTimeOutMS );
* ASCII transmission layers. In any case a call to xMBPortSerialGetByte()
* must immediately return a new character.
*
* \return <code>TRUE</code> if a event was posted to the queue because
* \return <code>true</code> if a event was posted to the queue because
* a new byte was received. The port implementation should wake up the
* tasks which are currently blocked on the eventqueue.
*/
extern BOOL( *pxMBFrameCBByteReceived ) ( void );
extern bool( *pxMBFrameCBByteReceived ) ( void );
extern BOOL( *pxMBFrameCBTransmitterEmpty ) ( void );
extern bool( *pxMBFrameCBTransmitterEmpty ) ( void );
extern BOOL( *pxMBPortCBTimerExpired ) ( void );
extern bool( *pxMBPortCBTimerExpired ) ( void );
/* ----------------------- TCP port functions -------------------------------*/
BOOL xMBTCPPortInit( USHORT usTCPPort );
bool xMBTCPPortInit( uint16_t usTCPPort );
void vMBTCPPortClose( void );
void vMBTCPPortDisable( void );
BOOL xMBTCPPortGetRequest( UCHAR **ppucMBTCPFrame, USHORT * usTCPLength );
bool xMBTCPPortGetRequest( uint8_t **ppucMBTCPFrame, uint16_t * usTCPLength );
BOOL xMBTCPPortSendResponse( const UCHAR *pucMBTCPFrame, USHORT usTCPLength );
bool xMBTCPPortSendResponse( const uint8_t *pucMBTCPFrame, uint16_t usTCPLength );
#ifdef __cplusplus
PR_END_EXTERN_C

View File

@ -69,11 +69,11 @@ PR_BEGIN_EXTERN_C
MB_EX_GATEWAY_TGT_FAILED = 0x0B
} eMBException;
typedef eMBException( *pxMBFunctionHandler ) ( UCHAR * pucFrame, USHORT * pusLength );
typedef eMBException( *pxMBFunctionHandler ) ( uint8_t * pucFrame, uint16_t * pusLength );
typedef struct
{
UCHAR ucFunctionCode;
uint8_t ucFunctionCode;
pxMBFunctionHandler pxHandler;
} xMBFunctionHandler;

View File

@ -75,8 +75,8 @@ PR_BEGIN_EXTERN_C
* xMBUtilSetBits( ucBits, 8, 8, 0x5A);
* \endcode
*/
void xMBUtilSetBits( UCHAR * ucByteBuf, USHORT usBitOffset,
UCHAR ucNBits, UCHAR ucValues );
void xMBUtilSetBits( uint8_t * ucByteBuf, uint16_t usBitOffset,
uint8_t ucNBits, uint8_t ucValues );
/*! \brief Function to read bits in a byte buffer.
*
@ -90,15 +90,15 @@ void xMBUtilSetBits( UCHAR * ucByteBuf, USHORT usBitOffset,
* than 8.
*
* \code
* UCHAR ucBits[2] = {0, 0};
* UCHAR ucResult;
* uint8_t ucBits[2] = {0, 0};
* uint8_t ucResult;
*
* // Extract the bits 3 - 10.
* ucResult = xMBUtilGetBits( ucBits, 3, 8 );
* \endcode
*/
UCHAR xMBUtilGetBits( UCHAR * ucByteBuf, USHORT usBitOffset,
UCHAR ucNBits );
uint8_t xMBUtilGetBits( uint8_t * ucByteBuf, uint16_t usBitOffset,
uint8_t ucNBits );
/*! @} */

View File

@ -80,11 +80,11 @@ typedef enum
} eMBBytePos;
/* ----------------------- Static functions ---------------------------------*/
static UCHAR prvucMBCHAR2BIN( UCHAR ucCharacter );
static uint8_t prvucMBint8_t2BIN( uint8_t ucCharacter );
static UCHAR prvucMBBIN2CHAR( UCHAR ucByte );
static uint8_t prvucMBBIN2int8_t( uint8_t ucByte );
static UCHAR prvucMBLRC( UCHAR * pucFrame, USHORT usLen );
static uint8_t prvucMBLRC( uint8_t * pucFrame, uint16_t usLen );
/* ----------------------- Static variables ---------------------------------*/
static volatile eMBSndState eSndState;
@ -92,21 +92,21 @@ static volatile eMBRcvState eRcvState;
/* We reuse the Modbus RTU buffer because only one buffer is needed and the
* RTU buffer is bigger. */
extern volatile UCHAR ucRTUBuf[];
static volatile UCHAR *ucASCIIBuf = ucRTUBuf;
extern volatile uint8_t ucRTUBuf[];
static volatile uint8_t *ucASCIIBuf = ucRTUBuf;
static volatile USHORT usRcvBufferPos;
static volatile uint16_t usRcvBufferPos;
static volatile eMBBytePos eBytePos;
static volatile UCHAR *pucSndBufferCur;
static volatile USHORT usSndBufferCount;
static volatile uint8_t *pucSndBufferCur;
static volatile uint16_t usSndBufferCount;
static volatile UCHAR ucLRC;
static volatile UCHAR ucMBLFCharacter;
static volatile uint8_t ucLRC;
static volatile uint8_t ucMBLFCharacter;
/* ----------------------- Start implementation -----------------------------*/
eMBErrorCode
eMBASCIIInit( UCHAR ucSlaveAddress, UCHAR ucPort, ULONG ulBaudRate, eMBParity eParity )
eMBASCIIInit( uint8_t ucSlaveAddress, uint8_t ucPort, uint32_t ulBaudRate, eMBParity eParity )
{
eMBErrorCode eStatus = MB_ENOERR;
( void )ucSlaveAddress;
@ -114,11 +114,11 @@ eMBASCIIInit( UCHAR ucSlaveAddress, UCHAR ucPort, ULONG ulBaudRate, eMBParity eP
ENTER_CRITICAL_SECTION( );
ucMBLFCharacter = MB_ASCII_DEFAULT_LF;
if( xMBPortSerialInit( ucPort, ulBaudRate, 7, eParity ) != TRUE )
if( xMBPortSerialInit( ucPort, ulBaudRate, 7, eParity ) != true )
{
eStatus = MB_EPORTERR;
}
else if( xMBPortTimersInit( CONFIG_MB_ASCII_TIMEOUT_SEC * 20000UL ) != TRUE )
else if( xMBPortTimersInit( CONFIG_MB_ASCII_TIMEOUT_SEC * 20000UL ) != true )
{
eStatus = MB_EPORTERR;
}
@ -132,7 +132,7 @@ void
eMBASCIIStart( void )
{
ENTER_CRITICAL_SECTION( );
vMBPortSerialEnable( TRUE, FALSE );
vMBPortSerialEnable( true, false );
eRcvState = STATE_RX_IDLE;
EXIT_CRITICAL_SECTION( );
@ -144,13 +144,13 @@ void
eMBASCIIStop( void )
{
ENTER_CRITICAL_SECTION( );
vMBPortSerialEnable( FALSE, FALSE );
vMBPortSerialEnable( false, false );
vMBPortTimersDisable( );
EXIT_CRITICAL_SECTION( );
}
eMBErrorCode
eMBASCIIReceive( UCHAR * pucRcvAddress, UCHAR ** pucFrame, USHORT * pusLength )
eMBASCIIReceive( uint8_t * pucRcvAddress, uint8_t ** pucFrame, uint16_t * pusLength )
{
eMBErrorCode eStatus = MB_ENOERR;
@ -159,7 +159,7 @@ eMBASCIIReceive( UCHAR * pucRcvAddress, UCHAR ** pucFrame, USHORT * pusLength )
/* Length and CRC check */
if( ( usRcvBufferPos >= MB_SER_PDU_SIZE_MIN )
&& ( prvucMBLRC( ( UCHAR * ) ucASCIIBuf, usRcvBufferPos ) == 0 ) )
&& ( prvucMBLRC( ( uint8_t * ) ucASCIIBuf, usRcvBufferPos ) == 0 ) )
{
/* Save the address field. All frames are passed to the upper layed
* and the decision if a frame is used is done there.
@ -169,10 +169,10 @@ eMBASCIIReceive( UCHAR * pucRcvAddress, UCHAR ** pucFrame, USHORT * pusLength )
/* Total length of Modbus-PDU is Modbus-Serial-Line-PDU minus
* size of address field and CRC checksum.
*/
*pusLength = ( USHORT )( usRcvBufferPos - MB_SER_PDU_PDU_OFF - MB_SER_PDU_SIZE_LRC );
*pusLength = ( uint16_t )( usRcvBufferPos - MB_SER_PDU_PDU_OFF - MB_SER_PDU_SIZE_LRC );
/* Return the start of the Modbus PDU to the caller. */
*pucFrame = ( UCHAR * ) & ucASCIIBuf[MB_SER_PDU_PDU_OFF];
*pucFrame = ( uint8_t * ) & ucASCIIBuf[MB_SER_PDU_PDU_OFF];
}
else
{
@ -183,10 +183,10 @@ eMBASCIIReceive( UCHAR * pucRcvAddress, UCHAR ** pucFrame, USHORT * pusLength )
}
eMBErrorCode
eMBASCIISend( UCHAR ucSlaveAddress, const UCHAR * pucFrame, USHORT usLength )
eMBASCIISend( uint8_t ucSlaveAddress, const uint8_t * pucFrame, uint16_t usLength )
{
eMBErrorCode eStatus = MB_ENOERR;
UCHAR usLRC;
uint8_t usLRC;
ENTER_CRITICAL_SECTION( );
/* Check if the receiver is still in idle state. If not we where too
@ -196,7 +196,7 @@ eMBASCIISend( UCHAR ucSlaveAddress, const UCHAR * pucFrame, USHORT usLength )
if( eRcvState == STATE_RX_IDLE )
{
/* First byte before the Modbus-PDU is the slave address. */
pucSndBufferCur = ( UCHAR * ) pucFrame - 1;
pucSndBufferCur = ( uint8_t * ) pucFrame - 1;
usSndBufferCount = 1;
/* Now copy the Modbus-PDU into the Modbus-Serial-Line-PDU. */
@ -204,12 +204,12 @@ eMBASCIISend( UCHAR ucSlaveAddress, const UCHAR * pucFrame, USHORT usLength )
usSndBufferCount += usLength;
/* Calculate LRC checksum for Modbus-Serial-Line-PDU. */
usLRC = prvucMBLRC( ( UCHAR * ) pucSndBufferCur, usSndBufferCount );
usLRC = prvucMBLRC( ( uint8_t * ) pucSndBufferCur, usSndBufferCount );
ucASCIIBuf[usSndBufferCount++] = usLRC;
/* Activate the transmitter. */
eSndState = STATE_TX_START;
vMBPortSerialEnable( FALSE, TRUE );
vMBPortSerialEnable( false, true );
}
else
{
@ -219,16 +219,16 @@ eMBASCIISend( UCHAR ucSlaveAddress, const UCHAR * pucFrame, USHORT usLength )
return eStatus;
}
BOOL
bool
xMBASCIIReceiveFSM( void )
{
BOOL xNeedPoll = FALSE;
UCHAR ucByte;
UCHAR ucResult;
bool xNeedPoll = false;
uint8_t ucByte;
uint8_t ucResult;
ASSERT( eSndState == STATE_TX_IDLE );
( void )xMBPortSerialGetByte( ( CHAR * ) & ucByte );
( void )xMBPortSerialGetByte( ( int8_t * ) & ucByte );
switch ( eRcvState )
{
/* A new character is received. If the character is a ':' the input
@ -251,7 +251,7 @@ xMBASCIIReceiveFSM( void )
}
else
{
ucResult = prvucMBCHAR2BIN( ucByte );
ucResult = prvucMBint8_t2BIN( ucByte );
switch ( eBytePos )
{
/* High nibble of the byte comes first. We check for
@ -259,7 +259,7 @@ xMBASCIIReceiveFSM( void )
case BYTE_HIGH_NIBBLE:
if( usRcvBufferPos < MB_SER_PDU_SIZE_MAX )
{
ucASCIIBuf[usRcvBufferPos] = ( UCHAR )( ucResult << 4 );
ucASCIIBuf[usRcvBufferPos] = ( uint8_t )( ucResult << 4 );
eBytePos = BYTE_LOW_NIBBLE;
break;
}
@ -328,11 +328,11 @@ xMBASCIIReceiveFSM( void )
return xNeedPoll;
}
BOOL
bool
xMBASCIITransmitFSM( void )
{
BOOL xNeedPoll = FALSE;
UCHAR ucByte;
bool xNeedPoll = false;
uint8_t ucByte;
ASSERT( eRcvState == STATE_RX_IDLE );
switch ( eSndState )
@ -341,7 +341,7 @@ xMBASCIITransmitFSM( void )
* the character ':'. */
case STATE_TX_START:
ucByte = ':';
xMBPortSerialPutByte( ( CHAR )ucByte );
xMBPortSerialPutByte( ( int8_t )ucByte );
eSndState = STATE_TX_DATA;
eBytePos = BYTE_HIGH_NIBBLE;
break;
@ -356,14 +356,14 @@ xMBASCIITransmitFSM( void )
switch ( eBytePos )
{
case BYTE_HIGH_NIBBLE:
ucByte = prvucMBBIN2CHAR( ( UCHAR )( *pucSndBufferCur >> 4 ) );
xMBPortSerialPutByte( ( CHAR ) ucByte );
ucByte = prvucMBBIN2int8_t( ( uint8_t )( *pucSndBufferCur >> 4 ) );
xMBPortSerialPutByte( ( int8_t ) ucByte );
eBytePos = BYTE_LOW_NIBBLE;
break;
case BYTE_LOW_NIBBLE:
ucByte = prvucMBBIN2CHAR( ( UCHAR )( *pucSndBufferCur & 0x0F ) );
xMBPortSerialPutByte( ( CHAR )ucByte );
ucByte = prvucMBBIN2int8_t( ( uint8_t )( *pucSndBufferCur & 0x0F ) );
xMBPortSerialPutByte( ( int8_t )ucByte );
pucSndBufferCur++;
eBytePos = BYTE_HIGH_NIBBLE;
usSndBufferCount--;
@ -379,7 +379,7 @@ xMBASCIITransmitFSM( void )
/* Finish the frame by sending a LF character. */
case STATE_TX_END:
xMBPortSerialPutByte( ( CHAR )ucMBLFCharacter );
xMBPortSerialPutByte( ( int8_t )ucMBLFCharacter );
/* We need another state to make sure that the CR character has
* been sent. */
eSndState = STATE_TX_NOTIFY;
@ -393,7 +393,7 @@ xMBASCIITransmitFSM( void )
/* Disable transmitter. This prevents another transmit buffer
* empty interrupt. */
vMBPortSerialEnable( TRUE, FALSE );
vMBPortSerialEnable( true, false );
eSndState = STATE_TX_IDLE;
break;
@ -401,14 +401,14 @@ xMBASCIITransmitFSM( void )
* idle state. */
case STATE_TX_IDLE:
/* enable receiver/disable transmitter. */
vMBPortSerialEnable( TRUE, FALSE );
vMBPortSerialEnable( true, false );
break;
}
return xNeedPoll;
}
BOOL
bool
xMBASCIITimerT1SExpired( void )
{
switch ( eRcvState )
@ -428,20 +428,20 @@ xMBASCIITimerT1SExpired( void )
vMBPortTimersDisable( );
/* no context switch required. */
return FALSE;
return false;
}
static UCHAR
prvucMBCHAR2BIN( UCHAR ucCharacter )
static uint8_t
prvucMBint8_t2BIN( uint8_t ucCharacter )
{
if( ( ucCharacter >= '0' ) && ( ucCharacter <= '9' ) )
{
return ( UCHAR )( ucCharacter - '0' );
return ( uint8_t )( ucCharacter - '0' );
}
else if( ( ucCharacter >= 'A' ) && ( ucCharacter <= 'F' ) )
{
return ( UCHAR )( ucCharacter - 'A' + 0x0A );
return ( uint8_t )( ucCharacter - 'A' + 0x0A );
}
else
{
@ -449,16 +449,16 @@ prvucMBCHAR2BIN( UCHAR ucCharacter )
}
}
static UCHAR
prvucMBBIN2CHAR( UCHAR ucByte )