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

RS485 functions
[Common functions]

Files

file  common-rs485.h
 

Commonly used RS485-related functions used by drivers.


Functions

bool RS485write (tMassiveArray &buf, ubyte len)
bool RS485read (tMassiveArray &buf, int &len, int timeout=100)
bool RS485readLargeResponse (tMassiveArray &buf, int &len, int timeout=100)
int RS485appendToBuff (tMassiveArray &buf, const short index, const ubyte *pData, const short nLength)
int RS485appendToBuff (tMassiveArray &buf, const short index, string pData)
void RS485initLib (long baudrate=230400)
void RS485clearRead (bool sendnewline=false)
bool RS485sendString (string &data)
bool RS485sendString (char *data)

Variables

int rxTimer
const ubyte newline [1] = '\n'
tMassiveArray RS485rxbuffer
tMassiveArray RS485txbuffer

Detailed Description

Commonly used RS485-related functions used by drivers


Function Documentation

int RS485appendToBuff ( tMassiveArray buf,
const short  index,
const ubyte *  pData,
const short  nLength 
)

Append an array of bytes to a tMassiveArray buffer, starts at index in the buffer and copies nLength bytes.

Parameters:
bufthe buffer to copy to
indexthe position in buffer where to start appending to
pDatathe data to be appended to buf
nLengththe length of the data to be appended
Returns:
the new 'tail' position of buf at which to append.

Append a string a tBigByteArray buffer, starts at index in the buffer

Parameters:
bufthe buffer to copy to
indexthe position in buffer where to start appending to
pDatathe string to be appended to buf
nLengththe length of the data to be appended
Returns:
the new 'tail' position of buf at which to append.
Examples:
benedettelli-nxt2wifi-test3.c.

Definition at line 176 of file common-rs485.h.

int RS485appendToBuff ( tMassiveArray buf,
const short  index,
string  pData 
)

Append a string a tMassiveArray buffer, starts at index in the buffer

Parameters:
bufthe buffer to copy to
indexthe position in buffer where to start appending to
pDatathe string to be appended to buf
Returns:
the new 'tail' position of buf at which to append.

Append a string a tBigByteArray buffer, starts at index in the buffer

Parameters:
bufthe buffer to copy to
indexthe position in buffer where to start appending to
pDatathe string to be appended to buf
Returns:
the new 'tail' position of buf at which to append.

Definition at line 192 of file common-rs485.h.

void RS485clearRead ( bool  sendnewline = false )
Examples:
benedettelli-nxt2wifi-test3.c.

Definition at line 248 of file common-rs485.h.

void RS485initLib ( long  baudrate = 230400 )
bool RS485read ( tMassiveArray buf,
int &  len,
int  timeout = 100 
)

Read a message from the NXT2WIFI. An optional timeout can be specified.

Parameters:
bufthe buffer in which to store the received data
lenthe amount of data received
timeoutoptional parameter to specify the timeout, defaults to 100ms
Returns:
true if no error occured, false if it did

Definition at line 91 of file common-rs485.h.

bool RS485readLargeResponse ( tMassiveArray buf,
int &  len,
int  timeout = 100 
)

Read a very large response from the NXT2WIFI sensor. This breaks up the reads into many smaller chunks to prevent weirdness on the bus.

Parameters:
bufthe buffer in which to store the received data
lenthe amount of data received
timeoutoptional parameter to specify the timeout, defaults to 100ms
Returns:
true if no error occured, false if it did

Definition at line 129 of file common-rs485.h.

bool RS485sendString ( string &  data )

Definition at line 263 of file common-rs485.h.

bool RS485sendString ( char *  data )

Definition at line 269 of file common-rs485.h.

bool RS485write ( tMassiveArray buf,
ubyte  len 
)

Write a message to the NXT2WIFI sensor

Parameters:
bufthe buffer to be transmitted
lenthe length of the data to be transmitted
Returns:
true if no error occured, false if it did

Definition at line 52 of file common-rs485.h.


Variable Documentation

const ubyte newline[1] = '\n'

Definition at line 41 of file common-rs485.h.

128 bit array for receiving

Examples:
benedettelli-nxt2wifi-test1.c, and benedettelli-nxt2wifi-test2.c.

Definition at line 43 of file common-rs485.h.

128 bit array for transmission

Examples:
benedettelli-nxt2wifi-test1.c, and benedettelli-nxt2wifi-test2.c.

Definition at line 44 of file common-rs485.h.

int rxTimer

timer for receiving timeouts

Definition at line 39 of file common-rs485.h.