I am new to use the netos63 software. I have tried to use the termios drivers without success. I have used the template software.
void applicationStart (void)
{
struct termios term;
int fd;
char message[] = "Print with termios
";
printf ("Print with printf
");
tx_thread_sleep(10);
fd = open("/com/0", (O_RDWR | O_NONBLOCK));
if (fd < 0)
{
printf("Error in open() file = %d
", getErrno());
}
if (tcgetattr(fd, &term) < 0)
{
printf("Error in tcgetattr() = %d
", getErrno());
}
term.c_iflag = 0;
term.c_oflag = 0;
term.c_cflag &= ~CSIZE;
term.c_cflag |= CS8; // 8 bit
term.c_cflag &= ~CSTOPB; // 1 stop bit
term.c_cflag &= ~PARENB; // No parity
term.c_cflag |= CRTS; // Enable RTS for input flow control
term.c_cflag |= CCTS; // Enable CTS for output flow control
term.c_xflag = 0;
term.c_cc[0] = 0;
term.baud = 9600;
if (tcsetattr(fd, TCSANOW, &term) < 0)
{
printf("Error in tcsetattr() = %d
", getErrno());
}
if (write(fd, message, strlen(message)) < 0)
{
printf("Error in write() = %d
", getErrno());
}
printf ("Print with printf again
");
tx_thread_suspend(tx_thread_identify());
}
The printf’s print the text.
The open() comes with errno 16 (mount device busy) and tcgetattr and tcsetattr will therefore come with error 22 (invalid argument).
I suppose that this means that the /com/0 has already been opened, but I am not able to close it first because I don’t know the file descriptor.
The termios API’s are used, because they are defined in the bsp connectme platform as default.
What is the problem?