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 / 2965
2964  |  2966
Subject: 
Re: LNP-problem...
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Thu, 21 Nov 2002 21:06:11 GMT
Viewed: 
2906 times
  
That looks ok to me.  But I'm no expert on LNP.

Here's a clip I use.  It looks a lot like what you're using.  It seems there may be a problem with your receive code.  I'm REAL shaky on that.  What does fputs do?

----
char *s;

s = "101";


if (strlen(s)>0) // send message
{
dsound_system(DSOUND_BEEP);
lnp_integrity_write(s,strlen(s));
s = "";
}
----


----- Original Message -----
From: Tom Wouters <aqua@no__spam.ulyssis.org>
Date: Thu, 21 Nov 2002 18:27:52 GMT
To: lugnet.robotics.rcx.legos@lugnet.com
Subject: Re: LNP-problem...


Steve Hassenplug wrote:
Why don't you post the code you're using.  Then we can tell you if it's a problem with the program.

ok this is the (relevant) code running on the rcx:



int main(int argc, char *argv[]) {
   char *p;
   init();
   execi(&PacketWatcher, 0, NULL, PRIO_NORMAL, DEFAULT_STACK_SIZE);
   execi(&Messenger, 0, NULL, PRIO_LOWEST, DEFAULT_STACK_SIZE);

   return 0;
}

int Messenger(int argc, char **argv){
   while(1){
     sleep(10);
     dsound_system(DSOUND_BEEP); //just to make sure we know the while
executes correctly
     result = lnp_integrity_write("sb", 2);

   }

}

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

the packetwatcher is just the thread that receives the messages from the
tower, that one works fine..

the code on the computer is the following:

#include <liblnp.h>
#include <stdio.h>
#include <stdlib.h>

void packet_handler(const unsigned char* data, unsigned char length);

/**
  * main functie van het test-programma,
  * dit laat ons toe gewoon strings naar het robotje te sturen
  *
  */
int main(int argc, char **argv){
   char *buffer, *b2;
   int result,len;
   int leng = 50;
   lnp_init(0,0,0,0, 0);

   lnp_integrity_set_handler(&packet_handler); //sets the packet handler
   //lnp_logical_range(1);


   b2 = malloc(leng+1);

   while(1){
     fputs("send::",stdout);
     fgets(b2,leng,stdin);

     len = strlen(b2) + 1;
     buffer = malloc(len + 2);
     memcpy(buffer, b2, len);
     result = lnp_integrity_write(buffer,len + 2);
     free(buffer);
   }
}

void packet_handler(const unsigned char* data, unsigned char length){
   fputs("\nrcv",stdout);
   fputs(data,stdout);
   fputs("\nsend::",stdout);
}

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

it basically should read commands to send to the rcx from stdin, en put
replies from the rcx to stdout but there's something wrong with it, if
the length of the string read from stdin is > 0 it sends the message
correctly en prompts for the new command, but if you accidently would
hit enter without anything there it will go crazy...

furthermore, although we can hear the beep of the rcx, lnpd never seems
to receive a message (not even an erroneous frame or so)

We just don't see where the problem might be...

Tom


--
_______________________________________________
Talk More, Pay Less with Net2Phone Direct(R), up to 1500 minutes free!
http://www.net2phone.com/cgi-bin/link.cgi?143



Message has 1 Reply:
  Re: LNP-problem...
 
(...) Hi, I'm Pieter and working with Tom on a project. I 've tried you're code but it doesn't work. To me the problem seems to be with lnpd. Here is it's log of the session. 0:Info > created lock file /var/lock/LCK..ttyS0 233:Info > running in (...) (22 years ago, 23-Nov-02, to lugnet.robotics.rcx.legos)

2 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