Hi,
I am having an intermittent problem with my /dev/ser1 not transmitting
data for some reason. The only way to get it to start working is to
reboot the computer. It will work fine for a while and then quit
(although I think it might only be when I launch the application, which
is still under development). Here is the code I am using to initialize
the port:
int InitializeCOM(int bptr, int flag)
{
int status, length, reply, i;
char buffer[30];
struct termios termios_p;
speed_t speed;
char message[100];
speed = BAUDRATE; // 57600
serial_fd = open(/dev/ser1, O_RDWR|O_NONBLOCK);
tcgetattr(serial_fd, &termios_p);
cfsetispeed(&termios_p, speed); // input baud rate
cfsetospeed(&termios_p, speed); // output baud rate
// 8 data bits, 1 stop bit, no parity, no flow control
termios_p.c_cflag |= CS8|CREAD|CLOCAL; // 8 data bits, turn on
receiver, no modem control
termios_p.c_lflag &= ~(ICANON | ECHO); // no echo or canonical
processing
termios_p.c_cflag &= ~(IHFLOW|OHFLOW); // no hardware flow control
status = tcsetattr(serial_fd, TCSANOW, &termios_p);
if (status)
perror(“InitializeCOM tcsetattr”);
tcflush(serial_fd, TCIOFLUSH);
status=write(serial_fd, “K”, 1); // send out first character -
sometimes it doesn’t work, but status returns 1 anyway
I check the return status on the open, and it is ok. I know it is not
sending anything because I watch it on a data scope. One wrinkle is
that when I slay the application I never call close(serial_fd) - is that
a problem? Thanks.