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 / 1361
1360  |  1362
Subject: 
legOS Addressing - Packet Handler
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Fri, 11 Aug 2000 10:19:48 GMT
Viewed: 
1187 times
  
Hi All

I have a very simple RCX legos program (which I've attached), that I'm having
difficulty with. I have compiled legOS with the default host address of 0 (0x00).
I am using WinLNP to send data to the RCX (simple short strings), but the RCX
will not recieve it.

The IR icon on the LCD illuminates, but the LCP display does not change. I have
simplified my program to just write a simple string to the LCD upon recieving
data,
but this does not work either.. Can anyone tell me if my attached code is
incorrect,
I am addressing my packet to host id 0 (as compiled) and port 1 (according to my
handler).

Thanks in advance,

Colin Ryan.

----------------Code Begins--------------- (short and sweet)


#include <conio.h>
#include <unistd.h>
#include <string.h>
#include <lnp.h>

#define PORT_ONE 1

static int quit = 0; /*end program button*/


/*------------------------------ LNP Handling functions
-----------------------------*/


/*Packet Handler for packets addresses to local port number 1*/
void addressHandlerPortOne(const unsigned char* data, unsigned char length,
unsigned char src) {

     cputs("prt1");
     sleep(1);
    /*I did have code here to write out the recieved data, but even this simpe
code won't work*/
     if (data[0] == 'q') quit = 1;
}


/*-----------------------------------------------------------------------------------*/

/*------------------------------ Main Body of Execution
-----------------------------*/
/*-----------------------------------------------------------------------------------*/

int main()
{

//Assign a handling function to a particular port number:
lnp_addressing_set_handler(PORT_ONE, addressHandlerPortOne);

cputs("Begin");

while(!quit)
{
   msleep(200);
  }
return 0;
}



Message has 1 Reply:
  Re: legOS Addressing - Packet Handler
 
(...) Take the sleep(1) out of the code! The function addressHandlerPortOne() is called from an interrupt, so you must not call any function which might cause a reschedule (which sleep() definitely does). You can do all this by having a separate (...) (24 years ago, 11-Aug-00, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  Re: lnpd
 
(...) (URL) "Do not go gentle into that good night. Rage, rage against the dying of the light." - Dylan Thomas Mike Ash - (URL), <mailto:mail@mikeash.com> (24 years ago, 9-Aug-00, 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