[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Serialport problem

Hello! I have problem with the serialport on the developer board LX. 
Sometime when I start my program, the read function can't find any data 
there. I now that I send data to the serialport continuously. I have tested 
the program with my PC running Linux without any problem.

The read function looks like this and is placed in an endless loop:  

if (read (*serial_port, &buf, 1) > 0)

Init of serialport looks like this: 

int com1_read (int serial_port){
  struct termios port_options;
  serial_port = open("/dev/ttyS0", O_RDONLY | O_NOCTTY | O_NDELAY | O_NONBLOCK);

  if (serial_port == -1)
    perror("open_port : Unable to open /dev/ttyS0");
      fprintf(stderr, "\nSerial port opend");
      bzero(&port_options, sizeof(struct termios));
      port_options.c_cflag = B57600 | CS8 | CLOCAL | CREAD;
      tcflush (serial_port, TCIFLUSH);
      tcsetattr (serial_port, TCSADRAIN, &port_options);
  return serial_port;

I have used the cris compiler tools version 1.14 and the 2.4.5 linux kernel

Joakim Eriksson