2011-03-29 04:38:46     error when reading from serial port

Document created by Aaronwu Employee on Aug 26, 2013
Version 1Show Document
  • View in full screen mode

2011-03-29 04:38:46     error when reading from serial port

Chandrashekhar Lavania (INDIA)

Message: 99424   

 

Hi,

 

I am trying to read data via the serial port, but the first character being transmitted is never read.

 

eg: If I try to transmit "abcdefg", then if I try to read 6 bytes, the data read by my script is "bcdefg". The "a" goes missing. I think the problem lies with the serial port settings. The settings I use are:

 

struct termios settings;

 

settings.c_cflag = B115200;

 

settings.c_cflag |= (CLOCAL | CREAD);

 

settings.c_cflag |= PARENB;        

 

settings.c_cflag &= ~PARODD;

 

settings.c_cflag &= ~CSTOPB;

 

settings.c_cflag |=  CS8;            

 

settings.c_cflag &= ~CRTSCTS;

 

settings.c_oflag &= ~ONCLR;

 

The actual data being read using the read() command does not contain the "a" as mentioned above.

 

What might be the cause of this ?

 

I did try to tweak the c_iflags using IXON, IXOFF, and IXANY, but it didn't work.

 

Regards,

Shekhar

QuoteReplyEditDelete

 

 

2011-03-30 04:39:30     Re: error when reading from serial port

Mike Frysinger (UNITED STATES)

Message: 99462   

 

what UART exactly are you using ?  which Blackfin part ?  what kernel version ?

 

are you using the UART in PIO mode or DMA ?  what if you change to the other ?

 

are you using the UART as your console ?  or are the two different ?

QuoteReplyEditDelete

 

 

2011-03-30 05:17:19     Re: error when reading from serial port

Chandrashekhar Lavania (INDIA)

Message: 99463   

 

Hi Mike,

 

I am using 2009R1 kernel, with a BF527 processor. The uart being used is uart1.

 

The uart is mapped as my console(/dev/ttyBF0), but while testing the communication I used telnet.

 

The uart is configured in DMA mode.

 

Regards,

 

Shekhar

QuoteReplyEditDelete

 

 

2011-03-30 05:26:38     Re: error when reading from serial port

Mike Frysinger (UNITED STATES)

Message: 99464   

 

disable the console on the uart then

 

QuoteReplyEditDelete

 

 

2011-03-31 04:34:09     Re: error when reading from serial port

Chandrashekhar Lavania (INDIA)

Message: 99471   

 

Hi Mike,

 

I disabled the console on the uart but it did not solve the problem.

 

Now I have tried another method. But it yields a peculiar result.

 

I built the scipt I was using on the platform using Linux GCC toolchain. I did modify it to do write instead of read.

 

Now I tried to send data using this desktop script over serial to the script running on the platform, and I observed the following:

 

1. I need to execute the desktop script twice before the platform script receives any data.

 

2. I need to send a '\n' character to get the platform script to read anything. If I do not do this then I can keep executing the Desktop script but the platform script keeps on waiting.

 

What can be the mechanism to solve this?

 

Regards,

 

Shekhar

QuoteReplyEditDelete

 

 

2011-03-31 14:16:59     Re: error when reading from serial port

Mike Frysinger (UNITED STATES)

Message: 99479   

 

that is correct behavior wrt to \n.  you need to adjust your termios settings accordingly.  please read the man page, especially wrt disabling ICANON.

Attachments

    Outcomes