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 / 3114
3113  |  3115
Subject: 
I cannot send more than 6 bytes with lnpd
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Tue, 21 Jan 2003 17:43:59 GMT
Viewed: 
3371 times
  
I'm trying to send some data from the RCX to my computer, using lnpd,
but I have the following problem: it seems that I cannot send more than
6/7 bytes, because after this limit I have a lot of errors from lpnd
(see the log below). The tower and the RCX are 20 cm far, and they were
not moved in any experiment.
I'm using BrickOS 0.2.6.09.newConf2 and lpnd downloaded from
http://legos.sourceforge.net/files/linux/LNPD/.
I thought it was battery problem (maybe too low either on the tower or
on th RCX), but I can download brickOS and my programs, so why can't I
send 10 bytes?

Any suggestion? Am I doing something wrong?

Halva

Here is the program that runs on the RCX:

--------------------------------------------------
#define MY_PORT 2
#define MY_ADDR 1
#define DEST_HOST 0x8
#define DEST_PORT 0x7
#define DEST_ADDR ( DEST_HOST << 4 | DEST_PORT )

#define SEND_N_BYTES 10

int main ( int argc, char** argv ) {

   unsigned char buf[15];
/*   near range */
   lnp_logical_range( 1 );

/*   lnp_set_hostaddr ( MY_ADDR ); */

   ds_active (&SENSOR_1);
   while (!shutdown_requested() ){
     unsigned val = SENSOR_1;
     unsigned light = LIGHT_1;
     size_t gap = sizeof(val);
     memcpy( buf, &val, gap );
     buf[gap] = 0x0f;
     buf[gap+1] = 0xf0;
     memcpy( buf+gap+2, &light, sizeof(light) );
     lnp_addressing_write ( buf, SEND_N_BYTES, DEST_ADDR, MY_PORT );
     cputw( light );
     sleep(2);
   }
   ds_passive(&SENSOR_1);

   exit(0);
}
-----------------------------------------------

Here is what I run on my computer:

-----------------------------------------------
#define MY_PORT 7
#define MSG_BUF_LENGTH 16

char * message = NULL;

void packet_handler (const unsigned char * from_msg, unsigned char size,
unsigned char from) {
   int loop = 0;
   memset( message, 0x0, MSG_BUF_LENGTH );
   memcpy( message, from_msg, (size_t) size );
   printf( "message from %hX length %d: ", from, size );
   for ( loop = 0; loop <= MSG_BUF_LENGTH; loop++ )
     printf( "%.2hX ", (unsigned char)message[loop] );
   printf( "\n" );
   fflush( stdout );
}

int main ( int argv, char** argc ) {
   switch ( lnp_init(0,0,0,0,0) ) {
   case INIT_OK:
     break;
   case INIT_BAD_PARAM: {
     fprintf(stderr,"returned INIT_BAD_PARAM\n");
     exit(1);
   } break;
   case INIT_ERROR: {
     fprintf(stderr,"returned INIT_ERROR\n");
     exit(2);
   } break;
   }

   message = (char *) malloc(MSG_BUF_LENGTH);
   lnp_addressing_set_handler( MY_PORT, packet_handler );
   while (1) {
   }
   free( message );
   lnp_shutdown();

   return 0;
}
------------------------
Finally the log file:
------------------------
        234:Info > running in Timesharing Mode
       1799:Integrity > Header f1
       1799:Integrity > Length 12
       1834:Logical > Inter-Byte Timeout
       1834:Integrity > Integrity reset
       2871:Client > connection 0 from host 127.0.0.1, port 34132
       3537:Logical > Keepalive sent
       3922:Integrity > Header f1
       3922:Integrity > Length 12
       3957:Logical > Inter-Byte Timeout
       3957:Integrity > Integrity reset
       6045:Integrity > Header f1
       6045:Integrity > Length 12
       6075:Logical > Inter-Byte Timeout
       6075:Integrity > Integrity reset
       7043:Logical > Keepalive sent
  ....



1 Message 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