I can output to the DB9 serial port on the TWR_SER board by enabling TTYD: and doing this:
serial_fd = fopen("ttyd:", 0);
ioctl(serial_fd, IO_IOCTL_SERIAL_SET_FLAGS, &flags);
fprintf(serial_fd,"\r\nHELLO!!!\r\n");
Now I want to use the Shell library, but I can't find how to direct where it interfaces. Looking at shell.c, it is calling just printf's (as opposed to fprintf(serial_fd...)). I tried launching the shell like this, but it didn't help.
Shell(Shell_commands, "ttyd:");
How does the shell get directed?
Thanks,
-- Ryan
To use the shell interface with a serial port there are a couple things that need to be edited in the twrk60n512.h file and the userconfig.h file
First the corresponding channel in the userconfig.h file needs to be initialized
#define BSPCFG_ENABLE_TTYD 1
Second the BSP_DEFAULT_IO_CHANNEL needs to be set up for the "ttyd:" in these lines in the twrk60n512.h file
#ifndef BSP_DEFAULT_IO_CHANNEL/* * Other Serial console options:(do not forget to enable BSPCFG_ENABLE_TTY define if changed) * "ttyf:" OSJTAG-COM polled mode * "ittyf:" OSJTAG-COM interrupt mode * "ttyd:" TWR-SER polled mode * "ittyd:" TWR-SER interrupt mode */ #if BSPCFG_ENABLE_TTYD #define BSP_DEFAULT_IO_CHANNEL "ttyd:" /* TWR-SER polled mode */ #define BSP_DEFAULT_IO_CHANNEL_DEFINED #else #define BSP_DEFAULT_IO_CHANNEL NULL #endif#endif
This will direct all the printf's used to the ttyd serial port, so then you can initialize the Shell
Shell(Shell_commands, NULL);
and it will be over the serial port. You will also have to recompile the BSP to incorporate the changes made in the userconfig.h and twrk60n512.h files.
Jeremy
Ah! I'd made the changes in user_config.h, but didn't realize that I had to modify twrk60n512.h to redirect printfs.
Works great. Thanks!
You can use telnet to direct your serial task.
you need to do:
1. Have a serial task, for instance Task_Serial()
2. Use RTCS_TASK telnet_shell = {"TN_Vt100", 8, 2000, task_telnet, NULL};
void task_telnet(void *dummy)
{
Task_Serial(0);// 0 specifies telnet, 1-N specifies serial PORT #
}
3. Start TELNET server when you start Network
TELNETSRV_init(taskname = "Telnet server", 7, 4000, &telnet_shell);
I had it work in k60n512.