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 / 1501
1500  |  1502
Subject: 
Still JAVA and LNP....
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Fri, 3 Nov 2000 00:50:40 GMT
Viewed: 
1520 times
  
hey all :) Sorry to bother again, but after limited uccess with getting JAVA
to cope with LNP, I've run into some (hopefully) simple problems,  I'm
having major problems with the checksum routine, this routine give me huge
integer nnumbers rather than the handy < 255 numbers in the packets.... I
realise that I'm doing something dumb, could someone point me in the right
way please....

short lnp_checksum(char data[], int  length)
{
       int  a = 255;
       int b = 255;
       int dIndex=0;
       while (length > 0)
      {
          System.out.print(new Integer(data[dIndex]).toString() + " ");
          a = (char)(a + data[dIndex++]);
          b = (char)(b + a);
          length--;
      }
   return (short)(a + (b << 8));
}
[Java excerpt]

I apologise for the terrible code, but I'm at that point where I'll try
anything to get a better understanding :) ..so its a work in progress ...see
casting <g> ...

And :) My IR tower keeps turning itself off, unless I send data to it, is
this the correct way to do this, or should I be ale to passively listen to
the world ?



Message has 2 Replies:
  Re: Still JAVA and LNP....
 
Umm in response to my own message, would someone be so kind as to explain the following <g> : // return (short)(a + (b << 8)); return (short)(a % 256); If I use the bottom line, discounting variable b, then my checksum is correct...otherwise it (...) (24 years ago, 3-Nov-00, to lugnet.robotics.rcx.legos)
  Re: Still JAVA and LNP....
 
(...) There is no way to passively listen to the world. This is good for batteries but bad in all other ways. So, your listening code should send a keep-alive on a regular basis to keep the tower from dying. No way around it :| Luis ---...--- "It's (...) (24 years ago, 3-Nov-00, to lugnet.robotics.rcx.legos)

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