To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcxOpen lugnet.robotics.rcx in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / 1858
1857  |  1859
Subject: 
LNPD problem
Newsgroups: 
lugnet.robotics.rcx
Date: 
Tue, 3 Dec 2002 22:31:06 GMT
Viewed: 
3112 times
  
Hi there,

I still don't manage to send any packages from the rcx to the PC.

I attached the client and the "receiver program" and here is a
fragment of the lnpd log:


   148032:Client > connection 1 from host 127.0.0.1, port 33485
    148039:Logical > Keepalive sent
    151548:Logical > Keepalive sent
    155058:Logical > Keepalive sent
    155796:Integrity > Header f0
    155801:Integrity > Length 3
    155819:Integrity > Integrity reset
    155819:Logical > Frame Error
    158559:Logical > Keepalive sent
    162068:Logical > Keepalive sent
    165580:Logical > Keepalive sent
    165831:Integrity > Header f0
    165835:Integrity > Length 3
    165854:Integrity > Integrity reset
    165854:Logical > Frame Error
    169088:Logical > Keepalive sent
    172588:Logical > Keepalive sent
    175865:Integrity > Header f0
    175870:Integrity > Length 3
    175888:Integrity > Integrity reset
    175888:Logical > Frame Error
    176098:Logical > Keepalive sent
    179608:Logical > Keepalive sent
    183109:Logical > Keepalive sent
    185900:Integrity > Header f0
    185904:Integrity > Length 3
    185923:Integrity > Integrity reset
    185923:Logical > Frame Error
    186618:Logical > Keepalive sent
    190128:Logical > Keepalive sent
    193638:Logical > Keepalive sent
    195935:Integrity > Header f0
    195939:Integrity > Length 3
    195958:Integrity > Integrity reset
    195958:Logical > Frame Error
    197148:Logical > Keepalive sent
    200648:Logical > Keepalive sent
    204158:Logical > Keepalive sent
    205969:Integrity > Header f0
    205974:Integrity > Length 3
    205992:Integrity > Integrity reset
    205992:Logical > Frame Error


A frame error occurs every time.

Isn't there someone out there who has got the same kind of problems
and found a solution for them?

These programs are tested on

-) Pentium III  667 Mhz running debian 3.0 (testing actually) gnu/linux
2.4.18 2.4.19 & 2.4.20 kernel's.
   with brickOS/legOs 0.24 - 0.26.08

and on a pentium celeron 400 Mhz machine. with more ore less the same
configuration.

Has anyone some kind of clue please?

Your help would be greatly appreciated.


thanks in advance,

Pieter

===File ~/thesis/client/client.c============================
#include <conio.h>
#include <unistd.h>
#include <dsensor.h>
#include <dmotor.h>
#include <sys/lcd.h>
#include <lnp/lnp.h>
#include <lnp/lnp-logical.h>
#include <string.h>
#include <dsound.h>
#define NOTES_LENGTH 126

int  gNewData = 0;
char  gMessagingData[256];
int gDataLength;
note_t notes[NOTES_LENGTH];
static const char message[] = "fo";

static char ntest[] = {
  'p', PITCH_D4,  2, PITCH_C4,  1,  PITCH_D4,  1,
  PITCH_F4,  1, PITCH_D4,  1,  PITCH_D4,  2,
  PITCH_F4,  2, PITCH_G4,  1,  PITCH_C5,  1,
  PITCH_A4,  2, PITCH_D4,  2,  PITCH_END, 0

};

/* copy's the notes in the given array into the notes array
*/
void notecp(note_t *pnotes){
  int i = 0;
  while (pnotes->pitch != PITCH_END && i < NOTES_LENGTH)
    notes[i++] = *pnotes++;
}

void init(void);
void DisplayHandler(char *command);
void MotorHandler(char* p);
MotorDirection mdir(char c);
void SoundHandler(char *command);


void packet_handler(const unsigned char* data, unsigned char length){
  dsound_system(DSOUND_BEEP);
  if (gNewData == 0){
    memcpy(gMessagingData, data, length);
    gDataLength = length;
    gNewData = 1;
  }
}

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

wakeup_t WaitForData(wakeup_t data){
  return gNewData;
}

cputs("go");

  while(1){
    wait_event(&WaitForData, 0);
    dsound_system(DSOUND_BEEP);
    switch(gMessagingData[0]){
    case 'm': MotorHandler(gMessagingData+1);
      break;
    case 'd': DisplayHandler(gMessagingData+1);
      break;
    case 's':
      SoundHandler(gMessagingData+1);
      break;
    }

    gNewData = 0;
    }
}

void SoundHandler(char *command){
  char *p;
  switch(*command){
    // plays the notes after it
  case 'p':

    p = command+1;
    notecp( (note_t *) p);
    dsound_play(notes);
    break;
    // play a pre defined tune
  case 't':
    break;
  case  'b':
    dsound_system(DSOUND_BEEP);
    //beep
    break;

  }
}

//controls the motors
void MotorHandler(char *command){
  switch(command[0]){
    // controls the speed of the motor
  case 's':
    motor_a_speed(command[1]);
    motor_b_speed(command[2]);
    motor_c_speed(command[3]);

    break;
    // controls the direction of the motor
  case 'd':
    motor_a_dir(mdir(command[1]));
    motor_b_dir(mdir(command[2]));
    motor_c_dir(mdir(command[3]));
    break;

    // power on or power off
  case 'p':   break;
    // timed power on
  case 't':  break;
  }
}

//determine the direction of the moters
MotorDirection mdir(char c){

  switch (c){

  case 'f' : return fwd;
  case 'r' : return rev;
  case 'o' : return off;
  case 'b' : return brake;
  }
}

//display stuff (max 5 chars) on the rcx display
void DisplayHandler(char *command){
  char buf[5];
  buf[0]=' ';
  buf[1]=' ';
  buf[2]=' ';
  buf[3]=' ';
  buf[4]=' ';
  memcpy(buf,command,5);
  cputs(buf);
}

int Messenger(int argc, char **argv){
  int len;
  len = strlen(message);
  while(1){
    sleep(10);
    dsound_system(DSOUND_BEEP);
    lnp_integrity_write(message, len+1);
    cputs("send");
  }

}

int main(int argc, char *argv[]) {
  init();
  dsound_system(DSOUND_BEEP);
  execi(&PacketWatcher, 0, NULL, PRIO_NORMAL, DEFAULT_STACK_SIZE);
  execi(&Messenger, 0, NULL, PRIO_LOWEST, DEFAULT_STACK_SIZE);
  return 0;
}

void init(void){
  lnp_integrity_set_handler(&packet_handler); //sets the packet handler
  lnp_logical_range(1);
}


============================================================

===File ~/thesis/client/command.c===========================
#include <liblnp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


void integrity_handler(const unsigned char* data, unsigned char length){

  char *b = malloc(length+1);

  memcpy(b, data, length);
  //b[length] = '\0';

  printf("We ontvangen een package met inhoud %d \n", *b);
  free(b);

}


void init(){

  lnp_integrity_set_handler(integrity_handler);

}

/**
* main functie van het test-programma,
* dit laat ons toe gewoon strings naar het robotje te sturen
*
*/
int main(int argc, char **argv){

  char *buffer, *b2;
  int result,len;
  int leng = 50;
  lnp_init(0,0,0,0, 0);
  b2 = malloc(leng+1);

  init();

  while(1){
    fputs("send::",stdout);
    fgets(b2,leng,stdin);

    len = strlen(b2) + 1;
    buffer = malloc(len);
    memcpy(buffer, b2, len);
    result = lnp_integrity_write(buffer,len);
    printf("Het resultaat van write is %i \n", result);
    free(buffer);
  }



}
============================================================



Message has 2 Replies:
  Re: LNPD problem
 
Hi Pieter, I'll take a shot at it... It's possible you may be experiencing a transmission problem on the RCX side. That's not to say that your RCX can't transmit IR data correctly... obviously it can since you are able to download BrickOS and that (...) (22 years ago, 4-Dec-02, to lugnet.robotics.rcx)
  Re: LNPD problem
 
At times I have experienced some issues wth using lnp; I was generally able to improve or elliminate the problem by increasing the packet_handler task priority... or lowering all other tasks to be less than the packet handler. (This includes kernel (...) (22 years ago, 4-Dec-02, to lugnet.robotics.rcx)

3 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