To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.javaOpen lugnet.robotics.rcx.java in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / Java / 287
286  |  288
Subject: 
Re: More than 1 integer in a data packet?
Newsgroups: 
lugnet.robotics.rcx.java
Date: 
Thu, 2 Oct 2003 15:21:23 GMT
Viewed: 
5024 times
  
In lugnet.robotics.rcx.java, Tyler Derkin wrote:
Does anyone know if I can send more than 1 byte/integer per packet
between the PC and RCX.

I'm not a leJOS expert by any stretch of the imagination.  But I think I can
help.

From what I understand of the rcxcomm
package API, one can only send an integer at a time.

That is not a correct understanding of the rcxcomm package API.  The
RCXOutputStream class, for example, which descends from java.io.OutputStream
inherits all the methods of that class.

So, while the page describing RCXOutputStream only directly mentions the
RCXOutputStream.write(int b) method it has links to the methods it inherits from
OutputStream:

RCXOutputStream.write(byte[] b);
RCXOutputStream.write(byte[] b, int off, int len);

If so, is there a way of sending, say an array of integers,
within a packet?

From the leJOS documentation there are several choices in addition to
RCXOutputStream.

static boolean LNP.addressingWrite(byte[] packet, int len, byte dest, byte
source);

Sends packet of up to 255 bytes to the destination address from the source
address. The source address is used for replying to the packet.

Parameters:

packet - the packet to send
len - the length of the packet
dest - the destination machine and port
source - the source machine and address

Returns:

true for successful send, else false, e.g. for collision detection


static boolean LLC.sendBytes(byte[] buf, int len);

Send a number of bytes and wait for completion of transmission

Parameters:

buf - the array of bytes to send
len - the number of bytes to send

Returns:

true if the send is successful, else false

Note that if you use LLC "The init() method must be called to take over driving
the IR unit from the ROM routines. Once this is done, the program cannot use the
Serial class."

Hope this helps.

John Hansen



Message is in Reply To:
  More than 1 integer in a data packet?
 
Hi there, Does anyone know if I can send more than 1 byte/integer per packet between the PC and RCX. From what I understand of the rcxcomm package API, one can only send an integer at a time. Also, the example supplied with the rcxcomm package only (...) (21 years ago, 1-Oct-03, to lugnet.robotics.rcx.java)

2 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