summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-07-24 15:10:21 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-07-24 15:10:21 +0000
commit6d2bcd43a9a90e4be63c1bc29f14882a8db536df (patch)
treed9193962a4631ab2b77486d8192377c05862ee8f /apps
parentbbae2a800dec1c8f22c3a2bf1d95affb68112746 (diff)
downloadnuttx-6d2bcd43a9a90e4be63c1bc29f14882a8db536df.tar.gz
nuttx-6d2bcd43a9a90e4be63c1bc29f14882a8db536df.tar.bz2
nuttx-6d2bcd43a9a90e4be63c1bc29f14882a8db536df.zip
Remove BOTHER
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4972 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps')
-rw-r--r--apps/examples/README.txt2
-rw-r--r--apps/examples/modbus/modbus_main.c5
-rw-r--r--apps/include/modbus/mb.h5
-rw-r--r--apps/include/modbus/mbport.h2
-rw-r--r--apps/modbus/ascii/mbascii.c2
-rw-r--r--apps/modbus/ascii/mbascii.h2
-rw-r--r--apps/modbus/mb.c2
-rw-r--r--apps/modbus/nuttx/portserial.c24
-rw-r--r--apps/modbus/rtu/mbrtu.c2
-rw-r--r--apps/modbus/rtu/mbrtu.h2
10 files changed, 26 insertions, 22 deletions
diff --git a/apps/examples/README.txt b/apps/examples/README.txt
index 0e777eda7..37d63786f 100644
--- a/apps/examples/README.txt
+++ b/apps/examples/README.txt
@@ -491,7 +491,7 @@ examples/modbus
that can be downloaded in its entirety from http://developer.berlios.de/project/showfiles.php?group_id=6120.
CONFIG_EXAMPLES_MODBUS_PORT, Default 0 (for /dev/ttyS0)
- CONFIG_EXAMPLES_MODBUS_BAUD, Default 38400
+ CONFIG_EXAMPLES_MODBUS_BAUD, Default B38400
CONFIG_EXAMPLES_MODBUS_PARITY, Default MB_PAR_EVEN
CONFIG_EXAMPLES_MODBUS_REG_INPUT_START, Default 1000
diff --git a/apps/examples/modbus/modbus_main.c b/apps/examples/modbus/modbus_main.c
index 1250cdf84..bb89c6cbb 100644
--- a/apps/examples/modbus/modbus_main.c
+++ b/apps/examples/modbus/modbus_main.c
@@ -64,6 +64,7 @@
#include <string.h>
#include <unistd.h>
#include <pthread.h>
+#include <termios.h>
#include <signal.h>
#include <errno.h>
@@ -80,7 +81,7 @@
#endif
#ifndef CONFIG_EXAMPLES_MODBUS_BAUD
-# define CONFIG_EXAMPLES_MODBUS_BAUD 38400
+# define CONFIG_EXAMPLES_MODBUS_BAUD B38400
#endif
#ifndef CONFIG_EXAMPLES_MODBUS_PARITY
@@ -192,7 +193,7 @@ static inline int modbus_initialize(void)
* MB_RTU = RTU mode
* 0x0a = Slave address
* CONFIG_EXAMPLES_MODBUS_PORT = port, default=0 (i.e., /dev/ttyS0)
- * CONFIG_EXAMPLES_MODBUS_BAUD = baud, default=38400
+ * CONFIG_EXAMPLES_MODBUS_BAUD = baud, default=B38400
* CONFIG_EXAMPLES_MODBUS_PARITY = parity, default=MB_PAR_EVEN
*/
diff --git a/apps/include/modbus/mb.h b/apps/include/modbus/mb.h
index ed247d163..be7c0df90 100644
--- a/apps/include/modbus/mb.h
+++ b/apps/include/modbus/mb.h
@@ -33,6 +33,7 @@
#include <stdint.h>
#include <stdbool.h>
+#include <termios.h>
#ifdef __cplusplus
PR_BEGIN_EXTERN_C
@@ -136,7 +137,7 @@ typedef enum
* address or to the broadcast address are processed.
* \param ucPort The port to use. E.g. 1 for COM1 on windows. This value
* is platform dependent and some ports simply choose to ignore it.
- * \param ulBaudRate The baudrate. E.g. 19200. Supported baudrates depend
+ * \param ulBaudRate The baudrate. E.g. B19200. Supported baudrates depend
* on the porting layer.
* \param eParity Parity used for serial transmission.
*
@@ -149,7 +150,7 @@ typedef enum
* - eMBErrorCode::MB_EPORTERR IF the porting layer returned an error.
*/
eMBErrorCode eMBInit( eMBMode eMode, uint8_t ucSlaveAddress,
- uint8_t ucPort, uint32_t ulBaudRate, eMBParity eParity );
+ uint8_t ucPort, speed_t ulBaudRate, eMBParity eParity );
/*! \ingroup modbus
* \brief Initialize the Modbus protocol stack for Modbus TCP.
diff --git a/apps/include/modbus/mbport.h b/apps/include/modbus/mbport.h
index e011c15bd..9301d8c90 100644
--- a/apps/include/modbus/mbport.h
+++ b/apps/include/modbus/mbport.h
@@ -71,7 +71,7 @@ bool xMBPortEventGet( /*@out@ */ eMBEventType * eEvent );
/* ----------------------- Serial port functions ----------------------------*/
-bool xMBPortSerialInit( uint8_t ucPort, uint32_t ulBaudRate,
+bool xMBPortSerialInit( uint8_t ucPort, speed_t ulBaudRate,
uint8_t ucDataBits, eMBParity eParity );
void vMBPortClose( void );
diff --git a/apps/modbus/ascii/mbascii.c b/apps/modbus/ascii/mbascii.c
index 455e1a7cb..4b8a56e01 100644
--- a/apps/modbus/ascii/mbascii.c
+++ b/apps/modbus/ascii/mbascii.c
@@ -106,7 +106,7 @@ static volatile uint8_t ucMBLFCharacter;
/* ----------------------- Start implementation -----------------------------*/
eMBErrorCode
-eMBASCIIInit( uint8_t ucSlaveAddress, uint8_t ucPort, uint32_t ulBaudRate, eMBParity eParity )
+eMBASCIIInit( uint8_t ucSlaveAddress, uint8_t ucPort, speed_t ulBaudRate, eMBParity eParity )
{
eMBErrorCode eStatus = MB_ENOERR;
( void )ucSlaveAddress;
diff --git a/apps/modbus/ascii/mbascii.h b/apps/modbus/ascii/mbascii.h
index 8ac0000e1..96001404a 100644
--- a/apps/modbus/ascii/mbascii.h
+++ b/apps/modbus/ascii/mbascii.h
@@ -37,7 +37,7 @@ PR_BEGIN_EXTERN_C
#ifdef CONFIG_MB_ASCII_ENABLED
eMBErrorCode eMBASCIIInit( uint8_t slaveAddress, uint8_t ucPort,
- uint32_t ulBaudRate, eMBParity eParity );
+ speed_t ulBaudRate, eMBParity eParity );
void eMBASCIIStart( void );
void eMBASCIIStop( void );
diff --git a/apps/modbus/mb.c b/apps/modbus/mb.c
index 0e5c8a920..209b1274c 100644
--- a/apps/modbus/mb.c
+++ b/apps/modbus/mb.c
@@ -130,7 +130,7 @@ static xMBFunctionHandler xFuncHandlers[CONFIG_MB_FUNC_HANDLERS_MAX] = {
/* ----------------------- Start implementation -----------------------------*/
eMBErrorCode
-eMBInit( eMBMode eMode, uint8_t ucSlaveAddress, uint8_t ucPort, uint32_t ulBaudRate, eMBParity eParity )
+eMBInit( eMBMode eMode, uint8_t ucSlaveAddress, uint8_t ucPort, speed_t ulBaudRate, eMBParity eParity )
{
eMBErrorCode eStatus = MB_ENOERR;
diff --git a/apps/modbus/nuttx/portserial.c b/apps/modbus/nuttx/portserial.c
index bf1f4526a..68c02830a 100644
--- a/apps/modbus/nuttx/portserial.c
+++ b/apps/modbus/nuttx/portserial.c
@@ -106,7 +106,7 @@ void vMBPortSerialEnable(bool bEnableRx, bool bEnableTx)
}
}
-bool xMBPortSerialInit(uint8_t ucPort, uint32_t ulBaudRate,
+bool xMBPortSerialInit(uint8_t ucPort, speed_t ulBaudRate,
uint8_t ucDataBits, eMBParity eParity)
{
char szDevice[16];
@@ -164,18 +164,20 @@ bool xMBPortSerialInit(uint8_t ucPort, uint32_t ulBaudRate,
if (bStatus)
{
- /* Set the new baud using the (non-standard) BOTHER mechanism
- * supported by NuttX.
+ /* Set the new baud. The following might be compatible with other
+ * OSs for the following reason.
+ *
+ * (1) In NuttX, cfset[i|o]speed always return OK so failures will
+ * really only be reported when tcsetattr() is called.
+ * (2) NuttX does not support separate input and output speeds so it
+ * is not necessary to call both cfsetispeed() and
+ * cfsetospeed(), and
+ * (3) In NuttX, the input value to cfiset[i|o]speed is not
+ * encoded, but is the absolute baud value. The following might
+ * not be
*/
-
- xNewTIO.c_ispeed = (speed_t)ulBaudRate;
- xNewTIO.c_ospeed = (speed_t)ulBaudRate;
- /* NOTE: In NuttX, cfset[i|o]speed always return OK. Failures will
- * only be reported when tcsetattr() is called.
- */
-
- if (cfsetispeed(&xNewTIO, BOTHER) != 0 || cfsetospeed(&xNewTIO, BOTHER) != 0)
+ if (cfsetispeed(&xNewTIO, ulBaudRate) != 0 /* || cfsetospeed(&xNewTIO, ulBaudRate) != 0 */)
{
vMBPortLog(MB_LOG_ERROR, "SER-INIT", "Can't set baud rate %ld for port %s: %d\n",
ulBaudRate, szDevice, errno);
diff --git a/apps/modbus/rtu/mbrtu.c b/apps/modbus/rtu/mbrtu.c
index 1c2f02a8b..196473c17 100644
--- a/apps/modbus/rtu/mbrtu.c
+++ b/apps/modbus/rtu/mbrtu.c
@@ -80,7 +80,7 @@ static volatile uint16_t usRcvBufferPos;
/* ----------------------- Start implementation -----------------------------*/
eMBErrorCode
-eMBRTUInit( uint8_t ucSlaveAddress, uint8_t ucPort, uint32_t ulBaudRate, eMBParity eParity )
+eMBRTUInit( uint8_t ucSlaveAddress, uint8_t ucPort, speed_t ulBaudRate, eMBParity eParity )
{
eMBErrorCode eStatus = MB_ENOERR;
uint32_t usTimerT35_50us;
diff --git a/apps/modbus/rtu/mbrtu.h b/apps/modbus/rtu/mbrtu.h
index 6a14654f0..ca35b94a7 100644
--- a/apps/modbus/rtu/mbrtu.h
+++ b/apps/modbus/rtu/mbrtu.h
@@ -34,7 +34,7 @@
#ifdef __cplusplus
PR_BEGIN_EXTERN_C
#endif
- eMBErrorCode eMBRTUInit( uint8_t slaveAddress, uint8_t ucPort, uint32_t ulBaudRate,
+ eMBErrorCode eMBRTUInit( uint8_t slaveAddress, uint8_t ucPort, speed_t ulBaudRate,
eMBParity eParity );
void eMBRTUStart( void );
void eMBRTUStop( void );