Browse Source

Put console and syslog on UART8, added support to nshterm for proper serial port config

sbg
Lorenz Meier 12 years ago
parent
commit
80f38e3dea
  1. 9
      ROMFS/px4fmu_common/init.d/rcS
  2. 1
      makefiles/config_px4fmu-v1_default.mk
  3. 2
      makefiles/config_px4fmu-v2_default.mk
  4. 14
      nuttx-configs/px4fmu-v2/nsh/defconfig
  5. 31
      src/systemcmds/nshterm/nshterm.c

9
ROMFS/px4fmu_common/init.d/rcS

@ -58,6 +58,15 @@ fi @@ -58,6 +58,15 @@ fi
if [ $MODE == autostart ]
then
#
# Start terminal
#
if sercon
then
echo "USB connected"
nshterm /dev/ttyACM0 &
fi
#
# Start the ORB (first app to start)
#

1
makefiles/config_px4fmu-v1_default.mk

@ -54,6 +54,7 @@ MODULES += systemcmds/reboot @@ -54,6 +54,7 @@ MODULES += systemcmds/reboot
MODULES += systemcmds/top
MODULES += systemcmds/tests
MODULES += systemcmds/config
MODULES += systemcmds/nshterm
#
# General system control

2
makefiles/config_px4fmu-v2_default.mk

@ -52,6 +52,8 @@ MODULES += systemcmds/pwm @@ -52,6 +52,8 @@ MODULES += systemcmds/pwm
MODULES += systemcmds/reboot
MODULES += systemcmds/top
MODULES += systemcmds/tests
MODULES += systemcmds/config
MODULES += systemcmds/nshterm
#
# General system control

14
nuttx-configs/px4fmu-v2/nsh/defconfig

@ -420,7 +420,7 @@ CONFIG_TASK_NAME_SIZE=24 @@ -420,7 +420,7 @@ CONFIG_TASK_NAME_SIZE=24
CONFIG_START_YEAR=1970
CONFIG_START_MONTH=1
CONFIG_START_DAY=1
# CONFIG_DEV_CONSOLE is not set
CONFIG_DEV_CONSOLE=y
# CONFIG_MUTEX_TYPES is not set
CONFIG_PRIORITY_INHERITANCE=y
CONFIG_SEM_PREALLOCHOLDERS=8
@ -523,7 +523,7 @@ CONFIG_PIPES=y @@ -523,7 +523,7 @@ CONFIG_PIPES=y
# CONFIG_POWER is not set
# CONFIG_SENSORS is not set
CONFIG_SERIAL=y
# CONFIG_DEV_LOWCONSOLE is not set
CONFIG_DEV_LOWCONSOLE=y
CONFIG_SERIAL_REMOVABLE=y
# CONFIG_16550_UART is not set
CONFIG_ARCH_HAVE_UART4=y
@ -542,8 +542,8 @@ CONFIG_SERIAL_NPOLLWAITERS=2 @@ -542,8 +542,8 @@ CONFIG_SERIAL_NPOLLWAITERS=2
# CONFIG_UART4_SERIAL_CONSOLE is not set
# CONFIG_USART6_SERIAL_CONSOLE is not set
# CONFIG_UART7_SERIAL_CONSOLE is not set
# CONFIG_UART8_SERIAL_CONSOLE is not set
CONFIG_NO_SERIAL_CONSOLE=y
CONFIG_UART8_SERIAL_CONSOLE=y
# CONFIG_NO_SERIAL_CONSOLE is not set
#
# USART1 Configuration
@ -650,7 +650,7 @@ CONFIG_USBDEV_MAXPOWER=500 @@ -650,7 +650,7 @@ CONFIG_USBDEV_MAXPOWER=500
# CONFIG_USBDEV_COMPOSITE is not set
# CONFIG_PL2303 is not set
CONFIG_CDCACM=y
CONFIG_CDCACM_CONSOLE=y
CONFIG_CDCACM_CONSOLE=n
CONFIG_CDCACM_EP0MAXPACKET=64
CONFIG_CDCACM_EPINTIN=1
CONFIG_CDCACM_EPINTIN_FSSIZE=64
@ -716,10 +716,10 @@ CONFIG_FS_BINFS=y @@ -716,10 +716,10 @@ CONFIG_FS_BINFS=y
#
# System Logging
#
# CONFIG_SYSLOG_ENABLE is not set
CONFIG_SYSLOG_ENABLE=y
CONFIG_SYSLOG=y
CONFIG_SYSLOG_CHAR=y
CONFIG_SYSLOG_DEVPATH="/dev/ttyS0"
CONFIG_SYSLOG_DEVPATH="/dev/ttyS6"
#
# Graphics Support

31
src/systemcmds/nshterm/nshterm.c

@ -40,6 +40,7 @@ @@ -40,6 +40,7 @@
*/
#include <nuttx/config.h>
#include <termios.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdarg.h>
@ -48,6 +49,7 @@ @@ -48,6 +49,7 @@
#include <errno.h>
#include <apps/nsh.h>
#include <fcntl.h>
#include <systemlib/err.h>
__EXPORT int nshterm_main(int argc, char *argv[]);
@ -61,8 +63,8 @@ nshterm_main(int argc, char *argv[]) @@ -61,8 +63,8 @@ nshterm_main(int argc, char *argv[])
uint8_t retries = 0;
int fd = -1;
while (retries < 5) {
// the retries are to cope with the behaviour of /dev/ttyACM0
// which may not be ready immediately.
/* the retries are to cope with the behaviour of /dev/ttyACM0 */
/* which may not be ready immediately. */
fd = open(argv[1], O_RDWR);
if (fd != -1) {
break;
@ -74,7 +76,30 @@ nshterm_main(int argc, char *argv[]) @@ -74,7 +76,30 @@ nshterm_main(int argc, char *argv[])
perror(argv[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(1);
close(2);

Loading…
Cancel
Save