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 / 2731
2730  |  2732
Subject: 
Re: whats up with lnp_init?
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Mon, 15 Jul 2002 02:03:42 GMT
Viewed: 
1972 times
  
"kenneth johansen" <kennethj@stud.cs.uit.no> wrote in message
news:3D31CF01.37F98172@stud.cs.uit.no...
i have 2 threads (pthreads), 1 that sends and 1 that recieves on my PC.
both of these runs in while(1) sentences.
so.. i thought lnp_init was to be run only once, but unless i run the
lnp_init routine each time i want to send a message nothing get sent!?
whats up with that ?
anyone have any ideas ??

kenneth johansen
kennethj@stud.cs.uit.no



Kenneth,

I'm not sure if I remember correctly, but lnpd as it is right now might not
fare so well with reentrant code (i.e. pthreads) because the signal masks
aren't set up properly.

Check the sources for the keepalive routines (the routines that keep the
serial port open for reading and writing).  If it uses SIGALRM, then you'll
need to rewrite the signal functions so that they have thread-specific
masks, or just rewrite it so that it uses pthreads instead of signals.  I
ended up doing the latter.

If you don't know what the keepalive stuff is for, here's a primer based on
what I've figured out (which may be wrong, in which case I'd be very
grateful to be corrected)

Basically, once you open the serial port for reading and writing, if you
don't write to the port every 3 seconds or so, it gets closed automatically.
You can tell if this happens by watching the green light on the IR tower.
If it goes off, then the port is closed and you'll have reopen it (which is
what lnp_init does).  the legOS code hacks this by just writing a junk byte
(0xFF) every 3.7 seconds to the IR port, which then keeps the port open.
dll and firmdl3 do this by means of setting a SIGALRM and resetting it every
time the signal fires.  I'm not sure how lnpd does it, but I'm assuming it's
pretty similar.

Hope that helps.
Albert



Message is in Reply To:
  whats up with lnp_init?
 
i have 2 threads (pthreads), 1 that sends and 1 that recieves on my PC. both of these runs in while(1) sentences. so.. i thought lnp_init was to be run only once, but unless i run the lnp_init routine each time i want to send a message nothing get (...) (22 years ago, 14-Jul-02, 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