2009-05-21 01:17:42     UART0 Receiving Problem

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

2009-05-21 01:17:42     UART0 Receiving Problem

ThangarJ P (INDIA)

Message: 74346   

 

Dear All,

 

I am working with uClinux-dist-2008 R1.5.-RC3. BF527-ezkit.

 

i have enabled the UART1 for debug purpose and UART0 for some other purpose.

 

i have configured the UART0 as like below

 

         newmodes = oldmodes;

        newmodes.c_lflag = 0;

 

        newmodes.c_oflag = 0;

        newmodes.c_cc[VTIME] = 0;

        newmodes.c_cc[VMIN] = 1;

 

        cfsetispeed(&newmodes, B19200);

        cfsetospeed(&newmodes, B19200);

 

        tcflush(s32_dvd_fd,TCIFLUSH);

        tcsetattr(s32_dvd_fd, TCSANOW, &newmodes);

 

i have opened the device as like below

 

s32_dvd_fd = open("/dev/ttyBF0",O_RDWR);

 

i have read the data form the serial device as like below

 

ret = read(s32_dvd_fd,Buffer,9)

 

The read is returning with some junk are previous data even the data available in the serial device is less than 9 bytes.

 

it wont block upto receive 9bytes

 

But if we configred newmodes.c_cc[VMIN] = 9, then the read is returning the proper data and also blocking upto receive 9 bytes.

 

But in my application the  requested bytes for read is not constant.

 

so how can we configure this c_cc[VMIN]  value?

 

Please provide your suggestions.

 

Thanks.

QuoteReplyEditDelete

 

 

2009-05-21 02:00:08     Re: UART0 Receiving Problem

Mike Frysinger (UNITED STATES)

Message: 74348   

 

if you set the blocking value to 1 byte, then the behavior you describe is correct.  why dont you write a simple read wrapper that does this for you -- it keeps calling read() until the return value satisfies the desired length.

QuoteReplyEditDelete

 

 

2009-05-21 05:17:21     Re: UART0 Receiving Problem

ThangarJ P (INDIA)

Message: 74407   

 

Dear Mike,

 

Thanks for your suggestion.

 

And  also i am facing one more issue.

 

The read API wont receive the hexadecimal value 0x11which is transitted from otherside  and also receive 0xA instead of  0xD.

 

It is receiving all hexadecimal values properly other than these above two.

 

Please prvide your suggestions.

 

Thanks.

QuoteReplyEditDelete

 

 

2009-05-21 13:49:56     Re: UART0 Receiving Problem

Mike Frysinger (UNITED STATES)

Message: 74422   

 

that doesnt make sense ... 0x11 is not a single byte.  the UART only operates on a single byte at a time.

 

as for 0xA vs 0xD, it'd be best to put a logic analyzer on the line to make sure you're transmitting what you actually think you are.  otherwise, put in debug code into the serial driver and have it log every byte exactly as it comes out (see UART_GET_CHAR() macro).

Attachments

    Outcomes