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 / 3066
3065  |  3067
Subject: 
Re: LNP problem
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Sun, 5 Jan 2003 18:21:30 GMT
Viewed: 
4038 times
  
Bodo Bauer wrote:

    [...]
    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
    [...]


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 with:

    ios.c_cflag = CREAD | ...

it should read:

ios.c_cflag = CREAD | CLOCAL | CS8 | (highspeed ? 0 : PARENB | PARODD);

You could take a look at the rcxtty.c file in the util/dll-src subdir of
brickOS, you will find the same initialization. This will wipe out the
frame errors. But your program won't run, anyway. You should change some
things so you will get:

PC PROGRAM:
===========================================================
#include <liblnp.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <string.h>

#define MY_PORT 7

void addr_handler(const unsigned char* data,unsigned char length,
unsigned char src)
{
    switch(data[0]) {
       case 's':
          printf( "%s\n", &data[1] );
          break;
       case 'i':
          printf( "%d\n", data[1] * 256 +  data[2] );
          break;
       default:
          printf( "unknown type\n" );
       }
       fflush( stdout );
    }

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;
}

----------------------------------------------------------
RCX PROGRAM:
==========================================================
#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_ADDR ( DEST_HOST << 4 | DEST_PORT )

unsigned char buf[3];
unsigned char len = 3;

void printInt(int i)
{
  int result;

    buf[0] = 'i';
    memcpy(buf + 1, &i, 2);
    result = lnp_addressing_write( buf, len, 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++ );
       msleep ( 200 );
    }
    cputs ( "done" );
    return 0;
}
-------------------------------------------------------------



Message has 2 Replies:
  Re: LNP problem
 
(...) This works in deed! Thank you so much Michael! No way I would have found this myself. BB (21 years ago, 5-Jan-03, to lugnet.robotics.rcx.legos)
  Re: LNP problem
 
Hi everyone, I have to say I have found these messages very interesting, and was wanting to use lnp myself but i do not know where to write and make my programs. And I would also like to find out more about how you write the pc code and the rcx code (...) (21 years ago, 28-Jan-03, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  LNP problem
 
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 (...) (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

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR