ts-7000
[Top] [All Lists]

Re: [ts-7000] Block problem when reading from a serial port.

To:
Subject: Re: [ts-7000] Block problem when reading from a serial port.
From: David Hawkins <>
Date: Mon, 29 Sep 2008 09:09:04 -0700
Hi Rodrigo,

> Here is problem, everything works ok except when we want to close the
> serial port.
>
> We want to unblock the serial port ‘read’ and have the thread to finish.
>
> We have try many different things to the file descriptor, like close the
> file, changing the blocking mode, opening the port again,etc..
>
> What would be the right way to force the read to return with a -1 ( or
> EOF) to allow the thread to finish as a good citizen..?

I would think, the device driver should have read unblock if you
close its file descriptor. However, if this is a driver written
by TS for a custom serial port (an extra port), then it could be
something that was accidentally 'missed' from their driver.

Rather than opening a thread to perform a blocked read, you could
use the thread to call select() on the file descriptor opened in
non-blocking mode. The use of the select() call requires
the driver to have implemented the poll() driver call.

In the case of using select, the select() call should unblock if
the device is closed. If the driver is 'broken', you could have
the select call wait on two handles; the serial port, and
a fifo/pipe. When you want to kill the thread, write to the
pipe to unblock select, and then the thread can shut down.

At least with the select method, you can work around limitations
of the driver (if that is indeed the cause). I'd recommend writing
some test code that works on an x86 serial port (16550 UART),
and then see if that same code fails to work on the TS board.

Just some ideas for you ...

Cheers,
Dave


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
    
    

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU