|
After doing a little more sleuthing, I was able to find out how to
process incoming IR and VLL messages. And yes, thankfully, VLL
decode is built into the firmware!
The following is some SpyBot MindScript code that will handle both
incoming VLL and IR messages.
program SpyRcv
{
#include "spybot.h"
#include "globals.h"
event MessageEvent when message
event VLLEvent when vll
// Display 8 bit value on LEDs
sub DebugOut(x)
{
// bits 0-5 on green & red LEDs, green is MSB
led[iDisplay] = (x & 0x17) | ((x & 8) * 4) | ((x & 32) / 4)
led[iYellowWarn] = (x / 64) & 1 // bit 6 on yellow LED
led[iVLL] = (x / 128) & 1 // bit 7 on rear red LED
}
main
{
// Turn off annoying IR pinging
ping[iInterval] = cDisablePings
// Receive IR messages on channel 2
link[iRxChannel] = iRCChannel2
start MessageHandler
start VLLHandler
forever { wait 100 }
}
watcher MessageHandler monitor MessageEvent
{
select message[ iRxIR, iHiByte ] * 256 + message[ iRxIR, iLoByte ]
{
// RCX sent 0x9223 (controller red button)
when 0x0200 { sound sndShocked Disp(ledSparkle) }
// RCX sent 0x92ab
when 0x0103 { sound sndHitByLaser Disp(ledAlarm) }
}
}
watcher VLLHandler monitor VLLEvent
{
sound sndGotIt
DebugOut(vll) // display VLL code on LEDs
}
}
For testing the above, here's some RCX MindScript code to alternately
send two VLL codes (hook an LED up to output B). The SpyBot will
make a sound and display the received VLL code on the top LEDs.
program RCXVLL2Spy
{
#include"s:\lego\include\rcx2\rcx2.h"
#include"s:\lego\include\rcx2\rcx2vll.h"
main
{
forever
{
on B wait 40
ms_Rwd(B) // VLL code 0000001
off B
wait 200
on B wait 40
ms_Beep3(B) // VLL code 0000110
off B
wait 200
}
}
}
And finally, here's the RCX NQC code to send some IR commands
(hook up 3 touch sensors to the RCX):
#define EVENT_1 0
#define EVENT_2 1
#define EVENT_3 2
task main()
{
SetSerialComm(SERIAL_COMM_4800|SERIAL_COMM_DUTY25|SERIAL_COMM_76KHZ);
SetSerialPacket(SERIAL_PACKET_DEFAULT);
SetSensor(SENSOR_1, SENSOR_TOUCH);
SetSensor(SENSOR_2, SENSOR_TOUCH);
SetSensor(SENSOR_3, SENSOR_TOUCH);
SetEvent(EVENT_1, SENSOR_1, EVENT_TYPE_PRESSED);
SetEvent(EVENT_2, SENSOR_2, EVENT_TYPE_PRESSED);
SetEvent(EVENT_3, SENSOR_3, EVENT_TYPE_PRESSED);
while (true)
{
monitor (EVENT_MASK(EVENT_1) + EVENT_MASK(EVENT_2) +
EVENT_MASK(EVENT_3))
{
Wait(100);
}
catch (EVENT_MASK(EVENT_1))
{
// Same as SpyBot controller red button (channel 2)
SetSerialData(0,0x92);
SetSerialData(1,0x23);
SendSerial(0,2);
}
catch (EVENT_MASK(EVENT_2))
{
// Send "non-standard" SpyBot message (channel 2)
SetSerialData(0,0x92);
SetSerialData(1,0xab);
SendSerial(0,2);
}
catch (EVENT_MASK(EVENT_3))
{
// Same as SpyBot controller left-forward button (channel 2)
SetSerialData(0,0x60);
SetSerialData(1,0x73);
SendSerial(0,2);
}
}
}
Well, that was interesting! I have to say, I think $60 is actually
a pretty good deal for these SpyBots (considering that at one time
the DDK with MicroScout was going for $100).
Cheers,
Mark
|
|
Message has 4 Replies: | | Re: Spybotics Comms
|
| (...) [snipped] Mark, are you using BricxCC to edit/compile/download your MindScript code? If so, I'd love to hear your opinion on how well you feel it works in BricxCC. If not, why not? :-) (...) Right. And the RDS set sold for $150. Spybots are a (...) (22 years ago, 19-Aug-02, to lugnet.robotics.spybotics)
| | | RE: Spybotics Comms
|
| WOW! :) Thank you very much Mark ! Cool, it's all true then :) The usable firmware VLL input together with RCX/Scout IR messages output and the Manas/Spybot IR input. So now I can have a setup like: Cybermaster--VLL->Sp...IR->Manas, eh ! :) so (...) (22 years ago, 20-Aug-02, to lugnet.robotics.spybotics)
| | | Re: Spybotics Comms
|
| Hi Mark, Thanks for providing the messaging listing in these posts (URL) you know if it is possible for the spybot to receive standard RCX messages (rather than serial RCX messaging that you use in your example)? Thanks, Barton... (22 years ago, 10-Sep-02, to lugnet.robotics.spybotics)
| | | Re: Spybotics Comms
|
| (...) Hi Mark, am I right, all you have described above only works with a RCX2.0-hardware cause of the changed IR-interface? Is there any chance to communicate between Spybot and RCX1.5 (with 2.0 firmware)? If there is no, I will have to buy a (...) (22 years ago, 10-Dec-02, to lugnet.robotics.spybotics)
|
Message is in Reply To:
| | RE: Spybotics Comms
|
| (...) PM (...) Great, thxs for this info :) (...) Yes, that's to be expected, from what I experienced with my MicroScout tests. (...) hmmmm... let's hope someone can do some work around that :) (...) Yes, like I did on a CyberMaster and on a RCX. (...) (22 years ago, 19-Aug-02, to lugnet.robotics.spybotics)
|
12 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|