To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 10194
10193  |  10195
Subject: 
Sending a message to a RCX using a PC
Newsgroups: 
lugnet.robotics
Date: 
Thu, 20 Jan 2000 14:44:38 GMT
Viewed: 
896 times
  
Thanks to many people (Roger Hamlett and
Philippe Possemiers among other), I now have a short VB
program that can send message to the RCX using the IR tower.

I give you the code for your use.  I always
use mod 256 to make sure the message was in the right range
[0..256]:

You need an object of type MSComm for the communications,
and I assume the value to send is in the object Text1:

with MSComm1
  rem setting
  .commport=1
  .settings="2400,O,8,1"
  rem open the serial port
  .portopen=true
  rem send wrapper
  .output=chr$(&H55)
  .output=chr$(&HFF)
  .output=chr$(&H0)
  rem code for message, and inverted code
  .output=chr$(&HF7)
  .output=chr$(&H08)
  rem content of the message, and inverted content
  .output=chr$(val(text1) mod 256)
  .output=chr$((val(text1) mod 256) XOR &HFF)
  rem checksum value, and inverted checksum
  .output=chr$((val(text1)+&HF7) mod 256)
  .output=chr$(((val(text1)+&HF7) mod 256 ) XOR &HFF)
  rem close port
  .portopen=false
end with

that's it.

If the object MScomm is not in your toolbar, you can add
it using ctrl-T. It is a standard component of VB 5.00.

Enjoy,
Denis.
--

Denis Cousineau, Postdoc           *****************************
Cognitive psychology               *                           *
Indiana University                 * Etudiant devant l'eternel *
Psychology Building                *                           *
Bloomington, 47405                 *****************************

Office: (812) 856-5217             Fax:    (812) 855-1086
E-mail: decousin@indiana.edu       http://Prelude.PSY.UMontreal.CA/~cousined



1 Message in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    
Active threads in Robotics

 
Verified and Trusted Team of Hackers
12 hours ago
Custom Search

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