Subject:
|
Re: send message from ir-tower to rcx
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Sat, 12 Jan 2002 06:56:54 GMT
|
Viewed:
|
2685 times
|
| |
| |
In lugnet.robotics, uhr@mathias.net writes:
> hi list!
:)
> i want to send a single-byte message from the serial ir-tower
> to the rcx, preferrably with visual basic. a program running on
> the host pc should send/recieve message to/from the rcx.
>
> what i found up to now is:
>
> - sending messages from the tower not possible with spirit.ocx
>
> - type "nqc -msg x" from the command line
> (cool and quite fast, but needs the serial port to be free,
> so spirit-comm would have to be opened and closed all
> the time when switching between sending and recieving)
>
> - several perl-scripts, c-programs etc. that send opcodes
> to the serial port / tower
> (impressing, but i don't have any of those environments
> and i couldn't get it to work with vb or a comm-tool, maybe
> i don't fully understand this opcode thing or use wrong
> com-port settings?)
>
> can anybody help me?
Download the new Mindstorms SDK for the 2.0 firmware
(http://news.lugnet.com/robotics/?n=16802). It's really, really cool and it
allows you to do all kinds of things that take advantage of the new
firmware. (Interestingly enough, both of the following methods are possible
with the RCX running the old firmware, but you need the tools in the new SDK.)
To have the tower send an RCX message, simply tell it to execute "msgs X" in
LEGO Assembler (LASM) code, where X is your message number. Or load up
ScriptEd and simply type in "msgs X", set the script to LASM, and punch Execute.
Unfortunately, there's no good way to have the tower *receive* a message.
My solution was to leave the IR tower on for a while to monitor the IR
traffic (e.g. by choosing "Monitor IR" in ScriptEd) and extract the message
from the incoming byte code stream. This gets rather tricky. The following
pseudo-code will do it:
if Mid(byte_code_string, 18, 2) = "f7" ' an RCX message
then the message number will be...
Val("&H" + Mid(byte_code_string, 28, 2))
if Mid(byte_code_string, 18, 2) = "d2" ' a remote message (0, 1, 2, or 3)
then the message number will be...
0 [clear message] if Mid(byte_code_string, 38, 2) is "00"
1 if it's "01"
2 if it's "02"
3 if it's "04" ' <-- note the 4: binary 2^(n-1), where N is the message
Of course, this assumes your byte-code strings are valid. If you want to
make sure, you'll need a bit more code. Usually, however, you won't need to
worry about that.
If you're using the serial port IR tower, make sure that you don't leave it
monitoring IR constantly - you might risk burning it out. (See
http://news.lugnet.com/robotics/rcx/?n=1245. It's not clear if the USB
tower has this problem or not.) Turn the tower on only when you need to
listen for a message, and keep it off the rest of the time.
> has someone ever made a vb-program that sends opcodes
> via the serial tower to the rcx?
You can also use ScriptEd or the new SDK for this. Set the script type to
"Raw Byte Code" or "Split Byte Code" according to your preference.
>
> thanks a lot and many greetings
> mat
You're welcome - HTH.
--Ian
|
|
Message is in Reply To:
| | send message from ir-tower to rcx
|
| hi list! i want to send a single-byte message from the serial ir-tower to the rcx, preferrably with visual basic. a program running on the host pc should send/recieve message to/from the rcx. what i found up to now is: - sending messages from the (...) (23 years ago, 11-Jan-02, to lugnet.robotics)
|
7 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
Active threads in Robotics
|
|
|
|