ts-7000
[Top] [All Lists]

Re: [ts-7000] Re: ts7200 2.4.26-ts11 second serial port problem - hangs

To:
Subject: Re: [ts-7000] Re: ts7200 2.4.26-ts11 second serial port problem - hangs in read
From: Jim Jackson <>
Date: Fri, 11 Feb 2011 20:55:57 +0000 (GMT)


On Fri, 11 Feb 2011, melloannapolis wrote:

> All - thanks for the comments.
> 
> I added parenthesis around the open statement, removed the no-delay flag, 
> rebooted and it started working. I don't know exactly why it wasn't 
> working but it must have had to do with the reboot more than anything....
> 
> changed this:
> if (fd = open(COM2, O_RDWR | O_NOCTTY | O_NDELAY) < 0) {

Ok didn't spot this, but the reason it's wrong is that the '<' is performed
first then fd gets assigned the result of that comparison.

The open returns say '3' which is not less than 0 so the result of the 
comparison is '0' - therefore fd gets set to zero.

> to this:
> if ((fd = open(COM2, O_RDWR | O_NOCTTY)) < 0) {

The brackets now force the order you wanted, first the assignment of the 
open to fd, then check if that is less than zero.

cheers
Jim

p.s. I found a table of operator precedence at 

  http://www.difranco.net/cop2220/op-prec.htm

but if in doubt, either use simpler statements e.g.

  fd = open(COM2, O_RDWR | O_NOCTTY);
  if ( fd < 0 ) {

or use brackets. 


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

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