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 / 3061
3060  |  3062
Subject: 
LNP problem
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Sun, 5 Jan 2003 06:45:16 GMT
Viewed: 
3246 times
  
Hi,

I'm just getting started using LNP, read the howto and tried to play
around with the examples therein. However, somthing goes wrong. I have a
little programm on the RCX increasing a counter every second, displaying
it's value on the lCD and sending it to the PC. On the PC side this
value should be displayed as soon as it's reveived.

The RCX side seems to work, at least the counter is increased, displayed
and something is sent out the IR port. The PC side however doesn't
display anything. When I look into lnpd's log, I see that eveytime the
RCX send something, I get errors:

    [...]
    238738:Logical > Frame Error
    239791:Integrity > Integrity reset
    239791:Logical > Frame Error
    239795:Integrity > Integrity reset
    239795:Logical > Frame Error
    239799:Integrity > Integrity reset
    239799:Logical > Frame Error
    239803:Integrity > Integrity reset
    239803:Logical > Frame Error
    239807:Integrity > Integrity reset
    [...]

Looks like something is received, just not understood. I'm running
brickOS-0.2.6.09.newConf2 on a Linux system and have no problems
programming the RCX otherwise. I got lnpd from
http://legos.sourceforge.net/files/linux/LNPD/, unfortunatly there is no
version number. RCX is 2.0 and I'm using a serial IR tower.

Below is the code I used for both, RCX and PC side. Any help is
appreciated!

Thanks,
BB


RCX Code:

        #include <lnp.h>
        #include <conio.h>
        #include <string.h>
        #include <lnp-logical.h>
        #include <dkey.h>

        #define MY_PORT 2
        #define DEST_HOST 0x8
        #define DEST_PORT 0x7
        #define DEST_PORT_2 0x8
        #define DEST_ADDR ( DEST_HOST << 4 | DEST_PORT )
        #define DEST_ADDR_2 ( DEST_HOST << 4 | DEST_PORT_2 )

        void printInt(int i)
        {
          char buf[3];
          int result;

          buf[0] = 'i';
          memcpy(buf + 1, &i, 2);
          result = lnp_addressing_write(buf,3, DEST_ADDR, MY_PORT);
        }
        wakeup_t prgmKeyCheck(wakeup_t data)
        {
            return dkey == KEY_PRGM;
        }

        int main ( int argc, char **argv ) {
          int c=0;
          lnp_logical_range ( 0 );
          while ( 1 ) {
            if (prgmKeyCheck(0)) break;
            printInt ( c );
            cputw( c++ );
            sleep ( 1 );
          }
          cputs ( "done" );
          return 0;
        }

PC code:

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

        #define MY_PORT 2
        #define DEST_HOST 0x8
        #define DEST_PORT 0x7
        #define DEST_PORT_2 0x8
        #define DEST_ADDR ( DEST_HOST << 4 | DEST_PORT )
        #define DEST_ADDR_2 ( DEST_HOST << 4 | DEST_PORT_2 )

        void addr_handler(const unsigned char* data,unsigned char
        length, unsigned char src)
        {
          int  temp;
          char *ptr;

          switch(data[0])
          {
          case 's':
            puts(data + 1);
            break;
          case 'i':
            ptr = (char *)temp;
            ptr[0] = data[2];
            ptr[1] = data[1];
            printf("%d", temp);
            break;
          }
        }

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

          if ( lnp_init ( 0, 0, 0, 0, 0 ) ) {
            perror ( "lnp_init" );
            exit(1);
          } else {
            printf ( "init OK\n" );
          }

          lnp_addressing_set_handler (MY_PORT, addr_handler );

          while ( 1 ) {};

          return 0;
        }



Message has 2 Replies:
  Re: LNP problem
 
(...) What about ptr = (char *)&temp; Regards Michael (21 years ago, 5-Jan-03, to lugnet.robotics.rcx.legos)
  Re: LNP problem
 
(...) Ok. This is indeed the result if you run the original LNP package. There are several problems with your sources, too. So try the following to get things done: First, go to the lnpd subdir and edit rcxtty.c. In function tty_init you find a line (...) (21 years ago, 5-Jan-03, to lugnet.robotics.rcx.legos)

9 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