Subject:
|
patch for lnpd ( Collision problem in far-mode )
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Sat, 12 Feb 2000 22:49:42 GMT
|
Viewed:
|
3099 times
|
| |
| |
Toni Martinez-Colom wrote:
>
> I have observed the same behavior... only by night. I think it must be the
> tower receiving echoes of its own packets.
i had never seen this interesting effect, because i always had my tower
in near mode, where it only happens if you put the tower straight in
front of a wall. I suspect it's a little more complex to explain what
happens here, because the tower always receives it's own packets -- this
actually is the principle of collision detection. We just test if every
byte we sent out comes back immediately, if not, or the uart tells us a
framing error occured, we regard this as a collision.
I guess there is some analog circuitry inside the tower that screws up
sometimes. If you modifiy lnptest to have the packets sent contain all
the same value in the data section, there are much less errors.
However, i found some kind of solution, that seems to make things much
better. I just removed the frame-error checking code from lnpd.
Actually, this code is not necessary, we have a checksum at the end of
each frame that should detect garbled data anyways. Obviously the uart
often detects frame errors although the content of the byte was received
correctly.
Perhaps we could also remove frame error detection from legOS with
positive results, i`ll check that.
Anyways, here is the patch for lnpd: You can still get the
frame-checking by adding -DCHECK_FRAMING to the CFLAGS, but by default
it will not be there, making lnpd even a little smaller.
Please, tell me if that helps, Martin
------------- snip here -------------------
--- transceiver.c.old Sat Feb 12 23:12:20 2000
+++ transceiver.c Sat Feb 12 23:08:45 2000
@@ -32,9 +32,11 @@
static unsigned char* tx_next;
static unsigned char* tx_verify;
static unsigned char* tx_end;
-static struct serial_icounter_struct tty_error_info;
static struct timeval inter_byte_time, keep_alive_time,
tx_allowed_time;
static const unsigned char keepalive_byte = KEEP_ALIVE_BYTE;
+#ifdef CHECK_FRAMING
+static struct serial_icounter_struct tty_error_info;
+#endif
// convert a time in milliseconds to struct timeval
static void msecs2timeval(int msecs, struct timeval *tval)
@@ -58,7 +60,7 @@
int result = select(0,NULL,NULL,NULL,&wtime);
if ( result < 0 && errno != EINTR ) error_exit("select()");
if (gettimeofday(&now,NULL)) error_exit("gettimeofday");
- if (timercmp(&now,&end,>)) break;
+ if (!timercmp(&now,&end,<)) break;
timersub(&end,&now,&wtime);
} while (1);
}
@@ -94,7 +96,9 @@
static void rx_flush(void)
{
if ( tcflush(rcxfd,TCIFLUSH)) error_exit("tcflush");
+#ifdef CHECK_FRAMING
if ( ioctl(rcxfd,TIOCGICOUNT,&tty_error_info)) error_exit(ioctl);
+#endif
}
// discard all characters in the output queue of tty
@@ -156,10 +160,14 @@
static int rcx_read(void)
{
- int badframe, bytes_read, total_read = 0;
+ int bytes_read, total_read = 0;
unsigned char rcv_buffer[RCV_BUFFER_SIZE];
unsigned char *rcvd;
+
+#ifdef CHECK_FRAMING
+ int badframe;
struct serial_icounter_struct new_error_info;
+#endif
while (1)
{
@@ -170,6 +178,7 @@
if ( bytes_read < 0 ) error_exit("read");
// log(LNPD_LOG_DEBUG,"read %d from tty",bytes_read);
+#ifdef CHECK_FRAMING
// check for frame errors
if ( ioctl(rcxfd,TIOCGICOUNT,&new_error_info))
error_exit("ioctl");
badframe =
@@ -187,6 +196,7 @@
log(LNPD_LOG_LOGICAL,"Frame Error");
break;
}
+#endif
for (rcvd = rcv_buffer; rcvd < rcv_buffer + bytes_read ; ++rcvd)
{
@@ -269,7 +279,9 @@
// wait for IR to settle
msleep(100);
rx_flush();
+#ifdef CHECK_FRAMING
if ( ioctl(rcxfd,TIOCGICOUNT,&tty_error_info)) error_exit("ioctl");
+#endif
// check if we can read back what we sent
write(rcxfd,&keepalive_byte,1);
------------- snip here -------------------
|
|
Message has 1 Reply:
Message is in Reply To:
| | RE: LNP Example please
|
| I have observed the same behavior... only by night. I think it must be the tower receiving echoes of its own packets. The sollution: place the tower far away from objects that can reflect light (including yourself). I also changed the tower battery (...) (25 years ago, 12-Feb-00, to lugnet.robotics.rcx.legos)
|
21 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
|
|
|
|