apps: Remove the check of CONFIG_SERIAL_TERMIOS
If the code only change c_oflag, c_iflag and c_lflag, not c_cflag in termios. Follow up the change from kernel: https://github.com/apache/nuttx/pull/8843 Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
369c354dc7
commit
86080a110e
@ -49,7 +49,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <termios.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
@ -67,11 +66,8 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
/* Configuration ************************************************************/
|
|
||||||
|
|
||||||
#ifndef CONFIG_SERIAL_TERMIOS
|
/* Configuration ************************************************************/
|
||||||
# error "CONFIG_SERIAL_TERMIOS is needed by modbus example"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CONFIG_EXAMPLES_MODBUS_PORT
|
#ifndef CONFIG_EXAMPLES_MODBUS_PORT
|
||||||
# define CONFIG_EXAMPLES_MODBUS_PORT 0
|
# define CONFIG_EXAMPLES_MODBUS_PORT 0
|
||||||
|
@ -50,10 +50,6 @@
|
|||||||
|
|
||||||
/* modbus master port */
|
/* modbus master port */
|
||||||
|
|
||||||
#ifndef CONFIG_SERIAL_TERMIOS
|
|
||||||
# error "CONFIG_SERIAL_TERMIOS is needed by modbus example"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_EXAMPLES_MODBUSMASTER_PORT
|
#ifdef CONFIG_EXAMPLES_MODBUSMASTER_PORT
|
||||||
# define MBMASTER_PORT CONFIG_EXAMPLES_MODBUSMASTER_PORT
|
# define MBMASTER_PORT CONFIG_EXAMPLES_MODBUSMASTER_PORT
|
||||||
#else
|
#else
|
||||||
|
@ -330,7 +330,6 @@ int main(int argc, FAR char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
/* Enable \n -> \r\n conversion during write */
|
/* Enable \n -> \r\n conversion during write */
|
||||||
|
|
||||||
ret = tcgetattr(termpair.fd_uart, &tio);
|
ret = tcgetattr(termpair.fd_uart, &tio);
|
||||||
@ -347,7 +346,6 @@ int main(int argc, FAR char *argv[])
|
|||||||
fprintf(stderr, "ERROR: tcsetattr() failed: %d\n", errno);
|
fprintf(stderr, "ERROR: tcsetattr() failed: %d\n", errno);
|
||||||
goto error_serial;
|
goto error_serial;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
printf("Starting a new NSH Session using %s\n", buffer);
|
printf("Starting a new NSH Session using %s\n", buffer);
|
||||||
|
|
||||||
|
@ -388,11 +388,7 @@ int FS_opendev(int chn, int infd, int outfd)
|
|||||||
|
|
||||||
g_file[chn] = malloc(sizeof(struct FileStream));
|
g_file[chn] = malloc(sizeof(struct FileStream));
|
||||||
g_file[chn]->dev = 1;
|
g_file[chn]->dev = 1;
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
g_file[chn]->tty = (infd == 0 ? isatty(infd) && isatty(outfd) : 0);
|
g_file[chn]->tty = (infd == 0 ? isatty(infd) && isatty(outfd) : 0);
|
||||||
#else
|
|
||||||
g_file[chn]->tty = 1;
|
|
||||||
#endif
|
|
||||||
g_file[chn]->recLength = 1;
|
g_file[chn]->recLength = 1;
|
||||||
g_file[chn]->infd = infd;
|
g_file[chn]->infd = infd;
|
||||||
g_file[chn]->inSize = 0;
|
g_file[chn]->inSize = 0;
|
||||||
@ -781,12 +777,10 @@ int FS_close(int dev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
int FS_istty(int chn)
|
int FS_istty(int chn)
|
||||||
{
|
{
|
||||||
return (g_file[chn] && g_file[chn]->tty);
|
return (g_file[chn] && g_file[chn]->tty);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
int FS_lock(int chn, off_t offset, off_t length, int mode, int w)
|
int FS_lock(int chn, off_t offset, off_t length, int mode, int w)
|
||||||
{
|
{
|
||||||
|
@ -112,13 +112,7 @@ int FS_openbinaryChn(int chn, const char *name, int mode);
|
|||||||
int FS_freechn(void);
|
int FS_freechn(void);
|
||||||
int FS_flush(int dev);
|
int FS_flush(int dev);
|
||||||
int FS_close(int dev);
|
int FS_close(int dev);
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
int FS_istty(int chn);
|
int FS_istty(int chn);
|
||||||
#else
|
|
||||||
# define FS_istty(chn) (1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int FS_lock(int chn, off_t offset, off_t length, int mode, int w);
|
int FS_lock(int chn, off_t offset, off_t length, int mode, int w);
|
||||||
int FS_truncate(int chn);
|
int FS_truncate(int chn);
|
||||||
void FS_shellmode(int chn);
|
void FS_shellmode(int chn);
|
||||||
|
@ -4163,11 +4163,7 @@ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file)
|
|||||||
b->yy_bs_column = 0;
|
b->yy_bs_column = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
b->yy_is_interactive = file ? (isatty(fileno(file)) > 0) : 0;
|
b->yy_is_interactive = file ? (isatty(fileno(file)) > 0) : 0;
|
||||||
#else
|
|
||||||
b->yy_is_interactive = 1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
errno = oerrno;
|
errno = oerrno;
|
||||||
}
|
}
|
||||||
|
@ -130,12 +130,6 @@ else
|
|||||||
CFLAGS += -DENABLE_PTHREAD=0
|
CFLAGS += -DENABLE_PTHREAD=0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SERIAL_TERMIOS),y)
|
|
||||||
CFLAGS += -DHAVE_TERMIOS_H
|
|
||||||
else
|
|
||||||
CFLAGS += -DHAVE_TERMIOS_H=0
|
|
||||||
endif
|
|
||||||
|
|
||||||
CFLAGS += -DEL_LOG_MAX=$(CONFIG_EMBEDLOG_LOG_MAX)
|
CFLAGS += -DEL_LOG_MAX=$(CONFIG_EMBEDLOG_LOG_MAX)
|
||||||
CFLAGS += -DEL_MEM_LINE_SIZE=$(CONFIG_EMBEDLOG_MEM_LINE_SIZE)
|
CFLAGS += -DEL_MEM_LINE_SIZE=$(CONFIG_EMBEDLOG_MEM_LINE_SIZE)
|
||||||
|
|
||||||
@ -151,6 +145,7 @@ CFLAGS += -DHAVE_ACCESS=0
|
|||||||
CFLAGS += -DENABLE_REENTRANT
|
CFLAGS += -DENABLE_REENTRANT
|
||||||
CFLAGS += -DENABLE_OUT_SYSLOG
|
CFLAGS += -DENABLE_OUT_SYSLOG
|
||||||
CFLAGS += -DHAVE_STAT
|
CFLAGS += -DHAVE_STAT
|
||||||
|
CFLAGS += -DHAVE_TERMIOS_H
|
||||||
CFLAGS += -DHAVE_UNISTD_H
|
CFLAGS += -DHAVE_UNISTD_H
|
||||||
CFLAGS += -DHAVE_FSYNC
|
CFLAGS += -DHAVE_FSYNC
|
||||||
CFLAGS += -DHAVE_FILENO
|
CFLAGS += -DHAVE_FILENO
|
||||||
|
@ -11,7 +11,6 @@ if LOGGING_NXSCOPE
|
|||||||
|
|
||||||
config LOGGING_NXSCOPE_INTF_SERIAL
|
config LOGGING_NXSCOPE_INTF_SERIAL
|
||||||
bool "NxScope serial port interface support"
|
bool "NxScope serial port interface support"
|
||||||
select SERIAL_TERMIOS
|
|
||||||
default n
|
default n
|
||||||
---help---
|
---help---
|
||||||
For details, see logging/nxscope/nxscope_iserial.c
|
For details, see logging/nxscope/nxscope_iserial.c
|
||||||
|
@ -33,14 +33,6 @@
|
|||||||
|
|
||||||
#include <logging/nxscope/nxscope.h>
|
#include <logging/nxscope/nxscope.h>
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef CONFIG_SERIAL_TERMIOS
|
|
||||||
# error Termios support must be enabled
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Type Definition
|
* Private Type Definition
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -214,6 +206,7 @@ int nxscope_ser_init(FAR struct nxscope_intf_s *intf,
|
|||||||
|
|
||||||
tcgetattr(priv->fd, &tio);
|
tcgetattr(priv->fd, &tio);
|
||||||
|
|
||||||
|
#ifdef CONFIG_SERIAL_TERMIOS
|
||||||
/* Configure a baud rate */
|
/* Configure a baud rate */
|
||||||
|
|
||||||
DEBUGASSERT(priv->cfg->baud > 0);
|
DEBUGASSERT(priv->cfg->baud > 0);
|
||||||
@ -224,6 +217,7 @@ int nxscope_ser_init(FAR struct nxscope_intf_s *intf,
|
|||||||
_err("ERROR: failed to set baud rate %d\n", errno);
|
_err("ERROR: failed to set baud rate %d\n", errno);
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Configure RAW mode */
|
/* Configure RAW mode */
|
||||||
|
|
||||||
|
@ -110,9 +110,8 @@ The NuttX-named configuration options that are available include:
|
|||||||
See also other serial settings, in particular:
|
See also other serial settings, in particular:
|
||||||
|
|
||||||
- `CONFIG_SERIAL_TERMIOS` – Serial driver supports `termios.h` interfaces
|
- `CONFIG_SERIAL_TERMIOS` – Serial driver supports `termios.h` interfaces
|
||||||
(`tcsetattr`, `tcflush`, etc.). If this is not defined, then the terminal
|
If this is not defined, then the terminal settings (baud, parity, etc.)
|
||||||
settings (baud, parity, etc.) are not configurable at runtime; serial streams
|
are not configurable at runtime.
|
||||||
will not be flushed when closed.
|
|
||||||
|
|
||||||
## Note
|
## Note
|
||||||
|
|
||||||
|
@ -45,10 +45,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <termios.h>
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
# include <termios.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "port.h"
|
#include "port.h"
|
||||||
|
|
||||||
@ -78,9 +75,7 @@ static uint8_t ucBuffer[BUF_SIZE];
|
|||||||
static int uiRxBufferPos;
|
static int uiRxBufferPos;
|
||||||
static int uiTxBufferPos;
|
static int uiTxBufferPos;
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
static struct termios xOldTIO;
|
static struct termios xOldTIO;
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
@ -182,9 +177,7 @@ void vMBPortSerialEnable(bool bEnableRx, bool bEnableTx)
|
|||||||
|
|
||||||
if (bEnableRx)
|
if (bEnableRx)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
tcflush(iSerialFd, TCIFLUSH);
|
tcflush(iSerialFd, TCIFLUSH);
|
||||||
#endif
|
|
||||||
uiRxBufferPos = 0;
|
uiRxBufferPos = 0;
|
||||||
bRxEnabled = true;
|
bRxEnabled = true;
|
||||||
}
|
}
|
||||||
@ -209,10 +202,7 @@ bool xMBPortSerialInit(uint8_t ucPort, speed_t ulBaudRate,
|
|||||||
{
|
{
|
||||||
char szDevice[16];
|
char szDevice[16];
|
||||||
bool bStatus = true;
|
bool bStatus = true;
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
struct termios xNewTIO;
|
struct termios xNewTIO;
|
||||||
#endif
|
|
||||||
|
|
||||||
snprintf(szDevice, 16, "/dev/ttyS%d", ucPort);
|
snprintf(szDevice, 16, "/dev/ttyS%d", ucPort);
|
||||||
|
|
||||||
@ -222,8 +212,6 @@ bool xMBPortSerialInit(uint8_t ucPort, speed_t ulBaudRate,
|
|||||||
szDevice, errno);
|
szDevice, errno);
|
||||||
bStatus = false;
|
bStatus = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
else if (tcgetattr(iSerialFd, &xOldTIO) != 0)
|
else if (tcgetattr(iSerialFd, &xOldTIO) != 0)
|
||||||
{
|
{
|
||||||
vMBPortLog(MB_LOG_ERROR, "SER-INIT", "Can't get settings from port %s: %d\n",
|
vMBPortLog(MB_LOG_ERROR, "SER-INIT", "Can't get settings from port %s: %d\n",
|
||||||
@ -298,7 +286,6 @@ bool xMBPortSerialInit(uint8_t ucPort, speed_t ulBaudRate,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return bStatus;
|
return bStatus;
|
||||||
}
|
}
|
||||||
@ -321,9 +308,7 @@ void vMBPortClose(void)
|
|||||||
{
|
{
|
||||||
if (iSerialFd != -1)
|
if (iSerialFd != -1)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
tcsetattr(iSerialFd, TCSANOW, &xOldTIO);
|
tcsetattr(iSerialFd, TCSANOW, &xOldTIO);
|
||||||
#endif
|
|
||||||
close(iSerialFd);
|
close(iSerialFd);
|
||||||
iSerialFd = -1;
|
iSerialFd = -1;
|
||||||
}
|
}
|
||||||
|
@ -46,10 +46,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <termios.h>
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
# include <termios.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "port.h"
|
#include "port.h"
|
||||||
|
|
||||||
@ -82,9 +79,7 @@ static uint8_t ucBuffer[BUF_SIZE];
|
|||||||
static int uiRxBufferPos;
|
static int uiRxBufferPos;
|
||||||
static int uiTxBufferPos;
|
static int uiTxBufferPos;
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
static struct termios xOldTIO;
|
static struct termios xOldTIO;
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
@ -186,9 +181,7 @@ void vMBMasterPortSerialEnable(bool bEnableRx, bool bEnableTx)
|
|||||||
|
|
||||||
if (bEnableRx)
|
if (bEnableRx)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
tcflush(iSerialFd, TCIFLUSH);
|
tcflush(iSerialFd, TCIFLUSH);
|
||||||
#endif
|
|
||||||
uiRxBufferPos = 0;
|
uiRxBufferPos = 0;
|
||||||
bRxEnabled = true;
|
bRxEnabled = true;
|
||||||
}
|
}
|
||||||
@ -213,10 +206,7 @@ bool xMBMasterPortSerialInit(uint8_t ucPort, speed_t ulBaudRate,
|
|||||||
{
|
{
|
||||||
char szDevice[16];
|
char szDevice[16];
|
||||||
bool bStatus = true;
|
bool bStatus = true;
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
struct termios xNewTIO;
|
struct termios xNewTIO;
|
||||||
#endif
|
|
||||||
|
|
||||||
snprintf(szDevice, 16, "/dev/ttyS%d", ucPort);
|
snprintf(szDevice, 16, "/dev/ttyS%d", ucPort);
|
||||||
|
|
||||||
@ -227,8 +217,6 @@ bool xMBMasterPortSerialInit(uint8_t ucPort, speed_t ulBaudRate,
|
|||||||
szDevice, errno);
|
szDevice, errno);
|
||||||
bStatus = false;
|
bStatus = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
else if (tcgetattr(iSerialFd, &xOldTIO) != 0)
|
else if (tcgetattr(iSerialFd, &xOldTIO) != 0)
|
||||||
{
|
{
|
||||||
vMBMasterPortLog(MB_LOG_ERROR, "SER-INIT",
|
vMBMasterPortLog(MB_LOG_ERROR, "SER-INIT",
|
||||||
@ -307,7 +295,6 @@ bool xMBMasterPortSerialInit(uint8_t ucPort, speed_t ulBaudRate,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return bStatus;
|
return bStatus;
|
||||||
}
|
}
|
||||||
@ -330,9 +317,7 @@ void vMBMasterPortClose( void )
|
|||||||
{
|
{
|
||||||
if (iSerialFd != -1)
|
if (iSerialFd != -1)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
tcsetattr(iSerialFd, TCSANOW, &xOldTIO);
|
tcsetattr(iSerialFd, TCSANOW, &xOldTIO);
|
||||||
#endif
|
|
||||||
close(iSerialFd);
|
close(iSerialFd);
|
||||||
iSerialFd = -1;
|
iSerialFd = -1;
|
||||||
}
|
}
|
||||||
|
@ -149,11 +149,9 @@ int nsh_login(FAR struct console_stdio_s *pstate)
|
|||||||
#ifdef CONFIG_NSH_PLATFORM_CHALLENGE
|
#ifdef CONFIG_NSH_PLATFORM_CHALLENGE
|
||||||
char challenge[128];
|
char challenge[128];
|
||||||
#endif
|
#endif
|
||||||
|
struct termios cfg;
|
||||||
int ret;
|
int ret;
|
||||||
int i;
|
int i;
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
struct termios cfg;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_NSH_PLATFORM_SKIP_LOGIN
|
#ifdef CONFIG_NSH_PLATFORM_SKIP_LOGIN
|
||||||
if (platform_skip_login() == OK)
|
if (platform_skip_login() == OK)
|
||||||
@ -199,7 +197,6 @@ int nsh_login(FAR struct console_stdio_s *pstate)
|
|||||||
|
|
||||||
/* Disable ECHO if its a tty device */
|
/* Disable ECHO if its a tty device */
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
if (isatty(INFD(pstate)))
|
if (isatty(INFD(pstate)))
|
||||||
{
|
{
|
||||||
if (tcgetattr(INFD(pstate), &cfg) == 0)
|
if (tcgetattr(INFD(pstate), &cfg) == 0)
|
||||||
@ -208,7 +205,6 @@ int nsh_login(FAR struct console_stdio_s *pstate)
|
|||||||
tcsetattr(INFD(pstate), TCSANOW, &cfg);
|
tcsetattr(INFD(pstate), TCSANOW, &cfg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
password[0] = '\0';
|
password[0] = '\0';
|
||||||
ret = readline_fd(pstate->cn_line, CONFIG_NSH_LINELEN,
|
ret = readline_fd(pstate->cn_line, CONFIG_NSH_LINELEN,
|
||||||
@ -216,7 +212,6 @@ int nsh_login(FAR struct console_stdio_s *pstate)
|
|||||||
|
|
||||||
/* Enable echo again after password */
|
/* Enable echo again after password */
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
if (isatty(INFD(pstate)))
|
if (isatty(INFD(pstate)))
|
||||||
{
|
{
|
||||||
if (tcgetattr(INFD(pstate), &cfg) == 0)
|
if (tcgetattr(INFD(pstate), &cfg) == 0)
|
||||||
@ -225,7 +220,6 @@ int nsh_login(FAR struct console_stdio_s *pstate)
|
|||||||
tcsetattr(INFD(pstate), TCSANOW, &cfg);
|
tcsetattr(INFD(pstate), TCSANOW, &cfg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
{
|
{
|
||||||
|
@ -83,11 +83,9 @@ enum parity_mode
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static struct cu_globals_s g_cu;
|
static struct cu_globals_s g_cu;
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
static int fd_std_tty;
|
static int fd_std_tty;
|
||||||
static struct termios g_tio_std;
|
static struct termios g_tio_std;
|
||||||
static struct termios g_tio_dev;
|
static struct termios g_tio_dev;
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
@ -135,6 +133,9 @@ static void sigint(int sig)
|
|||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
#ifdef CONFIG_SERIAL_TERMIOS
|
||||||
static int set_termios(int fd, int rate, enum parity_mode parity,
|
static int set_termios(int fd, int rate, enum parity_mode parity,
|
||||||
int rtscts, int nocrlf)
|
int rtscts, int nocrlf)
|
||||||
|
#else
|
||||||
|
static int set_termios(int fd, int nocrlf)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
int ret;
|
int ret;
|
||||||
@ -142,6 +143,7 @@ static int set_termios(int fd, int rate, enum parity_mode parity,
|
|||||||
|
|
||||||
tio = g_tio_dev;
|
tio = g_tio_dev;
|
||||||
|
|
||||||
|
#ifdef CONFIG_SERIAL_TERMIOS
|
||||||
tio.c_cflag &= ~(PARENB | PARODD | CRTSCTS);
|
tio.c_cflag &= ~(PARENB | PARODD | CRTSCTS);
|
||||||
|
|
||||||
switch (parity)
|
switch (parity)
|
||||||
@ -169,6 +171,7 @@ static int set_termios(int fd, int rate, enum parity_mode parity,
|
|||||||
{
|
{
|
||||||
tio.c_cflag |= CRTS_IFLOW | CCTS_OFLOW;
|
tio.c_cflag |= CRTS_IFLOW | CCTS_OFLOW;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
tio.c_oflag = OPOST;
|
tio.c_oflag = OPOST;
|
||||||
|
|
||||||
@ -228,7 +231,6 @@ static int retrieve_termios(int fd)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static void print_help(void)
|
static void print_help(void)
|
||||||
{
|
{
|
||||||
@ -239,15 +241,13 @@ static void print_help(void)
|
|||||||
" -o: Set odd parity\n"
|
" -o: Set odd parity\n"
|
||||||
" -s: Use given speed (default %d)\n"
|
" -s: Use given speed (default %d)\n"
|
||||||
" -r: Disable RTS/CTS flow control (default: on)\n"
|
" -r: Disable RTS/CTS flow control (default: on)\n"
|
||||||
" -c: Disable lf -> crlf conversion (default: off)\n"
|
|
||||||
#endif
|
#endif
|
||||||
|
" -c: Disable lf -> crlf conversion (default: off)\n"
|
||||||
" -f: Enable endless mode without escape sequence (default: off)\n"
|
" -f: Enable endless mode without escape sequence (default: off)\n"
|
||||||
" -?: This help\n",
|
" -?: This help\n",
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE,
|
|
||||||
CONFIG_SYSTEM_CUTERM_DEFAULT_BAUD
|
|
||||||
#else
|
|
||||||
CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE
|
CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE
|
||||||
|
#ifdef CONFIG_SERIAL_TERMIOS
|
||||||
|
, CONFIG_SYSTEM_CUTERM_DEFAULT_BAUD
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -297,8 +297,8 @@ int main(int argc, FAR char *argv[])
|
|||||||
int baudrate = CONFIG_SYSTEM_CUTERM_DEFAULT_BAUD;
|
int baudrate = CONFIG_SYSTEM_CUTERM_DEFAULT_BAUD;
|
||||||
enum parity_mode parity = PARITY_NONE;
|
enum parity_mode parity = PARITY_NONE;
|
||||||
int rtscts = 1;
|
int rtscts = 1;
|
||||||
int nocrlf = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
int nocrlf = 0;
|
||||||
int nobreak = 0;
|
int nobreak = 0;
|
||||||
int option;
|
int option;
|
||||||
int ret;
|
int ret;
|
||||||
@ -342,11 +342,11 @@ int main(int argc, FAR char *argv[])
|
|||||||
case 'r':
|
case 'r':
|
||||||
rtscts = 0;
|
rtscts = 0;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
nocrlf = 1;
|
nocrlf = 1;
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
nobreak = 1;
|
nobreak = 1;
|
||||||
@ -381,7 +381,6 @@ int main(int argc, FAR char *argv[])
|
|||||||
goto errout_with_devinit;
|
goto errout_with_devinit;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
/* remember serial device termios attributes */
|
/* remember serial device termios attributes */
|
||||||
|
|
||||||
ret = tcgetattr(g_cu.outfd, &g_tio_dev);
|
ret = tcgetattr(g_cu.outfd, &g_tio_dev);
|
||||||
@ -417,11 +416,14 @@ int main(int argc, FAR char *argv[])
|
|||||||
tcgetattr(fd_std_tty, &g_tio_std);
|
tcgetattr(fd_std_tty, &g_tio_std);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SERIAL_TERMIOS
|
||||||
if (set_termios(g_cu.outfd, baudrate, parity, rtscts, nocrlf) != 0)
|
if (set_termios(g_cu.outfd, baudrate, parity, rtscts, nocrlf) != 0)
|
||||||
|
#else
|
||||||
|
if (set_termios(g_cu.outfd, nocrlf) != 0)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
goto errout_with_outfd_retrieve;
|
goto errout_with_outfd_retrieve;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Open the serial device for reading. Since we are already connected,
|
/* Open the serial device for reading. Since we are already connected,
|
||||||
* this should not fail.
|
* this should not fail.
|
||||||
@ -521,10 +523,8 @@ int main(int argc, FAR char *argv[])
|
|||||||
|
|
||||||
errout_with_fds:
|
errout_with_fds:
|
||||||
close(g_cu.infd);
|
close(g_cu.infd);
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
errout_with_outfd_retrieve:
|
errout_with_outfd_retrieve:
|
||||||
retrieve_termios(g_cu.outfd);
|
retrieve_termios(g_cu.outfd);
|
||||||
#endif
|
|
||||||
errout_with_outfd:
|
errout_with_outfd:
|
||||||
close(g_cu.outfd);
|
close(g_cu.outfd);
|
||||||
errout_with_devinit:
|
errout_with_devinit:
|
||||||
|
@ -538,7 +538,6 @@ int main(int argc, FAR char *argv[])
|
|||||||
{
|
{
|
||||||
/* stdin stdout */
|
/* stdin stdout */
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
if (!g_force)
|
if (!g_force)
|
||||||
{
|
{
|
||||||
if ((g_mode == UNCOMPRESS) && isatty(0))
|
if ((g_mode == UNCOMPRESS) && isatty(0))
|
||||||
@ -557,7 +556,6 @@ int main(int argc, FAR char *argv[])
|
|||||||
lzf_exit(1);
|
lzf_exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (g_mode == COMPRESS)
|
if (g_mode == COMPRESS)
|
||||||
{
|
{
|
||||||
|
@ -75,9 +75,7 @@ struct tcurses_vt100_s
|
|||||||
int out_fd;
|
int out_fd;
|
||||||
int keycount;
|
int keycount;
|
||||||
char keybuf[16];
|
char keybuf[16];
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
tcflag_t lflag;
|
tcflag_t lflag;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
@ -1469,9 +1467,7 @@ static bool tcurses_vt100_checkkey(FAR struct termcurses_s *dev)
|
|||||||
FAR struct termcurses_s *tcurses_vt100_initialize(int in_fd, int out_fd)
|
FAR struct termcurses_s *tcurses_vt100_initialize(int in_fd, int out_fd)
|
||||||
{
|
{
|
||||||
FAR struct tcurses_vt100_s *priv;
|
FAR struct tcurses_vt100_s *priv;
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
struct termios cfg;
|
struct termios cfg;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Allocate a new device structure */
|
/* Allocate a new device structure */
|
||||||
|
|
||||||
@ -1490,7 +1486,6 @@ FAR struct termcurses_s *tcurses_vt100_initialize(int in_fd, int out_fd)
|
|||||||
priv->out_fd = out_fd;
|
priv->out_fd = out_fd;
|
||||||
priv->keycount = 0;
|
priv->keycount = 0;
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
if (isatty(priv->in_fd))
|
if (isatty(priv->in_fd))
|
||||||
{
|
{
|
||||||
if (tcgetattr(priv->in_fd, &cfg) == 0)
|
if (tcgetattr(priv->in_fd, &cfg) == 0)
|
||||||
@ -1516,7 +1511,6 @@ FAR struct termcurses_s *tcurses_vt100_initialize(int in_fd, int out_fd)
|
|||||||
priv->lflag = 0;
|
priv->lflag = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return (FAR struct termcurses_s *)priv;
|
return (FAR struct termcurses_s *)priv;
|
||||||
}
|
}
|
||||||
@ -1532,10 +1526,8 @@ FAR struct termcurses_s *tcurses_vt100_initialize(int in_fd, int out_fd)
|
|||||||
static int tcurses_vt100_terminate(FAR struct termcurses_s *dev)
|
static int tcurses_vt100_terminate(FAR struct termcurses_s *dev)
|
||||||
{
|
{
|
||||||
FAR struct tcurses_vt100_s *priv;
|
FAR struct tcurses_vt100_s *priv;
|
||||||
int fd;
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
struct termios cfg;
|
struct termios cfg;
|
||||||
#endif
|
int fd;
|
||||||
|
|
||||||
priv = (FAR struct tcurses_vt100_s *)dev;
|
priv = (FAR struct tcurses_vt100_s *)dev;
|
||||||
fd = priv->out_fd;
|
fd = priv->out_fd;
|
||||||
@ -1546,7 +1538,6 @@ static int tcurses_vt100_terminate(FAR struct termcurses_s *dev)
|
|||||||
|
|
||||||
write(fd, g_setdefcolors, strlen(g_setdefcolors));
|
write(fd, g_setdefcolors, strlen(g_setdefcolors));
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
if (isatty(priv->in_fd))
|
if (isatty(priv->in_fd))
|
||||||
{
|
{
|
||||||
if (tcgetattr(priv->in_fd, &cfg) == 0 && priv->lflag & ECHO)
|
if (tcgetattr(priv->in_fd, &cfg) == 0 && priv->lflag & ECHO)
|
||||||
@ -1555,7 +1546,6 @@ static int tcurses_vt100_terminate(FAR struct termcurses_s *dev)
|
|||||||
tcsetattr(priv->in_fd, TCSANOW, &cfg);
|
tcsetattr(priv->in_fd, TCSANOW, &cfg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
config SYSTEM_YMODEM
|
config SYSTEM_YMODEM
|
||||||
tristate "YMODEM"
|
tristate "YMODEM"
|
||||||
depends on SERIAL_TERMIOS
|
|
||||||
---help---
|
---help---
|
||||||
Enable support for ymodem.
|
Enable support for ymodem.
|
||||||
|
|
||||||
|
@ -69,9 +69,7 @@ int main(int argc, FAR char *argv[])
|
|||||||
FAR const char *devname = CONFIG_SYSTEM_ZMODEM_DEVNAME;
|
FAR const char *devname = CONFIG_SYSTEM_ZMODEM_DEVNAME;
|
||||||
FAR const char *pathname = CONFIG_SYSTEM_ZMODEM_MOUNTPOINT;
|
FAR const char *pathname = CONFIG_SYSTEM_ZMODEM_MOUNTPOINT;
|
||||||
int exitcode = EXIT_FAILURE;
|
int exitcode = EXIT_FAILURE;
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
struct termios saveterm;
|
struct termios saveterm;
|
||||||
#endif
|
|
||||||
int option;
|
int option;
|
||||||
int ret;
|
int ret;
|
||||||
int fd;
|
int fd;
|
||||||
@ -124,7 +122,6 @@ int main(int argc, FAR char *argv[])
|
|||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
/* Save the current terminal setting */
|
/* Save the current terminal setting */
|
||||||
|
|
||||||
tcgetattr(fd, &saveterm);
|
tcgetattr(fd, &saveterm);
|
||||||
@ -137,7 +134,6 @@ int main(int argc, FAR char *argv[])
|
|||||||
/* Enable hardware Rx/Tx flow control */
|
/* Enable hardware Rx/Tx flow control */
|
||||||
|
|
||||||
zm_flowc(fd);
|
zm_flowc(fd);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Get the Zmodem handle */
|
/* Get the Zmodem handle */
|
||||||
@ -164,18 +160,13 @@ errout_with_zmodem:
|
|||||||
zmr_release(handle);
|
zmr_release(handle);
|
||||||
|
|
||||||
errout_with_device:
|
errout_with_device:
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
#ifdef CONFIG_SYSTEM_ZMODEM_FLOWC
|
|
||||||
/* Flush the serial output to assure do not hang trying to drain it */
|
/* Flush the serial output to assure do not hang trying to drain it */
|
||||||
|
|
||||||
tcflush(fd, TCIOFLUSH);
|
tcflush(fd, TCIOFLUSH);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Restore the saved terminal setting */
|
/* Restore the saved terminal setting */
|
||||||
|
|
||||||
tcsetattr(fd, TCSANOW, &saveterm);
|
tcsetattr(fd, TCSANOW, &saveterm);
|
||||||
#endif
|
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
errout:
|
errout:
|
||||||
|
@ -88,9 +88,7 @@ int main(int argc, FAR char *argv[])
|
|||||||
bool skip = false;
|
bool skip = false;
|
||||||
long tmp;
|
long tmp;
|
||||||
int exitcode = EXIT_FAILURE;
|
int exitcode = EXIT_FAILURE;
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
struct termios saveterm;
|
struct termios saveterm;
|
||||||
#endif
|
|
||||||
int option;
|
int option;
|
||||||
int ret;
|
int ret;
|
||||||
int fd;
|
int fd;
|
||||||
@ -177,7 +175,6 @@ int main(int argc, FAR char *argv[])
|
|||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
/* Save the current terminal setting */
|
/* Save the current terminal setting */
|
||||||
|
|
||||||
tcgetattr(fd, &saveterm);
|
tcgetattr(fd, &saveterm);
|
||||||
@ -190,7 +187,6 @@ int main(int argc, FAR char *argv[])
|
|||||||
/* Enable hardware Rx/Tx flow control */
|
/* Enable hardware Rx/Tx flow control */
|
||||||
|
|
||||||
zm_flowc(fd);
|
zm_flowc(fd);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Get the Zmodem handle */
|
/* Get the Zmodem handle */
|
||||||
@ -264,18 +260,13 @@ errout_with_zmodem:
|
|||||||
zms_release(handle);
|
zms_release(handle);
|
||||||
|
|
||||||
errout_with_device:
|
errout_with_device:
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
# ifdef CONFIG_SYSTEM_ZMODEM_FLOWC
|
|
||||||
/* Flush the serial output to assure do not hang trying to drain it */
|
/* Flush the serial output to assure do not hang trying to drain it */
|
||||||
|
|
||||||
tcflush(fd, TCIOFLUSH);
|
tcflush(fd, TCIOFLUSH);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Restore the saved terminal setting */
|
/* Restore the saved terminal setting */
|
||||||
|
|
||||||
tcsetattr(fd, TCSANOW, &saveterm);
|
tcsetattr(fd, TCSANOW, &saveterm);
|
||||||
#endif
|
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
errout:
|
errout:
|
||||||
|
@ -577,9 +577,7 @@ uint32_t zm_filecrc(FAR struct zm_state_s *pzm, FAR const char *filename);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
void zm_rawmode(int fd);
|
void zm_rawmode(int fd);
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: zm_flowc
|
* Name: zm_flowc
|
||||||
|
@ -476,7 +476,6 @@ uint32_t zm_filecrc(FAR struct zm_state_s *pzm, FAR const char *filename)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
void zm_rawmode(int fd)
|
void zm_rawmode(int fd)
|
||||||
{
|
{
|
||||||
struct termios term;
|
struct termios term;
|
||||||
@ -485,7 +484,6 @@ void zm_rawmode(int fd)
|
|||||||
cfmakeraw(&term);
|
cfmakeraw(&term);
|
||||||
tcsetattr(fd, TCSANOW, &term);
|
tcsetattr(fd, TCSANOW, &term);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: zm_flowc
|
* Name: zm_flowc
|
||||||
|
Loading…
Reference in New Issue
Block a user