Subject:
|
more networking questions
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Fri, 26 Nov 1999 08:50:18 GMT
|
Viewed:
|
990 times
|
| |
| |
Will the lnp task which is doing the receiving only wake up the next layer up
if the message is properly formed. Currently here is my program
-- start of longish bit of code --
#include <conio.h>
#include <unistd.h>
#include <dsensor.h>
#include <dmotor.h>
#include <sys/lnp.h>
#include <semaphore.h>
#include <sys/tm.h>
#include <string.h>
#include <stdlib.h>
static unsigned char buffer[256]; //!< packet receive buffer
volatile unsigned char packet_len; //!< packet length
volatile unsigned char packet_src; //!< packet sender
static sem_t packet_sem; //!< synchronization semaphore
//! packet handler, called from interrupt
/*! makes copy and wakes parser task.
*/
static void packet_producer(const unsigned char *data,
unsigned char length,
unsigned char src) {
// old packet still unhandled or empty packet?
//
if(packet_len>0 || length==0)
return;
memcpy(buffer,data,length);
packet_len=length;
packet_src=src;
sem_post(&packet_sem);
}
//! packet command parser task
static int packet_consumer(int argc, char *argv[])
{
char msg[8];
unsigned char cmd;
while(1)
{
// wait for new packet
packet_len=0;
sem_wait(&packet_sem);
cputs("88");
lcd_refresh();
cmd=buffer[0];
}
return 0;
}//end consumer task
// the main
int main(int argc, char *argv[])
{
lnp_init();
packet_len=0;
sem_init(&packet_sem,0,0);
execi(&packet_consumer,0,0,PRIO_HIGHEST,DEFAULT_STACK_SIZE);
lnp_addressing_set_handler(0,&packet_producer);
tm_start(); //start the task manager
return 0;
}
-- end of longish bit of code.
So my theory is that when the RCX receives something it will display 88 on the
screen (hey not very exciting but as I said I am just trying to get something
going).
Anyhow to test this I have been just dumping garbage out onto the IR tower
(using cat textfile > /dev/ttyS0). Now I just came to the realisation that
maybe another layer IS receiving this but not passing it up because it is just
junk and not a properly formed message from another RCX running legOS. If this
is the case then that is niceish because maybe then I can use another rcx to
send some stuff and then my first one will pick it up :)
Basically again HELP with simple networking would be appreciated :)
thanks
michael
|
|
Message has 1 Reply: | | Re: more networking questions
|
| (...) Your msg is propably not well formed enough. Just fetch a copy of nqc_src_1.2 or higher (unix, mac and lesser OS-es available) and you end up with a command ./nqc -msg XXX where XXX is a magic number :-) Which translates to a valid msg. If you (...) (25 years ago, 26-Nov-99, to lugnet.robotics.rcx.legos)
|
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|