Remove BOTHER
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4972 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
parent
908eb20483
commit
9d5fded19b
|
@ -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
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
||||
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.
|
||||
/* 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
|
||||
*/
|
||||
|
||||
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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -3054,8 +3054,10 @@
|
|||
standard) c_ispeed and c_ospeed baud values may be accessed directly.
|
||||
* arch/arm/src/stm32/stm32_serial.c: Add minimal termios support for the STM32
|
||||
(BOTHER style baud settings only). Contributed by Mike Smith.
|
||||
* configs/lpc4343-xplorer/src: Clean up SPIFI-library based build to that it
|
||||
actually works.
|
||||
* arch/arm/src/lpc43xx/lpc43_spifi.c: Add support for verification to writes.
|
||||
Add debug option to dump buffers. Several bugfixes... almost works.
|
||||
* configs/lpc4343-xplorer/src: Clean up SPIFI-library based build to that it
|
||||
actually works.
|
||||
* arch/arm/src/lpc43xx/lpc43_spifi.c: Add support for verification to writes.
|
||||
Add debug option to dump buffers. Several bugfixes... almost works.
|
||||
* include/termios.h, lib/termios/*, and arch/arm/src/stm32/stm32_serial.c: :
|
||||
BOTHER is gone again.
|
||||
|
||||
|
|
|
@ -1248,15 +1248,9 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
|||
break;
|
||||
}
|
||||
|
||||
/* TODO: (1) Note that only the BOTHER baud is returned; (2) Other
|
||||
* termios fields are not yet initialized. Here we also exploit the
|
||||
* internal knowledge that ctfsetospeed() is equivalent to
|
||||
* cfsetispeed().
|
||||
*/
|
||||
/* TODO: Other termios fields are not yet returned. */
|
||||
|
||||
cfsetispeed(termiosp, BOTHER);
|
||||
termiosp->c_ispeed = priv->baud;
|
||||
termiosp->c_ospeed = priv->baud;
|
||||
termiosp->c_speed = priv->baud;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1270,19 +1264,9 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
|||
break;
|
||||
}
|
||||
|
||||
/* TODO: Only the BOTHER speed setting is supported. Here we
|
||||
* also exploit the internal knowledge that ctfgetospeed() is
|
||||
* equivalent to cfgetispeed().
|
||||
*/
|
||||
/* TODO: Handle other termios settings. */
|
||||
|
||||
if (cfgetospeed(termiosp) != BOTHER ||
|
||||
termiosp->c_ispeed != termiosp->c_ospeed)
|
||||
{
|
||||
ret = -ENOSYS;
|
||||
break;
|
||||
}
|
||||
|
||||
priv->baud = termiosp->c_ispeed;
|
||||
priv->baud = termiosp->c_speed;
|
||||
up_setspeed(dev);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1107,7 +1107,7 @@ CONFIG_EXAMPLE_BUTTONS_NAME1="SW2"
|
|||
# examples/modbus
|
||||
#
|
||||
# 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
|
||||
|
@ -1116,7 +1116,7 @@ CONFIG_EXAMPLE_BUTTONS_NAME1="SW2"
|
|||
# CONFIG_EXAMPLES_MODBUS_REG_HOLDING_NREGS, Default 130
|
||||
#
|
||||
CONFIG_EXAMPLES_MODBUS_PORT=1
|
||||
CONFIG_EXAMPLES_MODBUS_BAUD=9600
|
||||
CONFIG_EXAMPLES_MODBUS_BAUD=B9600
|
||||
|
||||
#
|
||||
# Settings for examples/usbserial
|
||||
|
|
|
@ -98,19 +98,17 @@
|
|||
|
||||
/* Control Modes (c_cflag in the termios structure) */
|
||||
|
||||
#define CBAUD (0x0f) /* Bits 0-3: baud */
|
||||
#define CBAUDEX (1 << 4) /* Bit 4: Extended baud */
|
||||
#define CSIZE (3 << 5) /* Bits 5-6: Character size: */
|
||||
# define CS5 (0 << 5) /* 5 bits */
|
||||
# define CS6 (1 << 5) /* 6 bits */
|
||||
# define CS7 (2 << 5) /* 7 bits */
|
||||
# define CS8 (3 << 5) /* 8 bits */
|
||||
#define CSTOPB (1 << 7) /* Bit 7: Send two stop bits, else one */
|
||||
#define CREAD (1 << 8) /* Bit 8: Enable receiver */
|
||||
#define PARENB (1 << 9) /* Bit 9: Parity enable */
|
||||
#define PARODD (1 << 10) /* Bit 10: Odd parity, else even */
|
||||
#define HUPCL (1 << 11) /* Bit 11: Hang up on last close */
|
||||
#define CLOCAL (1 << 12) /* Bit 12: Ignore modem status lines */
|
||||
#define CSIZE (3 << 0) /* Bits 0-1: Character size: */
|
||||
# define CS5 (0 << 0) /* 5 bits */
|
||||
# define CS6 (1 << 0) /* 6 bits */
|
||||
# define CS7 (2 << 0) /* 7 bits */
|
||||
# define CS8 (3 << 0) /* 8 bits */
|
||||
#define CSTOPB (1 << 2) /* Bit 2: Send two stop bits, else one */
|
||||
#define CREAD (1 << 3) /* Bit 3: Enable receiver */
|
||||
#define PARENB (1 << 4) /* Bit 4: Parity enable */
|
||||
#define PARODD (1 << 5) /* Bit 5: Odd parity, else even */
|
||||
#define HUPCL (1 << 6) /* Bit 6: Hang up on last close */
|
||||
#define CLOCAL (1 << 7) /* Bit 7: Ignore modem status lines */
|
||||
|
||||
/* Local Modes (c_lflag in the termios structure) */
|
||||
|
||||
|
@ -142,41 +140,38 @@
|
|||
|
||||
/* Baud Rate Selection. */
|
||||
|
||||
#define B0 (0x00) /* Hang up */
|
||||
#define B50 (0x01) /* 50 baud */
|
||||
#define B75 (0x02) /* 75 baud */
|
||||
#define B110 (0x03) /* 110 baud */
|
||||
#define B134 (0x04) /* 134.5 baud */
|
||||
#define B150 (0x05) /* 150 baud */
|
||||
#define B200 (0x06) /* 200 baud */
|
||||
#define B300 (0x07) /* 300 baud */
|
||||
#define B600 (0x08) /* 600 baud */
|
||||
#define B1200 (0x09) /* 1,200 baud */
|
||||
#define B1800 (0x0a) /* 1,800 baud */
|
||||
#define B2400 (0x0b) /* 2,400 baud */
|
||||
#define B4800 (0x0c) /* 4,800 baud */
|
||||
#define B9600 (0x0d) /* 9,600 baud */
|
||||
#define B19200 (0x0e) /* 19,200 baud */
|
||||
#define B38400 (0x0f) /* 38,400 baud */
|
||||
#define B0 0 /* Hang up */
|
||||
#define B50 50 /* 50 baud */
|
||||
#define B75 75 /* 75 baud */
|
||||
#define B110 110 /* 110 baud */
|
||||
#define B134 134 /* 134.5 baud */
|
||||
#define B150 150 /* 150 baud */
|
||||
#define B200 200 /* 200 baud */
|
||||
#define B300 300 /* 300 baud */
|
||||
#define B600 600 /* 600 baud */
|
||||
#define B1200 1200 /* 1,200 baud */
|
||||
#define B1800 1800 /* 1,800 baud */
|
||||
#define B2400 2400 /* 2,400 baud */
|
||||
#define B4800 4800 /* 4,800 baud */
|
||||
#define B9600 9600 /* 9,600 baud */
|
||||
#define B19200 19200 /* 19,200 baud */
|
||||
#define B38400 38400 /* 38,400 baud */
|
||||
|
||||
/* "Extended" baud rates above 37K include the CBAUDEX bit */
|
||||
|
||||
#define BOTHER (CBAUDEX | 0x00) /* Use baud values in c_ispeed and c_ospeed */
|
||||
#define B57600 (CBAUDEX | 0x01) /* 57,600 baud */
|
||||
#define B115200 (CBAUDEX | 0x02) /* 115,200 baud */
|
||||
#define B128000 (CBAUDEX | 0x03) /* 128,000 baud */
|
||||
#define B230400 (CBAUDEX | 0x04) /* 230,400 baud */
|
||||
#define B256000 (CBAUDEX | 0x05) /* 256,000 baud */
|
||||
#define B460800 (CBAUDEX | 0x06) /* 460,800 baud */
|
||||
#define B500000 (CBAUDEX | 0x07) /* 500,000 baud */
|
||||
#define B576000 (CBAUDEX | 0x08) /* 576,000 baud */
|
||||
#define B921600 (CBAUDEX | 0x09) /* 921,600 baud */
|
||||
#define B1000000 (CBAUDEX | 0x0a) /* 1,000,000 baud */
|
||||
#define B1152000 (CBAUDEX | 0x0b) /* 1,152,000 baud */
|
||||
#define B1500000 (CBAUDEX | 0x0c) /* 1,500,000 baud */
|
||||
#define B2000000 (CBAUDEX | 0x0d) /* 2,000,000 baud */
|
||||
#define B2500000 (CBAUDEX | 0x0e) /* 2,500,000 baud */
|
||||
#define B3000000 (CBAUDEX | 0x0f) /* 3,000,000 baud */
|
||||
#define B57600 57600 /* 57,600 baud */
|
||||
#define B115200 115200 /* 115,200 baud */
|
||||
#define B128000 128000 /* 128,000 baud */
|
||||
#define B230400 230400 /* 230,400 baud */
|
||||
#define B256000 256000 /* 256,000 baud */
|
||||
#define B460800 460800 /* 460,800 baud */
|
||||
#define B500000 500000 /* 500,000 baud */
|
||||
#define B576000 576000 /* 576,000 baud */
|
||||
#define B921600 921600 /* 921,600 baud */
|
||||
#define B1000000 1000000 /* 1,000,000 baud */
|
||||
#define B1152000 1152000 /* 1,152,000 baud */
|
||||
#define B1500000 1500000 /* 1,500,000 baud */
|
||||
#define B2000000 2000000 /* 2,000,000 baud */
|
||||
#define B2500000 2500000 /* 2,500,000 baud */
|
||||
#define B3000000 3000000 /* 3,000,000 baud */
|
||||
|
||||
/* Attribute Selection (used with tcsetattr()) */
|
||||
|
||||
|
@ -222,10 +217,12 @@ struct termios
|
|||
tcflag_t c_lflag; /* Local modes */
|
||||
cc_t c_cc[NCCS]; /* Control chars */
|
||||
|
||||
/* If CBAUD == BOTHER, then these fields hold the input/output BAUD. */
|
||||
/* Implementation specific fields. For portability reasons, these fields
|
||||
* should not be accessed directly, but rather through only through the
|
||||
* cf[set|get][o|i]speed() POSIX interfaces.
|
||||
*/
|
||||
|
||||
speed_t c_ispeed; /* Input speed (non-POSIX)*/
|
||||
speed_t c_ospeed; /* Output speed (non-POSIX) */
|
||||
const speed_t c_speed; /* Input/output speed (non-POSIX)*/
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -65,15 +65,17 @@
|
|||
*
|
||||
* Descripton:
|
||||
* The cfgetispeed() function shall extract the input baud rate from the
|
||||
* termios structure to which the termios_p argument points.
|
||||
* termios structure to which the termiosp argument points.
|
||||
*
|
||||
* This function shall return exactly the value in the termios data
|
||||
* structure, without interpretation.
|
||||
*
|
||||
* NOTE 1: NuttX does not not control input/output baud rates independently
|
||||
* Hense, this function is *identical* to cfgetospeed.
|
||||
* NOTE 2: If this function returns BOTHER and the more flexible input
|
||||
* speed can be obtained from the Linux-like c_ispeed field.
|
||||
* NOTE 2. In Nuttx, the speed_t is defined to be uint32_t and the baud
|
||||
* encodings of termios.h are the actual baud values themselves. Therefore,
|
||||
* any baud value may be returned here... not just those enumerated in
|
||||
* termios.h
|
||||
*
|
||||
* Input Parameters:
|
||||
* termiosp - The termiosp argument is a pointer to a termios structure.
|
||||
|
@ -83,8 +85,8 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
speed_t cfgetispeed(const struct termios *termios_p)
|
||||
speed_t cfgetispeed(FAR const struct termios *termiosp)
|
||||
{
|
||||
DEBUGASSERT(termios_p);
|
||||
return (termios_p->c_cflag & (CBAUD | CBAUDEX));
|
||||
DEBUGASSERT(termiosp);
|
||||
return termiosp->c_speed;
|
||||
}
|
||||
|
|
|
@ -65,15 +65,17 @@
|
|||
*
|
||||
* Descripton:
|
||||
* The cfgetospeed() function shall extract the output baud rate from the
|
||||
* termios structure to which the termios_p argument points.
|
||||
* termios structure to which the termiosp argument points.
|
||||
*
|
||||
* This function shall return exactly the value in the termios data
|
||||
* structure, without interpretation.
|
||||
*
|
||||
* NOTE 1: NuttX does not not control input/output baud rates independently
|
||||
* Hense, this function is *identical* to cfgetispeed.
|
||||
* NOTE 2: If this function returns BOTHER and the more flexible input
|
||||
* speed can be obtained from the Linux-like c_ospeed field.
|
||||
* NOTE 2. In Nuttx, the speed_t is defined to be uint32_t and the baud
|
||||
* encodings of termios.h are the actual baud values themselves. Therefore,
|
||||
* any baud value may be returned here... not just those enumerated in
|
||||
* termios.h
|
||||
*
|
||||
* Input Parameters:
|
||||
* termiosp - The termiosp argument is a pointer to a termios structure.
|
||||
|
@ -83,8 +85,8 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
speed_t cfgetospeed(const struct termios *termios_p)
|
||||
speed_t cfgetospeed(FAR const struct termios *termiosp)
|
||||
{
|
||||
DEBUGASSERT(termios_p);
|
||||
return (termios_p->c_cflag & (CBAUD | CBAUDEX));
|
||||
DEBUGASSERT(termiosp);
|
||||
return termiosp->c_speed;
|
||||
}
|
||||
|
|
|
@ -66,15 +66,19 @@
|
|||
*
|
||||
* Descripton:
|
||||
* The cfsetispeed() function sets the input baud rate stored in the
|
||||
* structure pointed to by termios_p to speed.
|
||||
* structure pointed to by termiosp to speed.
|
||||
*
|
||||
* There is no effect on the baud rates set in the hardware until a
|
||||
* subsequent successful call to tcsetattr() on the same termios structure.
|
||||
*
|
||||
* NOTE 1: NuttX does not not control input/output baud rates independently
|
||||
* Hense, this function is *identical* to cfsetospeed.
|
||||
* NOTE 2: If the specia value BOTHER is used, then the actual input baud
|
||||
* must also be provided in the (non-standard) c_ispeed field.
|
||||
* NOTE 2. In Nuttx, the speed_t is defined to be uint32_t and the baud
|
||||
* encodings of termios.h are the actual baud values themselves. Therefore,
|
||||
* any baud value can be provided as the speed argument here. However, if
|
||||
* you do so, your code will *NOT* be portable to other environments where
|
||||
* speed_t is smaller and where the termios.h baud values are encoded! To
|
||||
* avoid portability issues, use the baud definitions in termios.h!
|
||||
*
|
||||
* Input Parameters:
|
||||
* termiosp - The termiosp argument is a pointer to a termios structure.
|
||||
|
@ -86,11 +90,14 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
int cfsetispeed(struct termios *termios_p, speed_t speed)
|
||||
int cfsetispeed(FAR struct termios *termiosp, speed_t speed)
|
||||
{
|
||||
DEBUGASSERT(termios_p);
|
||||
speed &= (CBAUD | CBAUDEX);
|
||||
termios_p->c_cflag &= ~(CBAUD | CBAUDEX);
|
||||
termios_p->c_cflag |= speed;
|
||||
FAR speed_t *speedp;
|
||||
|
||||
DEBUGASSERT(termiosp);
|
||||
|
||||
speedp = (FAR speed_t *)&termiosp->c_speed;
|
||||
*speedp = speed;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
@ -66,15 +66,19 @@
|
|||
*
|
||||
* Descripton:
|
||||
* The cfsetospeed() function sets the output baud rate stored in the
|
||||
* structure pointed to by termios_p to speed.
|
||||
* structure pointed to by termiosp to speed.
|
||||
*
|
||||
* There is no effect on the baud rates set in the hardware until a
|
||||
* subsequent successful call to tcsetattr() on the same termios structure.
|
||||
*
|
||||
* NOTE 1: NuttX does not not control input/output baud rates independently
|
||||
* Hense, this function is *identical* to cfsetispeed.
|
||||
* NOTE 2: If the specia value BOTHER is used, then the actual input baud
|
||||
* must also be provided in the (non-standard) c_ospeed field.
|
||||
* NOTE 2. In Nuttx, the speed_t is defined to be uint32_t and the baud
|
||||
* encodings of termios.h are the actual baud values themselves. Therefore,
|
||||
* any baud value can be provided as the speed argument here. However, if
|
||||
* you do so, your code will *NOT* be portable to other environments where
|
||||
* speed_t is smaller and where the termios.h baud values are encoded! To
|
||||
* avoid portability issues, use the baud definitions in termios.h!
|
||||
*
|
||||
* Input Parameters:
|
||||
* termiosp - The termiosp argument is a pointer to a termios structure.
|
||||
|
@ -86,11 +90,14 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
int cfsetospeed(struct termios *termios_p, speed_t speed)
|
||||
int cfsetospeed(struct termios *termiosp, speed_t speed)
|
||||
{
|
||||
DEBUGASSERT(termios_p);
|
||||
speed &= (CBAUD | CBAUDEX);
|
||||
termios_p->c_cflag &= ~(CBAUD | CBAUDEX);
|
||||
termios_p->c_cflag |= speed;
|
||||
FAR speed_t *speedp;
|
||||
|
||||
DEBUGASSERT(termiosp);
|
||||
|
||||
speedp = (FAR speed_t *)&termiosp->c_speed;
|
||||
*speedp = speed;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue