apps/system/zmodem: Add an option to enable hardware flow control via termios.
This commit is contained in:
parent
803323c213
commit
1e94c78e2e
@ -65,6 +65,26 @@ config SYSTEM_ZMODEM_MOUNTPOINT
|
||||
Names of file send by the sz commond, on the other hand, must be
|
||||
absolute paths beginning with '/'.
|
||||
|
||||
config SYSTEM_ZMODEM_FLOWC
|
||||
bool
|
||||
default n
|
||||
|
||||
config SYSTEM_ZMODEM_IFLOW
|
||||
bool "Rx flow control"
|
||||
default n
|
||||
select SYSTEM_ZMODEM_FLOWC
|
||||
depends on SERIAL_TERMIOS
|
||||
---help---
|
||||
Enable H/W CTS flow control.
|
||||
|
||||
config SYSTEM_ZMODEM_OFLOW
|
||||
bool "Tx flow control"
|
||||
default n
|
||||
select SYSTEM_ZMODEM_FLOWC
|
||||
depends on SERIAL_TERMIOS
|
||||
---help---
|
||||
Enable H/W RTS flow control.
|
||||
|
||||
config SYSTEM_ZMODEM_RCVSAMPLE
|
||||
bool "Reverse channel"
|
||||
default n
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* system/zmodem/rz_main.c
|
||||
*
|
||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2013, 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -127,6 +127,12 @@ int rz_main(int argc, FAR char **argv)
|
||||
goto errout;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SYSTEM_ZMODEM_FLOWC
|
||||
/* Enable hardware Rx/Tx flow control */
|
||||
|
||||
zm_flowc(fd);
|
||||
#endif
|
||||
|
||||
/* Get the Zmodem handle */
|
||||
|
||||
handle = zmr_initialize(fd);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* system/zmodem/sz_main.c
|
||||
*
|
||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2013, 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -186,6 +186,12 @@ int sz_main(int argc, FAR char **argv)
|
||||
goto errout;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SYSTEM_ZMODEM_FLOWC
|
||||
/* Enable hardware Rx/Tx flow control */
|
||||
|
||||
zm_flowc(fd);
|
||||
#endif
|
||||
|
||||
/* Get the Zmodem handle */
|
||||
|
||||
handle = zms_initialize(fd);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* apps/system/zmodem/zm.h
|
||||
*
|
||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2013, 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* References:
|
||||
@ -577,6 +577,18 @@ int zm_writefile(int fd, FAR const uint8_t *buffer, size_t buflen, bool zcnl);
|
||||
|
||||
uint32_t zm_filecrc(FAR struct zm_state_s *pzm, FAR const char *filename);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: zm_flowc
|
||||
*
|
||||
* Description:
|
||||
* Enable hardware Rx/Tx flow control
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_ZMODEM_FLOWC
|
||||
void zm_flowc(int fd);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: zm_putzdle
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* system/zmodem/zm_utils.c
|
||||
*
|
||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2013, 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -42,6 +42,7 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <crc32.h>
|
||||
@ -430,7 +431,7 @@ int zm_writefile(int fd, FAR const uint8_t *buffer, size_t buflen, bool zcnl)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/************************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: zm_filecrc
|
||||
*
|
||||
* Description:
|
||||
@ -439,7 +440,7 @@ int zm_writefile(int fd, FAR const uint8_t *buffer, size_t buflen, bool zcnl)
|
||||
* Assumptions:
|
||||
* The allocated I/O buffer is available to buffer file data.
|
||||
*
|
||||
************************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t zm_filecrc(FAR struct zm_state_s *pzm, FAR const char *filename)
|
||||
{
|
||||
@ -471,3 +472,62 @@ uint32_t zm_filecrc(FAR struct zm_state_s *pzm, FAR const char *filename)
|
||||
close(fd);
|
||||
return ~crc;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: zm_flowc
|
||||
*
|
||||
* Description:
|
||||
* Enable hardware Rx/Tx flow control
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_ZMODEM_FLOWC
|
||||
void zm_flowc(int fd)
|
||||
{
|
||||
struct termios term;
|
||||
|
||||
/* Get the termios */
|
||||
|
||||
tcgetattr(fd, &term);
|
||||
|
||||
#ifdef CONFIG_SYSTEM_ZMODEM_IFLOW
|
||||
/* Set input flow control */
|
||||
|
||||
#ifdef CRTS_IFLOW
|
||||
term.c_cflag |= CRTS_IFLOW;
|
||||
#else
|
||||
term.c_cflag |= CRTSCTS;
|
||||
#endif
|
||||
#else /* CONFIG_SYSTEM_ZMODEM_IFLOW */
|
||||
/* Clear input flow control */
|
||||
|
||||
#ifdef CRTS_IFLOW
|
||||
term.c_cflag &= ~CRTS_IFLOW;
|
||||
#else
|
||||
term.c_cflag &= ~CRTSCTS;
|
||||
#endif
|
||||
#endif /* CONFIG_SYSTEM_ZMODEM_IFLOW */
|
||||
|
||||
#ifdef CONFIG_SYSTEM_ZMODEM_OFLOW
|
||||
/* Set output flow control */
|
||||
|
||||
#ifdef CCTS_OFLOW
|
||||
term.c_cflag |= CCTS_OFLOW;
|
||||
#else
|
||||
term.c_cflag |= CRTSCTS;
|
||||
#endif
|
||||
#else /* CONFIG_SYSTEM_ZMODEM_OFLOW */
|
||||
/* Clear output flow control */
|
||||
|
||||
#ifdef CCTS_OFLOW
|
||||
term.c_cflag &= ~CCTS_OFLOW;
|
||||
#else
|
||||
term.c_cflag &= ~CRTSCTS;
|
||||
#endif
|
||||
#endif /* CONFIG_SYSTEM_ZMODEM_OFLOW */
|
||||
|
||||
/* Save the modified termios */
|
||||
|
||||
tcsetattr(fd, TCSANOW, &term);
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user