2010-09-27 08:10:42     serial driver read API issue

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

2010-09-27 08:10:42     serial driver read API issue

ThangarJ P (INDIA)

Message: 93885   

 

Hi,

 

We are working in custom board with BF527 and  Linux version 2.6.28.10-ADI-2009R1.

 

we have enabled the builtin serial driver for UART communications which created the nodes as ttyBF0 and ttyBF1.

 

The driver opens like this "fd = open("/dev/ttyBF0",O_RDWR);"

 

The data from the UART port is read using the read() API which is blocking call.

 

The read API format is "read(fd,Buffer,1);"

 

But we are facing an issue while closing the driver ,i.e  read() API is still pending if there is no data in the UART port.

 

The driver closes like this "close(fd);"

 

how to overcome this problem?

 

can you please provide your suggestions.

 

 

 

Thanks,

 

Thangaraj.P

QuoteReplyEditDelete

 

 

2010-09-27 13:44:49     Re: serial driver read API issue

Mike Frysinger (UNITED STATES)

Message: 93887   

 

please read the open and/or fcntl man pages.  look for the nonblock option.

QuoteReplyEditDelete

 

 

2010-09-28 04:23:02     Re: serial driver read API issue

ThangarJ P (INDIA)

Message: 93900   

 

Dear Mike,

 

Thanks for your reply.

 

The code works fine for non-block option.

 

But we don't want poll the read continously until there is data on the UART port.

 

So, is there any way of breaking the block read while closing the driver?

 

Thanks,

 

Thangaraj.P

QuoteReplyEditDelete

 

 

2010-09-28 04:28:15     Re: serial driver read API issue

Mike Frysinger (UNITED STATES)

Message: 93902   

 

so use a standard function like select() or epoll()

Attachments

    Outcomes