- Workshop: Programming a Bioloid robot workbench using C# and C++
- Workshop: USB, serial and remote communications with C#
- C++, Bioloid and Raspberry Pi (v0.2)
- So… let’s the Bioloid, C++ and QT games start!
- [UPDATED] A simple but pretty complete Linux C++ example for Bioloid
- Bioloid Workbench Windows C++ examples
[Previous post: Workshop: Dynamixel communications with C#]
SerialPort2Dynamixel
Encapsulating the SerialPort .Net class offers an easy way to use the serial port and receive Dynamixel Zig messages with the Dynamixel protocol.
.
.
Collaborator classes:
– The SerialPort .Net class.
– RCDataReader class, which unpack the Dynamixel Zigbee sequence offering the clean data received.
Operations:
The public interface that others classes will use offers principally these operations:
public void setRemoteControlMode(bool on), which sets on or off the reception of data
public void setRemoteControlMode(bool on) { if (on) setReceiveDataMethod(rdDataReader.rawRemoteDataReceived); else setReceiveDataMethod(null); }
public void setReceiveDataMethod(remoteControlDataReceived rcDataReceived), that sets the method that will be called when serial port data is received.
And some basics serial port data operations:
public bool open(String com, int speed), to open the serial port which name is in the com parameter. Wireless communications and USB ports, as used by Zig or USB2Dynaniel, are also serial ports (COM1, COM2, … or /ttyUSB0, ttyUSB1).
public void close(), it will do nothing if the port is already closed.
public byte[] query(byte[] buffer, int pos, int wait), send (write) a query and gets (read) the result.
public void rawWrite(byte[] buffer, int pos), well… it will write whatever contains the buffer in the first pos positions
public byte[] rawRead() , read and returns the data received.
Notes:
To avoid concurrency problems all the operations that use the Dynamixel bus are protected with a Mutex object that avoids that two or more concurrent objects use SerialPort2Dynamixel simultaneously entering the same operation or using the same resources, like variables, objects or the Dynamixel bus.
RCDataReader
Its responsability is to receive the Dynamixel Zig packets and extract the data.
Collaborator class:
– The ZigSequence enum, with the Dynamixels protocols data sections
Operations:
public void rawRemoteDataReceived(byte[] rcData), receives the Zigbee data.
public int getValue(), returns the last value received
You must log in to post a comment.