ts-7000
[Top] [All Lists]

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

To: <>
Subject: [ts-7000] Block problem when reading from a serial port.
From: "Rodrigo Varas" <>
Date: Mon, 29 Sep 2008 09:00:42 -0700

Hello Group:

 

I was wondering if somebody got some ideas on the following problem we have.

 

We do open a serial port and then we open a thread to start reading characters and put in a mailbox buffer.

Snippet code will be something like..

 

    /* Open write/read serial port */

    fd = open(portName,

               O_RDWR       /* As read and write */

               | O_NOCTTY   /* Doesn't want to be the "controlling terminal" for that port */

               | O_SYNC);

 

 

Then we open the thread and start reading using blocking mode:

 

      pthread_create(&threadId, NULL, HandleBlockReceivedTask, (void *)this);

 

 

void CSerialPort::HandleBlockReceived() {

      UCHAR buf;

      int amount;

      USHORT data;

 

      /* Ensure blocking mode */

      fcntl(fd, F_SETFL, 0);

   

      while (enable) {

            amount = read(fd, &buf, 1);         ç====== block call

 

 

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..?

 

Thanks in advance,

Rodrigo.

 

 

__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: =Email Delivery: Digest | m("yahoogroups.com?subject","ts-7000-fullfeatured");=Change Delivery Format: Fully Featured">Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | =Unsubscribe

__,_._,___
<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