Mindstorms 3rd Party ROBOTC Drivers RobotC
[Home] [Download] [Submit a bug/suggestion] [ROBOTC Forums] [Blog] [Support this project]
Files | Functions | Variables

IR Link RCX comms
[HiTechnic]

Files

file  HTRCX-driver.h
 

HiTechnic IR Link RCX Comms Driver.


Functions

bool HTRCXsendHeader (tSensors link)
void HTRCXencode (tSensors link, tByteArray &iBuffer, tByteArray &oBuffer)
bool HTRCXreadResp (tSensors link, tByteArray &response)
bool HTRCXplaySound (tSensors link, unsigned byte sound)
bool HTRCXsendByte (tSensors link, unsigned byte data)
bool HTRCXsendWord (tSensors link, short data)
bool HTRCXmotorOn (tSensors link, unsigned byte _motor)
bool HTRCXmotorOff (tSensors link, unsigned byte _motor)
bool HTRCXmotorFwd (tSensors link, unsigned byte _motor)
bool HTRCXmotorRev (tSensors link, unsigned byte _motor)
bool HTRCXmotorPwr (tSensors link, unsigned byte _motor, unsigned byte power)

Variables

tByteArray HTRCXI2CRequest
tByteArray HTRCXI2CReply
tByteArray HTRCXIRMsg
byte HTRCXCmdToggle = 0

Detailed Description

HiTechnic IR Link RCX Comms Driver


Function Documentation

void HTRCXencode ( tSensors  link,
tByteArray iBuffer,
tByteArray oBuffer 
)

This encodes the message into the standard RCX format with opcodes, data and their complements, followed by a checksum.
The output is an I2C message that can be sent to the IR Link.
This does NOT send the IR message header.

Note: this is an internal function and should be not be called directly.

Parameters:
linkthe sensor port number
iBufferthe IR message that is to be sent by the IR Link to the RCX
oBufferthe I2C message to be sent to the IR Link

Definition at line 98 of file HTRCX-driver.h.

bool HTRCXmotorFwd ( tSensors  link,
unsigned byte  _motor 
)

Move the specified motor forward

NOTE: This does not currently work with the ROBOTC firmware on the RCX

Parameters:
linkthe sensor port number
_motorthe motor channel to move forward
Returns:
true if no error occured, false if it did

Definition at line 300 of file HTRCX-driver.h.

bool HTRCXmotorOff ( tSensors  link,
unsigned byte  _motor 
)

Turn the specified motor off

NOTE: This does not currently work with the ROBOTC firmware on the RCX

Parameters:
linkthe sensor port number
_motorthe motor channel to turn off
Returns:
true if no error occured, false if it did

Definition at line 275 of file HTRCX-driver.h.

bool HTRCXmotorOn ( tSensors  link,
unsigned byte  _motor 
)

Turn the specified motor on

NOTE: This does not currently work with the ROBOTC firmware on the RCX

Parameters:
linkthe sensor port number
_motorthe motor channel to turn on
Returns:
true if no error occured, false if it did

Definition at line 250 of file HTRCX-driver.h.

bool HTRCXmotorPwr ( tSensors  link,
unsigned byte  _motor,
unsigned byte  power 
)

Set the motor power.

NOTE: This does not currently work with the ROBOTC firmware on the RCX

Parameters:
linkthe sensor port number
_motorthe motor channel to change the power level of
powerthe amount of power to be applied to the motor
Returns:
true if no error occured, false if it did

Definition at line 351 of file HTRCX-driver.h.

bool HTRCXmotorRev ( tSensors  link,
unsigned byte  _motor 
)

Move the specified motor reverse

NOTE: This does not currently work with the ROBOTC firmware on the RCX

Parameters:
linkthe sensor port number
_motorthe motor channel to move reverse
Returns:
true if no error occured, false if it did

Definition at line 325 of file HTRCX-driver.h.

bool HTRCXplaySound ( tSensors  link,
unsigned byte  sound 
)

Tell the RCX to play a sound. Sounds are numbered 0-5

Parameters:
linkthe sensor port number
soundthe sound to play, numbered 0-6
Returns:
true if no error occured, false if it did

Definition at line 180 of file HTRCX-driver.h.

bool HTRCXreadResp ( tSensors  link,
tByteArray response 
)

Read a message sent by the RCX. You will need to poll frequently to check if a message has been sent. The number of bytes received is in the first element of the response array. If it is non-zero, a message was received.

Parameters:
linkthe sensor port number
responsethe IR message that was received from the RCX
Returns:
true if no error occured, false if it did

Definition at line 142 of file HTRCX-driver.h.

bool HTRCXsendByte ( tSensors  link,
unsigned byte  data 
)

Send a single byte message to the RCX

Parameters:
linkthe sensor port number
datathe data to be sent to the RCX
Returns:
true if no error occured, false if it did

Definition at line 204 of file HTRCX-driver.h.

bool HTRCXsendHeader ( tSensors  link )

Sends the RCX IR message header with all the trimmings.

Note: this is an internal function and should be not be called directly.

Parameters:
linkthe sensor port number
Returns:
true if no error occured, false if it did

Definition at line 69 of file HTRCX-driver.h.

bool HTRCXsendWord ( tSensors  link,
short  data 
)

Send 2 bytes message to the RCX as a short.

NOTE: This only works with the ROBOTC firmware on the RCX

Parameters:
linkthe sensor port number
datathe data to be sent to the RCX
Returns:
true if no error occured, false if it did
Examples:
HTRCX-test1.c.

Definition at line 226 of file HTRCX-driver.h.


Variable Documentation

byte HTRCXCmdToggle = 0

Definition at line 46 of file HTRCX-driver.h.

Definition at line 43 of file HTRCX-driver.h.

Definition at line 42 of file HTRCX-driver.h.

Definition at line 44 of file HTRCX-driver.h.