mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 18:47:21 +08:00
Put console and syslog on UART8, added support to nshterm for proper serial port config
This commit is contained in:
@@ -58,6 +58,15 @@ fi
|
|||||||
if [ $MODE == autostart ]
|
if [ $MODE == autostart ]
|
||||||
then
|
then
|
||||||
|
|
||||||
|
#
|
||||||
|
# Start terminal
|
||||||
|
#
|
||||||
|
if sercon
|
||||||
|
then
|
||||||
|
echo "USB connected"
|
||||||
|
nshterm /dev/ttyACM0 &
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Start the ORB (first app to start)
|
# Start the ORB (first app to start)
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ MODULES += systemcmds/reboot
|
|||||||
MODULES += systemcmds/top
|
MODULES += systemcmds/top
|
||||||
MODULES += systemcmds/tests
|
MODULES += systemcmds/tests
|
||||||
MODULES += systemcmds/config
|
MODULES += systemcmds/config
|
||||||
|
MODULES += systemcmds/nshterm
|
||||||
|
|
||||||
#
|
#
|
||||||
# General system control
|
# General system control
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ MODULES += systemcmds/pwm
|
|||||||
MODULES += systemcmds/reboot
|
MODULES += systemcmds/reboot
|
||||||
MODULES += systemcmds/top
|
MODULES += systemcmds/top
|
||||||
MODULES += systemcmds/tests
|
MODULES += systemcmds/tests
|
||||||
|
MODULES += systemcmds/config
|
||||||
|
MODULES += systemcmds/nshterm
|
||||||
|
|
||||||
#
|
#
|
||||||
# General system control
|
# General system control
|
||||||
|
|||||||
@@ -420,7 +420,7 @@ CONFIG_TASK_NAME_SIZE=24
|
|||||||
CONFIG_START_YEAR=1970
|
CONFIG_START_YEAR=1970
|
||||||
CONFIG_START_MONTH=1
|
CONFIG_START_MONTH=1
|
||||||
CONFIG_START_DAY=1
|
CONFIG_START_DAY=1
|
||||||
# CONFIG_DEV_CONSOLE is not set
|
CONFIG_DEV_CONSOLE=y
|
||||||
# CONFIG_MUTEX_TYPES is not set
|
# CONFIG_MUTEX_TYPES is not set
|
||||||
CONFIG_PRIORITY_INHERITANCE=y
|
CONFIG_PRIORITY_INHERITANCE=y
|
||||||
CONFIG_SEM_PREALLOCHOLDERS=8
|
CONFIG_SEM_PREALLOCHOLDERS=8
|
||||||
@@ -523,7 +523,7 @@ CONFIG_PIPES=y
|
|||||||
# CONFIG_POWER is not set
|
# CONFIG_POWER is not set
|
||||||
# CONFIG_SENSORS is not set
|
# CONFIG_SENSORS is not set
|
||||||
CONFIG_SERIAL=y
|
CONFIG_SERIAL=y
|
||||||
# CONFIG_DEV_LOWCONSOLE is not set
|
CONFIG_DEV_LOWCONSOLE=y
|
||||||
CONFIG_SERIAL_REMOVABLE=y
|
CONFIG_SERIAL_REMOVABLE=y
|
||||||
# CONFIG_16550_UART is not set
|
# CONFIG_16550_UART is not set
|
||||||
CONFIG_ARCH_HAVE_UART4=y
|
CONFIG_ARCH_HAVE_UART4=y
|
||||||
@@ -542,8 +542,8 @@ CONFIG_SERIAL_NPOLLWAITERS=2
|
|||||||
# CONFIG_UART4_SERIAL_CONSOLE is not set
|
# CONFIG_UART4_SERIAL_CONSOLE is not set
|
||||||
# CONFIG_USART6_SERIAL_CONSOLE is not set
|
# CONFIG_USART6_SERIAL_CONSOLE is not set
|
||||||
# CONFIG_UART7_SERIAL_CONSOLE is not set
|
# CONFIG_UART7_SERIAL_CONSOLE is not set
|
||||||
# CONFIG_UART8_SERIAL_CONSOLE is not set
|
CONFIG_UART8_SERIAL_CONSOLE=y
|
||||||
CONFIG_NO_SERIAL_CONSOLE=y
|
# CONFIG_NO_SERIAL_CONSOLE is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# USART1 Configuration
|
# USART1 Configuration
|
||||||
@@ -650,7 +650,7 @@ CONFIG_USBDEV_MAXPOWER=500
|
|||||||
# CONFIG_USBDEV_COMPOSITE is not set
|
# CONFIG_USBDEV_COMPOSITE is not set
|
||||||
# CONFIG_PL2303 is not set
|
# CONFIG_PL2303 is not set
|
||||||
CONFIG_CDCACM=y
|
CONFIG_CDCACM=y
|
||||||
CONFIG_CDCACM_CONSOLE=y
|
CONFIG_CDCACM_CONSOLE=n
|
||||||
CONFIG_CDCACM_EP0MAXPACKET=64
|
CONFIG_CDCACM_EP0MAXPACKET=64
|
||||||
CONFIG_CDCACM_EPINTIN=1
|
CONFIG_CDCACM_EPINTIN=1
|
||||||
CONFIG_CDCACM_EPINTIN_FSSIZE=64
|
CONFIG_CDCACM_EPINTIN_FSSIZE=64
|
||||||
@@ -716,10 +716,10 @@ CONFIG_FS_BINFS=y
|
|||||||
#
|
#
|
||||||
# System Logging
|
# System Logging
|
||||||
#
|
#
|
||||||
# CONFIG_SYSLOG_ENABLE is not set
|
CONFIG_SYSLOG_ENABLE=y
|
||||||
CONFIG_SYSLOG=y
|
CONFIG_SYSLOG=y
|
||||||
CONFIG_SYSLOG_CHAR=y
|
CONFIG_SYSLOG_CHAR=y
|
||||||
CONFIG_SYSLOG_DEVPATH="/dev/ttyS0"
|
CONFIG_SYSLOG_DEVPATH="/dev/ttyS6"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Graphics Support
|
# Graphics Support
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
#include <termios.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -48,6 +49,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <apps/nsh.h>
|
#include <apps/nsh.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <systemlib/err.h>
|
||||||
|
|
||||||
__EXPORT int nshterm_main(int argc, char *argv[]);
|
__EXPORT int nshterm_main(int argc, char *argv[]);
|
||||||
|
|
||||||
@@ -61,8 +63,8 @@ nshterm_main(int argc, char *argv[])
|
|||||||
uint8_t retries = 0;
|
uint8_t retries = 0;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
while (retries < 5) {
|
while (retries < 5) {
|
||||||
// the retries are to cope with the behaviour of /dev/ttyACM0
|
/* the retries are to cope with the behaviour of /dev/ttyACM0 */
|
||||||
// which may not be ready immediately.
|
/* which may not be ready immediately. */
|
||||||
fd = open(argv[1], O_RDWR);
|
fd = open(argv[1], O_RDWR);
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
break;
|
break;
|
||||||
@@ -74,7 +76,30 @@ nshterm_main(int argc, char *argv[])
|
|||||||
perror(argv[1]);
|
perror(argv[1]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
// setup standard file descriptors
|
|
||||||
|
/* set up the serial port with output processing */
|
||||||
|
|
||||||
|
/* Try to set baud rate */
|
||||||
|
struct termios uart_config;
|
||||||
|
int termios_state;
|
||||||
|
|
||||||
|
/* Back up the original uart configuration to restore it after exit */
|
||||||
|
if ((termios_state = tcgetattr(fd, &uart_config)) < 0) {
|
||||||
|
warnx("ERROR get termios config %s: %d\n", argv[1], termios_state);
|
||||||
|
close(fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set ONLCR flag (which appends a CR for every LF) */
|
||||||
|
uart_config.c_oflag |= (ONLCR | OPOST | OCRNL);
|
||||||
|
|
||||||
|
if ((termios_state = tcsetattr(fd, TCSANOW, &uart_config)) < 0) {
|
||||||
|
warnx("ERROR setting baudrate / termios config for %s (tcsetattr)\n", argv[1]);
|
||||||
|
close(fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* setup standard file descriptors */
|
||||||
close(0);
|
close(0);
|
||||||
close(1);
|
close(1);
|
||||||
close(2);
|
close(2);
|
||||||
|
|||||||
Reference in New Issue
Block a user