To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.spyboticsOpen lugnet.robotics.spybotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Spybotics / 315
Subject: 
RCX to Spy messages thru IR communications route
Newsgroups: 
lugnet.robotics.spybotics
Date: 
Sat, 13 Mar 2004 23:33:45 GMT
Viewed: 
6565 times
  
Has anyone got messaging from the RCX2 to Spybotics working? Would be great to
hear if you have!


Subject: 
Re: RCX to Spy messages thru IR communications route
Newsgroups: 
lugnet.robotics.spybotics
Date: 
Tue, 16 Mar 2004 21:58:03 GMT
Viewed: 
6737 times
  
In lugnet.robotics.spybotics, Ed Parrent wrote:
Has anyone got messaging from the RCX2 to Spybotics working? Would be great to
hear if you have!

Mark Riley wrote a program quite a while ago that sends IR messages to a Spybot
from an RCX (http://news.lugnet.com/robotics/spybotics/?n=56).  The receiver
side of this (running on the Spybot) is implemented in his post in MindScript.
I just posted a message a few minutes ago which contains an NQC port (with some
modifications) of Mark's MindScript program.

To send a message back to the RCX you can use SendRCXMessage.

Let us all know how it works out for you.

John Hansen
http://bricxcc.sourceforge.net/


Subject: 
Re: RCX to Spy messages thru IR communications route
Newsgroups: 
lugnet.robotics.spybotics
Date: 
Fri, 19 Mar 2004 03:07:33 GMT
Viewed: 
6760 times
  
In lugnet.robotics.spybotics, John Hansen wrote:
Has anyone got messaging from the RCX2 to Spybotics working?
Mark Riley wrote a program quite a while ago that sends IR messages to a Spybot
from an RCX (http://news.lugnet.com/robotics/spybotics/?n=56).  The receiver
side of this (running on the Spybot) is implemented ...
John Hansen
http://bricxcc.sourceforge.net/

John:
Thx for pointing out the past 'Riley' post, and especially for your timely and
very astute info. You folks, and you J.H. are 'right-on' once again! Yes it
works, but SPY seems to react only to very specific code strings (message A:
byte 0=0x92, byte1=0x23; message B: byte 0=0x92, byte1=0xab; ... etc.), and
immediately performs the message code! (The two messages [above] are two
separate SPY led animations). I am looking for a way to send a more general
number code IR message from the RCX  to Spy (such as in your RCX NQC program of
March 16, and use the sent 'message parameter' from the RCX, generated by an RCX
actively running program, as a 'process parameter' in another program, actively
running on the SPYBOT). Have not got that solved directly (short of time coding
a combination, say of one of the above mentioned messages). Do you SPY fans out
there have anymore thoughts? We have SPY pulling an 'RCX in a small cart'
around, with both handling navigation/logic/sensing tasks.
Increasing the RCX TxPower to HI, makes the RCX messaging from the cart (behind
Snaptrack SPY) really quite solid. In fact, SPY jumps to an uncoupled RCX cart
20 ft. away!
Gramps Eddie & Grandson CJ


Subject: 
Re: RCX to Spy messages thru IR communications route
Newsgroups: 
lugnet.robotics.spybotics
Date: 
Wed, 24 Mar 2004 02:23:39 GMT
Viewed: 
6982 times
  
In lugnet.robotics.spybotics, Ed Parrent wrote:
Yes it
works, but SPY seems to react only to very specific code strings (message A:
byte 0=0x92, byte1=0x23; message B: byte 0=0x92, byte1=0xab; ... etc.), and
immediately performs the message code! (The two messages [above] are two
separate SPY led animations). I am looking for a way to send a more general
number code IR message from the RCX  to Spy

Okay, after banging my head against this for WAY too long I think I have finally
figured out (somewhat) a few things that were previously completely lost to my
understanding.

If you want an RCX (running RCX2 firmware) to simulate a Spybot Ping you can use
the following code:

  SetSerialComm(SERIAL_COMM_4800|SERIAL_COMM_76KHZ);
  SetSerialPacket(SERIAL_PACKET_DEFAULT);
  SetSerialData(0,0x80); // sometimes this is 0x81.  I don't know why
  SetSerialData(1,0xd8); // my ID
  SetSerialData(2,0x00); // my ping info
  SetSerialData(3,0xa8); // checksum (adjust so that sum of all 4 == 0)
  SendSerial(0,4);

If you want to send a Spybot message to a Spybot using an RCX (running the RCX2
firmware) you can use the following code:

  SetSerialComm(SERIAL_COMM_4800|SERIAL_COMM_76KHZ);
  SetSerialPacket(SERIAL_PACKET_DEFAULT);
  SetSerialData(0,0x8a); // broadcast
//  SetSerialData(0,0x89); // linkcast
//  SetSerialData(0,0x88); // individual message
  SetSerialData(1,0xd8); // my ID
  SetSerialData(2,0x04); // my ping info (when broadcasting)
//  SetSerialData(2,0x04); // linkcast link-id (when linkcasting)
//  SetSerialData(2,0x04); // id of a bot at an index in the relation table
  SetSerialData(3,0x40); // command byte
  SetSerialData(4,0x40); // hi byte
  SetSerialData(5,0x40); // lo byte
  SetSerialData(6,0xda); // checksum (adjust so that sum of all 7 == 0)
  SendSerial(0,7);

Now we need somebody really smart to write a function for the built-in API that
works something like SendSpybotMessage in the Spybot API.  Here's my feeble stab
at it:

#define MSG_BROADCAST 0x8a
#define MSG_LINKCAST 0x89
#define MSG_DIRECT 0x88

__nolist void SendSpybotMessage(const int &nMode, const int &nMyID,
  const int &nAddress, const int &nCmd, const int &nHiByte, const int &nLoByte)
{
  SetSerialComm(SERIAL_COMM_4800|SERIAL_COMM_76KHZ);
  SetSerialPacket(SERIAL_PACKET_DEFAULT);
  SetSerialData(0,nMode);
  SetSerialData(1,nMyID);
  SetSerialData(2,nAddress);
  SetSerialData(3,nCmd);
  SetSerialData(4,nHiByte);
  SetSerialData(5,nLoByte);
  SetSerialData(6,0x100-((nMode+nMyID+nAddress+nCmd+nHiByte+nLoByte)&0xff));
  SendSerial(0,7);
}


I have tried this with broadcasting (0x8a) and the Spybot receives a message as
expected.  I haven't figured out how to get linkcast or directed message to
work.  It might require doing a simulated ping to get the RCX into the Spybot's
world relation table with its own ping ID.  The linkcast mode also might require
knowing the Spybot's link-id.

I figured this stuff out by monitoring the IR received by the tower when I had a
Spybot send out messages using SendMessage and the Mindscript equivalent of that
built-in subroutine (which you can find in the postdemo program in the
MindStorms SDK help file).  I modified my RCXTool program so that it can monitor
the Spybot IR output.  I tried monitoring using the ScriptEd tool from LEGO but
I couldn't get it to work for some reason.

I also discovered that when you set the Spybot serial type (SetSerialType) using
SERIAL_TYPE_USER it just outputs the 4 raw bytes (index, cmd, hi, lo) but when
you set it to SERIAL_TYPE_SPYBOT it outputs the 7 byte sequence discussed above
on the call to SendSerial when using the Spybot NQC API.  I presume something
analogous occurs when you switch to SERIAL_TYPE_RC.  That doesn't seem to be the
case for SERIAL_TYPE_RCX, however.

Hopefully someone will find this useful.

John Hansen
http://bricxcc.sourceforge.net/


Subject: 
Re: RCX to Spy messages thru IR communications route
Newsgroups: 
lugnet.robotics.spybotics
Date: 
Thu, 25 Mar 2004 14:47:48 GMT
Viewed: 
6904 times
  
In lugnet.robotics.spybotics, John Hansen wrote:
  SetSerialData(0,0x80); // sometimes this is 0x81.  I don't know why

Hi John,

I think the low nibble of the first byte contains the Link ID of the Spybot.  It
is zero if the Spybot is not linked to a controller.  1 if it is linked to
controller 1, 2 if controller 2, etc.  This should be easy to double check with
your IR monitor setup.

--Jay


Subject: 
Re: RCX to Spy messages thru IR communications route
Newsgroups: 
lugnet.robotics.spybotics, lugnet.robotics, lugnet.robotics.rcx, lugnet.robotics.rcx.nqc
Date: 
Thu, 25 Mar 2004 18:02:42 GMT
Viewed: 
11147 times
  
In lugnet.robotics.spybotics, Jay Francis wrote:
In lugnet.robotics.spybotics, John Hansen wrote:
SetSerialData(0,0x80); // sometimes this is 0x81.  I don't know why

I think the low nibble of the first byte contains the Link ID of the Spybot.  It
is zero if the Spybot is not linked to a controller.  1 if it is linked to
controller 1, 2 if controller 2, etc.  This should be easy to double check with
your IR monitor setup.

Yes, that is what another person told me via email yesterday.  So a ping
simulation function for an RCX running the RCX2 firmware could be:

// nLinkID = 0-7, where 0 = no link, 7 = pc link, 1-6 = controller link
// nMyID = 8-255 (minBotID = 8, maxBotID = 255)
// nInfo = 0-255

__nolist void SendSpyPing(const int &nLinkID, const int &nMyID,
  const int &nInfo)
{
  SetSerialComm(SERIAL_COMM_4800|SERIAL_COMM_76KHZ);
  SetSerialPacket(SERIAL_PACKET_DEFAULT);
  int tmp = 0x80+(nLinkID&0x7);
  SetSerialData(0,tmp);
  SetSerialData(1,nMyID);
  SetSerialData(2,nInfo);
  SetSerialData(3,0x100-((tmp+nMyID+nInfo)&0xff));
  SendSerial(0,4);
}

I understand a little better now what these constants in Spybot.h mean:

const cNoID = 0
const cControllerID1 = 1
const cControllerID2 = 2
const cControllerID3 = 3
const cControllerID4 = 4
const cControllerID5 = 5
const cControllerID6 = 6
const cPCID = 7
const cMinBotID = 8
const cMaxBotID = 255

John Hansen
http://bricxcc.sourceforge.net/


Subject: 
Re: RCX to Spy messages thru IR communications route
Newsgroups: 
lugnet.robotics.spybotics, lugnet.robotics, lugnet.robotics.rcx, lugnet.robotics.rcx.nqc
Date: 
Thu, 25 Mar 2004 23:39:21 GMT
Viewed: 
11195 times
  
I'm a little surprised that the Spybot doesn't need to see the packet header
byte - the byte containing the range/orientation bits preceding the 0x8n Ping
byte.  The header is deliberately generated with the stop bit cleared to force a
framing error.  I thought it was a convenient (or necessary??) method for the
Spybot to detect a start of packet.

Does your IR monitoring see this byte - or does it get gobbled up due to the
framing error?

--Jay


Subject: 
Re: RCX to Spy messages thru IR communications route
Newsgroups: 
lugnet.robotics.spybotics, lugnet.robotics, lugnet.robotics.rcx, lugnet.robotics.rcx.nqc
Date: 
Fri, 26 Mar 2004 21:13:40 GMT
Viewed: 
11230 times
  
In lugnet.robotics.spybotics, Jay Francis wrote:
I'm a little surprised that the Spybot doesn't need to see the packet header
byte - the byte containing the range/orientation bits preceding the 0x8n Ping
byte.  The header is deliberately generated with the stop bit cleared to force a
framing error.  I thought it was a convenient (or necessary??) method for the
Spybot to detect a start of packet.

Does your IR monitoring see this byte - or does it get gobbled up due to the
framing error?

I presume that somewhere that data is being dropped.  It isn't showing up as
data the tower reports to the operating system.

I haven't actually tried the function I posted the other day so it is entirely
possible that a Spybot will not recognize it as a valid Ping.

Have you tried it yet?

John Hansen
http://bricxcc.sourceforge.net/


Subject: 
Re: RCX to Spy messages thru IR communications route
Newsgroups: 
lugnet.robotics.spybotics, lugnet.robotics, lugnet.robotics.rcx, lugnet.robotics.rcx.nqc
Date: 
Fri, 26 Mar 2004 21:17:40 GMT
Viewed: 
11281 times
  
In lugnet.robotics.spybotics, Jay Francis wrote:
I'm a little surprised that the Spybot doesn't need to see the packet header
byte - the byte containing the range/orientation bits preceding the 0x8n Ping
......raming error?

--Jay

Boy, this RCX to Spy IR comm thing is sure going the right way! The SPYBOTICS
are a little known and hidden LEGO gem.
Gramps Eddie & Grandson CJ


Subject: 
Re: RCX to Spy messages thru IR communications route
Newsgroups: 
lugnet.robotics.spybotics, lugnet.robotics, lugnet.robotics.rcx, lugnet.robotics.rcx.nqc
Date: 
Mon, 29 Mar 2004 21:27:55 GMT
Viewed: 
11577 times
  
In lugnet.robotics.spybotics, John Hansen wrote:
I haven't actually tried the function I posted the other day so it is entirely
possible that a Spybot will not recognize it as a valid Ping.

Have you tried it yet?

Hi John,

It does work.  The RCX appears in the Spybot's World Table.  The Range is set to
Anywhere.

Pretty cool...

--Jay


©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR