|
ECRobot C++ API for LEGO MINDSTORMS NXT
1.0.10
|
RS485 communication class. More...
#include <Rs485.h>
Public Member Functions | |
| Rs485 (U32 baudRate=LEGO_DEFAULT_BAUD_RATE) | |
| Constructor. | |
| ~Rs485 (void) | |
| Destructor (disable RS485). | |
| U32 | send (U8 *data, U32 offset, U32 length) |
| Send data. | |
| U32 | receive (U8 *data, U32 offset, U32 length) const |
| Receive data. | |
Static Public Attributes | |
| static const U32 | MAX_RS485_DATA_LENGTH = 64 |
| Maximum length of data in byte for send/receive. | |
| static const U32 | LEGO_DEFAULT_BAUD_RATE = 921600 |
| LEGO default baud rate [bps]. | |
RS485 communication class.
NXT sensor port 4 should be used for RS485 communication.
Default configrations:
921600 [bps]
Asynchronous mode
8 bits character length
1 stop bit
No parity check
| ecrobot::Rs485::Rs485 | ( | U32 | baudRate = LEGO_DEFAULT_BAUD_RATE | ) |
Constructor.
Note:
This class must be constructed as a global object. Otherwise, a device assertion will be displayed
in the LCD when the object is constructed as a non global object. When the object is destructed while the system is shut down, RS485 is disabled automatically.
| baudRate | RS485 baud rate [bps] |
| ecrobot::Rs485::~Rs485 | ( | void | ) |
Destructor (disable RS485).
| - |
| U32 ecrobot::Rs485::receive | ( | U8 * | data, |
| U32 | offset, | ||
| U32 | length | ||
| ) | const |
Receive data.
| data | Data to be received |
| offset | Offset of data to be received |
| length | Length of data to be received |
| U32 ecrobot::Rs485::send | ( | U8 * | data, |
| U32 | offset, | ||
| U32 | length | ||
| ) |
Send data.
| data | Data to be sent |
| offset | Offset of data to be sent |
| length | Length of data to be sent |