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 / 2964
2963  |  2965
Subject: 
Re: LNP-problem...
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Thu, 21 Nov 2002 18:27:52 GMT
Viewed: 
3252 times
  
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



Message is in Reply To:
  Re: LNP-problem...
 
Why don't you post the code you're using. Then we can tell you if it's a problem with the program. Steve ----- Original Message ----- From: Tom Wouters <aqua@no__spam.ulyssis.org> Date: Wed, 20 Nov 2002 17:21:47 GMT To: (...) (22 years ago, 20-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