Subject:
|
Re: LNP collision detection Bug found and fixed
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Thu, 9 Dec 1999 10:12:20 GMT
|
Viewed:
|
972 times
|
| |
| |
Martin Cornelius wrote:
>
> 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 ?
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 warning), and thus subtracts one from tx_state.
define TX_COLL (-1)
would fix it. OTOH, it could be something completely different since
your change to an int shouldn't fix this problem. Is the existing
definition volatile?
> 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.
The 8 character queue will be the FIFO in the SIO - you can disable it
on Linux, I believe.
Cheers,
Ben.
--
SECURE HOSTING AT THE BUNKER! http://www.thebunker.net/hosting.htm
http://www.apache-ssl.org/ben.html
"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
- Indira Gandhi
|
|
Message has 1 Reply:
Message is in Reply To:
| | LNP collision detection Bug found and fixed
|
| 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 (...) (25 years ago, 8-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
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|