[caption id="attachment_1117" align="alignright" width="150"] Bioloid SerialPort2Dynamixel C#[/caption]
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:
[caption id="attachment_1134" align="alignright" width="150"] Bioloid SerialPort2Dynamixel C# Collaborators[/caption]
- 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
[sourcecode language="csharp"]
public void setRemoteControlMode(bool on)
{
if (on)
setReceiveDataMethod(rdDataReader.rawRemoteDataReceived);
else
setReceiveDataMethod(null);
}
[/sourcecode]
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:
[caption id="attachment_1112" align="alignright" width="131"] Raspberry Pi - USB2Dynamixel - CM510[/caption]
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.
[caption id="attachment_1620" align="aligncenter" width="300"] Xevel USB2AX[/caption]
[caption id="attachment_1622" align="aligncenter" width="300"] USB2AX over USB2DYNAMIXEL[/caption]
RCDataReader
[caption id="attachment_1155" align="alignright" width="150"] Bioloid RCDataReader C#[/caption]
[caption id="attachment_1128" align="alignleft" width="112"] RemoteCommunications[/caption]
Its responsability is to receive the Dynamixel Zig packets and extract the data.
Collaborator class:
- The ZigSequence enum, with the Dynamixels protocols data sections
[caption id="attachment_1171" align="aligncenter" width="300"] RC-100 packet[/caption]
Operations:
[caption id="attachment_1146" align="alignleft" width="105"] Robotis RC-100 remote controller values[/caption]
public void rawRemoteDataReceived(byte[] rcData), receives the Zigbee data.
public int getValue(), returns the last value received
No hay comentarios:
Publicar un comentario