To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 552
551  |  553
Subject: 
LNP collision detection Bug found and fixed
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Wed, 8 Dec 1999 03:25:37 GMT
Viewed: 
923 times
  
Hi there, i just found an evil little bug in lnp ( or maybe it's
actually a bug in gcc ). The problem is the definition of tx_state as
char, and compare operations like if (tx_state < TX_ACTIVE) . The
compiler generates wrong code for this operation. Also, setting
tx_state=TX_COLL ( #defined to -1) sets it to 0 ! looks like the
compiler treats char as unsigned ?

If you use lnp everything works fine as long as no collision happens,
beacuse TX_COLL is not involved. If it does, lnp_logical_write() never
returns in most cases.

My fix: declare tx_state as volatile int, and omit the cast to volatile
char* in lnp_logical.c. It works for me, and collisions are detected now
as expected.

BTW, i wrote a little linux library that tries to implement lnp exactly
like the RCX does, i.e., looking for frame-errors and unexpected receive
chars while sending. The only difference is the inter-byte-timeout,
which must be set a little bit higher on linux.
The reason for this: sigio is not delivered on each incoming byte, some
tests show on my box there are up to 8 bytes in the queue when sigio is
delivered. I guess this effect is due to linux scheduling with 100 Hz (
on i386 ). Setting the interbyte timeout to 3 times the value used on
the RCX works fine. Maybe it also would help to use realtime scheduling,
but you have to set the program SUID root for this ;-(  i haven't tested
this so far.
I'm not really happy with this implementation, because it uses signals
heavily and handlers are called from inside sigio handler, what means
they cannot use full libc functionality.
I'd like to try to build an implementation based on POSIX threads,
sometime... However, it looks like it's working so far, if anyone is
interested in the source drop me a note.



Message has 1 Reply:
  Re: LNP collision detection Bug found and fixed
 
(...) It shouldn't matter if it does. More likely, it seems to me, is that TX_COLL is defined like this: #define TX_COLL -1 in which case, the offending statement becomes: tx_state=-1; which is old-style for: tx_state-=1; (should generate a (...) (25 years ago, 9-Dec-99, to lugnet.robotics.rcx.legos)

3 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR