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 / 1224
1223  |  1225
Subject: 
Re: LegOS + Lego Remote
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Tue, 18 Jul 2000 15:09:55 GMT
Viewed: 
1945 times
  
here are the diffs, apply against 0.2.4...
um, not sure how to do multi-file diffs, so there are 5 files here; note that
dll.exe needs to be rebuilt to handle the changed parity...

still looking in the kernel for a clean place to stick in timeout code, for now
that has to be done in user code (unless you just want the 0 to 1 pulses)...

call lnp_remote_set_handler with your remote handler as the callback...

chris



patch against util/dll-src/rcxtty.c

126c126
<     dcb.Parity   = 0; // 0-4=no,odd,even,mark,space
---
    dcb.Parity   = 1;                   // 0-4=no,odd,even,mark,space


patch against kernel/lnp-logical.c

212c212
<   S_MR =SMR_P_NONE;
---
  S_MR =SMR_P_ODD;


patch against include/lnp/lnp.h

48a49,53
//! handler for remote
/*! arguments are (buttonstate)
*/
typedef void (*lnp_remote_handler_t) (unsigned int);

54a60,62
//! dummy remote packet handler
#define LNP_DUMMY_REMOTE ((lnp_remote_handler_t)0)

66a75,77
//! packets from remote have no ports
extern lnp_remote_handler_t lnp_remote_handler;

84a96,101
}

//! set the remote packet handler
extern inline void lnp_remote_set_handler(lnp_remote_handler_t handler)
{
  lnp_remote_handler = handler;


patch against include/lnp/sys/lnp.h

44a45,47
//! length of header from remote, -1 because first byte is used to id • sequence
#define LNP_REMOTE_HEADER_LENGTH (5-1)

50c53,65
<   LNPwaitCRC
---
  LNPwaitCRC,

//! states when waiting for remote
  LNPwaitRH1, // note that first byte is consumed by LNPwaitHeader
  LNPwaitRH2,
  LNPwaitRH3,
  LNPwaitRH4,
  LNPwaitRB0,
  LNPwaitRB0I,
  LNPwaitRB1,
  LNPwaitRB1I,
  LNPwaitRC,
  LNPwaitRCI,
68d82
<


patch against kernel/lnp.c

72a73,75
//! remote handler
lnp_remote_handler_t lnp_remote_handler;

75a79,87
//! remote header bytes excluding first byte
const unsigned char lnp_remote_sequence[LNP_REMOTE_HEADER_LENGTH] = • {0xff,0x00,0xd2,0x2d};

//! button masks from remote
unsigned char lnp_remote_button0;
unsigned char lnp_remote_button1;

//! checksum from remote
unsigned char lnp_remote_checksum; • 194a207,211
      if ( b == 0x55 )
      {
        lnp_integrity_state = LNPwaitRH1;
      }
      else • 225a243,313

    // state machine to handle remote
    case LNPwaitRH1:
    case LNPwaitRH2:
    case LNPwaitRH3:
    case LNPwaitRH4:
      // waiting for header bytes
      // compressed code to save mem
      if ( b == lnp_remote_sequence[ lnp_integrity_state-LNPwaitRH1 ] )
      {
        lnp_integrity_state++;
      }
      else
      {
        lnp_integrity_state = LNPwaitHeader;
      };
      break;

    case LNPwaitRB0:
      lnp_remote_button0 = b;
      lnp_integrity_state++;
      break;

    case LNPwaitRB0I:
      if ( (0xff-(unsigned)b) == lnp_remote_button0 )
      {
        lnp_integrity_state++;
      }
      else
      {
        lnp_integrity_state = LNPwaitHeader;
      };
      break;

    case LNPwaitRB1:
      lnp_remote_button1 = b;
      lnp_integrity_state++;
      break;

    case LNPwaitRB1I:
      if ( (0xff-(unsigned)b) == lnp_remote_button1 )
      {
        lnp_integrity_state++;
      }
      else
      {
        lnp_integrity_state = LNPwaitHeader;
      };
      break;

    case LNPwaitRC:
      lnp_remote_checksum = 0xd2 + lnp_remote_button0 + lnp_remote_button1;
      if ( b == lnp_remote_checksum )
      {
        lnp_integrity_state++;
      }
      else
      {
        lnp_integrity_state = LNPwaitHeader;
      };

      break;

    case LNPwaitRCI:
      // if checksum valid and remote handler has been installed, call remote • handler
      if ( (b == 0xff - lnp_remote_checksum) && (lnp_remote_handler) )
      {
        lnp_remote_handler( (lnp_remote_button0<<8)+lnp_remote_button1 );
      }; // else just drop remote info
      lnp_integrity_state = LNPwaitHeader;
      break; • 286a375
  lnp_remote_handler=LNP_DUMMY_REMOTE;



Message is in Reply To:
  Re: LegOS + Lego Remote
 
Sure, I'll clean it up and post the diffs tomorrow... chris (...) (24 years ago, 17-Jul-00, to lugnet.robotics.rcx.legos)

7 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