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 / 3134
3133  |  3135
Subject: 
Re: LNP problem
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Tue, 28 Jan 2003 20:03:17 GMT
Viewed: 
3897 times
  
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 below, and how this works and where it goes?

I have a good understanding of programming, it's just this is a very new
area to me, and is truly very interesting,

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

Does anyone one know of any good books or websites for this topic?

So far I have BrickOS configured and running in cygwin, and I also have
winLNP downloaded and placed it in my brickOS directory like the site i was
reading told me to. But as for what to do now I am stuck.

If anyone could help with the above questions I would be most grateful.

Thanks

Andrew



Message has 1 Reply:
  Re: LNP problem
 
(...) I don't know anything about Windows, but I started using LNP on Linux with good results lately. It really isn't that hard once you get your first programm running ... :) I wrote a little remote-control/monitor app based on LNP. While for Gnome (...) (21 years ago, 29-Jan-03, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  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

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