Dynamixel  2.9.5
RoadNarrows Robotics Dynamixel Package
DynaComm Class Referenceabstract

Dynamixel Bus Communications Abstract Base Class. More...

#include <DynaComm.h>

Inheritance diagram for DynaComm:
DynaCommBotSense DynaCommSerial

Public Types

typedef void(* HalfDuplexTxFunc_T) (void *pArg)
 Half-duplex control transmit function type.
 
typedef void(* HalfDuplexRxFunc_T) (void *pArg, size_t uNumTxBytes)
 Half-duplex control receive function type.
 

Public Member Functions

 DynaComm ()
 
 DynaComm (const char *sUri, int nBaudRate)
 
virtual ~DynaComm ()
 Destructor.
 
const char * GetDeviceUri () const
 
const int GetBaudRate () const
 
virtual int GetResourceId () const =0
 Get system-unique resource identifier. More...
 
virtual int Open (const char *sDevUri, int nBaudRate)=0
 Open communication to dynamixel bus. More...
 
virtual int Open ()=0
 (Re)Open communication to dynamixel bus. More...
 
virtual int Close ()=0
 Close communication to dynamixel bus. More...
 
virtual int SetBaudRate (int nNewBaudRate)=0
 Set the Dynamixel Bus new baud rate. More...
 
virtual int SetHalfDuplexCtl (int nSignal, HalfDuplexTxFunc_T fnEnableTx=NULL, HalfDuplexRxFunc_T fnEnableRx=NULL)=0
 
virtual int Read8 (int nServoId, uint_t uAddr, byte_t *pVal)=0
 Read an 8-bit value from Dynamixel servo control table. More...
 
virtual int Read8 (int nServoId, uint_t uAddr, uint_t *pVal)
 Read an 8-bit value from Dynamixel servo control table. More...
 
virtual int Write8 (int nServoId, uint_t uAddr, byte_t byVal)=0
 Write an 8-bit value to Dynamixel servo control table. More...
 
virtual int Write8 (int nServoId, uint_t uAddr, uint_t uVal)
 Write an 8-bit value to Dynamixel servo control table. More...
 
virtual int Read16 (int nServoId, uint_t uAddr, ushort_t *pVal)=0
 Read a 16-bit value from Dynamixel servo control table. More...
 
virtual int Read16 (int nServoId, uint_t uAddr, uint_t *pVal)
 Read a 16-bit value from Dynamixel servo control table. More...
 
virtual int Write16 (int nServoId, uint_t uAddr, ushort_t uhVal)=0
 Write a 16-bit value to Dynamixel servo control table. More...
 
virtual int Write16 (int nServoId, uint_t uAddr, uint_t uVal)
 Write a 16-bit value to Dynamixel servo control table. More...
 
virtual int vSyncWrite (uint_t uAddr, uint_t uValSize, uint_t uCount,...)
 Synchronous write 8/16-bit values to a list of Dynamixel servos. More...
 
virtual int SyncWrite (uint_t uAddr, uint_t uValSize, DynaSyncWriteTuple_T tuples[], uint_t uCount)=0
 Synchronous Write 8/16-bit values to a list of Dynamixel servos. More...
 
virtual bool Ping (int nServoId)=0
 Ping the servo. More...
 
virtual int Reset (int nServoId)=0
 Reset a servo back to default values. More...
 
virtual bool IsOpen ()
 Test if Dynamixel Bus is open. More...
 
virtual uint_t GetAlarms ()
 Get current alarms. More...
 
virtual void ClearAlarms ()
 Clear current alarms.
 
virtual uint_t GetBusStatus ()
 Get the Dynamixel Bus status. More...
 

Static Public Member Functions

static DynaCommNew (const char *sUri, int nBaudRate)
 Archetype constructor to create a new Dynamixel bus communication derived instance. More...
 
static std::string GetAlarmsString (const uint_t uAlarms, const std::string &strSep="; ")
 Get a formatted servo alarms string associated with the alarms. More...
 
static std::string GetAlarmsShortString (const uint_t uAlarms, const std::string &strSep=",")
 Get a formatted servo alarms short string associated with the alarms. More...
 
static const char * GetBusStatusString (uint_t uBusStatus)
 Get the string describing the Dynamixel servo communication status. More...
 
static int BaudRateToNum (int nBaudRate)
 Map baud rate to Dynamixel baud number. More...
 
static int BaudNumToRate (int nBaudRate)
 Map baud number to Dynamixel baud rate. More...
 
static int BaudRateAt (int nIndex)
 Get the baud rate associated with the given index. More...
 
static int BaudNumAt (int nIndex)
 Get the baud number associated with the given index. More...
 

Protected Attributes

char * m_sDevUri
 dynamixel bus device URI
 
int m_nBaudRate
 baud rate
 
bool m_bIsOpen
 dynamixel bus communication is [not] open
 
uint_t m_uBusStatus
 bus comminication status
 
uint_t m_uAlarms
 servo alarms from last I/O operation
 
shm_mutex_t m_mutexComm
 synchonization mutex
 

Static Protected Attributes

static const key_t ShmKey = 0x70add12a
 shared memory key More...
 

Detailed Description

Dynamixel Bus Communications Abstract Base Class.

The DynaComm abstract class provides the I/O template to communicate with Dynamixel servos on a Dynamixel bus.

Definition at line 80 of file DynaComm.h.

Constructor & Destructor Documentation

DynaComm::DynaComm ( )

Default constructor.

Definition at line 149 of file DynaComm.cxx.

References DYNA_ALARM_NONE.

150 {
151  m_sDevUri = NULL;
152  m_nBaudRate = 0;
153  m_bIsOpen = false;
155 
156  shm_mutex_init(ShmKey, &m_mutexComm);
157 }
uint_t m_uAlarms
servo alarms from last I/O operation
Definition: DynaComm.h:503
char * m_sDevUri
dynamixel bus device URI
Definition: DynaComm.h:499
int m_nBaudRate
baud rate
Definition: DynaComm.h:500
#define DYNA_ALARM_NONE
no alarms
Definition: Dynamixel.h:646
static const key_t ShmKey
shared memory key
Definition: DynaComm.h:497
shm_mutex_t m_mutexComm
synchonization mutex
Definition: DynaComm.h:504
bool m_bIsOpen
dynamixel bus communication is [not] open
Definition: DynaComm.h:501
DynaComm::DynaComm ( const char *  sUri,
int  nBaudRate 
)

Initialization constructor.

Parameters
sUriDynamixel Bus device Uniform Resource Identifier string.
nBaudRateDevice baud rate.

Definition at line 159 of file DynaComm.cxx.

References DYNA_ALARM_NONE, and newstr().

160 {
161  m_sDevUri = newstr(sUri);
162  m_nBaudRate = nBaudRate;
163  m_bIsOpen = false;
165 
166  shm_mutex_init(ShmKey, &m_mutexComm);
167 }
uint_t m_uAlarms
servo alarms from last I/O operation
Definition: DynaComm.h:503
char * newstr(const char *s)
Allocate new duplicated string.
char * m_sDevUri
dynamixel bus device URI
Definition: DynaComm.h:499
int m_nBaudRate
baud rate
Definition: DynaComm.h:500
#define DYNA_ALARM_NONE
no alarms
Definition: Dynamixel.h:646
static const key_t ShmKey
shared memory key
Definition: DynaComm.h:497
shm_mutex_t m_mutexComm
synchonization mutex
Definition: DynaComm.h:504
bool m_bIsOpen
dynamixel bus communication is [not] open
Definition: DynaComm.h:501

Member Function Documentation

int DynaComm::BaudNumAt ( int  nIndex)
static

Get the baud number associated with the given index.

This function can be used to iterate of all supported baud rates.

Parameters
nIndexZero based index.
Returns
If the index is in range, returns the baud number at the index.
Otherwise 0 is returned.

Definition at line 408 of file DynaComm.cxx.

References DynaBaudMap.

Referenced by GetBusStatus().

409 {
410  if( (nIndex >= 0) && (nIndex < arraysize(DynaBaudMap)) )
411  {
412  return DynaBaudMap[nIndex][1];
413  }
414  else
415  {
416  return 0;
417  }
418 }
static const int DynaBaudMap[DYNA_BAUDNUM_NUMOF][2]
Baud rate to baud number enumeration map.
Definition: DynaComm.cxx:125
int DynaComm::BaudNumToRate ( int  nBaudRate)
static

Map baud number to Dynamixel baud rate.

Parameters
nBaudNumBaud number.
Returns
Returns baud rate on success.

Definition at line 382 of file DynaComm.cxx.

References DYNA_ECODE_BAD_VAL, and DynaBaudMap.

Referenced by GetBusStatus(), and DynaServo::ReadBaudRate().

383 {
384  int i;
385 
386  for(i=0; i<arraysize(DynaBaudMap); ++i)
387  {
388  if( DynaBaudMap[i][1] == nBaudNum )
389  {
390  return DynaBaudMap[i][0];
391  }
392  }
393  return -DYNA_ECODE_BAD_VAL;
394 }
static const int DynaBaudMap[DYNA_BAUDNUM_NUMOF][2]
Baud rate to baud number enumeration map.
Definition: DynaComm.cxx:125
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
int DynaComm::BaudRateAt ( int  nIndex)
static

Get the baud rate associated with the given index.

This function can be used to iterate of all supported baud rates.

Parameters
nIndexZero based index.
Returns
If the index is in range, returns the baud rate at the index.
Otherwise 0 is returned.

Definition at line 396 of file DynaComm.cxx.

References DynaBaudMap.

Referenced by GetBusStatus(), and DynaShellCmdCreate::TabCompletion().

397 {
398  if( (nIndex >= 0) && (nIndex < arraysize(DynaBaudMap)) )
399  {
400  return DynaBaudMap[nIndex][0];
401  }
402  else
403  {
404  return 0;
405  }
406 }
static const int DynaBaudMap[DYNA_BAUDNUM_NUMOF][2]
Baud rate to baud number enumeration map.
Definition: DynaComm.cxx:125
int DynaComm::BaudRateToNum ( int  nBaudRate)
static

Map baud rate to Dynamixel baud number.

Parameters
nBaudRateBaud rate.
Returns
Returns baud number on success.

Definition at line 368 of file DynaComm.cxx.

References DYNA_ECODE_BAD_VAL, and DynaBaudMap.

Referenced by GetBusStatus(), New(), DynaCommSerial::Open(), DynaCommSerial::SetBaudRate(), and DynaServo::WriteBaudRate().

369 {
370  int i;
371 
372  for(i=0; i<arraysize(DynaBaudMap); ++i)
373  {
374  if( DynaBaudMap[i][0] == nBaudRate )
375  {
376  return DynaBaudMap[i][1];
377  }
378  }
379  return -DYNA_ECODE_BAD_VAL;
380 }
static const int DynaBaudMap[DYNA_BAUDNUM_NUMOF][2]
Baud rate to baud number enumeration map.
Definition: DynaComm.cxx:125
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
virtual int DynaComm::Close ( )
pure virtual

Close communication to dynamixel bus.

Implemented in DynaCommBotSense, and DynaCommSerial.

Referenced by GetBaudRate().

virtual uint_t DynaComm::GetAlarms ( )
inlinevirtual

Get current alarms.

Returns
Returns alarm bits.

Definition at line 393 of file DynaComm.h.

References m_uAlarms.

Referenced by DynaServoGeneric::ReadHealth().

394  {
395  return m_uAlarms;
396  }
uint_t m_uAlarms
servo alarms from last I/O operation
Definition: DynaComm.h:503
string DynaComm::GetAlarmsShortString ( const uint_t  uAlarms,
const std::string &  strSep = "," 
)
static

Get a formatted servo alarms short string associated with the alarms.

Parameters
uAlarmsDynamixel servo alarm bits.
strSepSeparator string between alarm substrings.
Returns
Returns string.

Definition at line 340 of file DynaComm.cxx.

References DYNA_ALARM_NONE, and DynaServoAlarmShortStrTbl.

Referenced by ClearAlarms().

342 {
343  string strAlarms;
344  size_t i;
345  uint_t bit;
346 
347  if( uAlarms == DYNA_ALARM_NONE )
348  {
349  return "OK";
350  }
351 
352  for(i=0, bit=0x01; i<arraysize(DynaServoAlarmShortStrTbl); ++i, bit<<=1)
353  {
354  if( !strAlarms.empty() )
355  {
356  strAlarms += strSep;
357  }
358 
359  if( bit & uAlarms )
360  {
361  strAlarms += DynaServoAlarmShortStrTbl[i];
362  }
363  }
364 
365  return strAlarms;
366 }
#define DYNA_ALARM_NONE
no alarms
Definition: Dynamixel.h:646
static const char * DynaServoAlarmShortStrTbl[]
Dynamixel Servo Alarms Short String Table.
Definition: DynaComm.cxx:111
string DynaComm::GetAlarmsString ( const uint_t  uAlarms,
const std::string &  strSep = "; " 
)
static

Get a formatted servo alarms string associated with the alarms.

Parameters
uAlarmsDynamixel servo alarm bits.
strSepSeparator string between alarm substrings.
Returns
Returns string.

Definition at line 312 of file DynaComm.cxx.

References DYNA_ALARM_NONE, and DynaServoAlarmStrTbl.

Referenced by ClearAlarms(), DynaShellCmdReadHealth::doExec(), DynaLogServoAlarms(), and DynaShell::Error().

314 {
315  string strAlarms;
316  size_t i;
317  uint_t bit;
318 
319  if( uAlarms == DYNA_ALARM_NONE )
320  {
321  return "OK";
322  }
323 
324  for(i=0, bit=0x01; i<arraysize(DynaServoAlarmStrTbl); ++i, bit<<=1)
325  {
326  if( !strAlarms.empty() )
327  {
328  strAlarms += strSep;
329  }
330 
331  if( bit & uAlarms )
332  {
333  strAlarms += DynaServoAlarmStrTbl[i];
334  }
335  }
336 
337  return strAlarms;
338 }
static const char * DynaServoAlarmStrTbl[]
Dynamixel Servo Alarms String Table.
Definition: DynaComm.cxx:97
#define DYNA_ALARM_NONE
no alarms
Definition: Dynamixel.h:646
const int DynaComm::GetBaudRate ( ) const
inline

Get the current baud rate.

Returns
Return buad rate.

Definition at line 146 of file DynaComm.h.

References Close(), GetResourceId(), m_nBaudRate, Open(), Read8(), SetBaudRate(), and SetHalfDuplexCtl().

147  {
148  return m_nBaudRate;
149  }
int m_nBaudRate
baud rate
Definition: DynaComm.h:500
virtual uint_t DynaComm::GetBusStatus ( )
inlinevirtual

Get the Dynamixel Bus status.

Returns
Status.

Definition at line 434 of file DynaComm.h.

References BaudNumAt(), BaudNumToRate(), BaudRateAt(), BaudRateToNum(), GetBusStatusString(), and m_uBusStatus.

435  {
436  return m_uBusStatus;
437  }
uint_t m_uBusStatus
bus comminication status
Definition: DynaComm.h:502
const char * DynaComm::GetBusStatusString ( uint_t  uBusStatus)
static

Get the string describing the Dynamixel servo communication status.

Parameters
uBusStatusDynamixel bus communication status.
Returns
Returns the appropriate status string.

Definition at line 298 of file DynaComm.cxx.

References DynaBusStatusStrTbl.

Referenced by GetBusStatus().

299 {
300  if( uBusStatus < 0 )
301  {
302  uBusStatus = -uBusStatus;
303  }
304 
305  if( uBusStatus >= arraysize(DynaBusStatusStrTbl) )
306  {
307  uBusStatus = arraysize(DynaBusStatusStrTbl) - 1;
308  }
309  return DynaBusStatusStrTbl[uBusStatus];
310 }
static const char * DynaBusStatusStrTbl[]
Dynamixel Bus Communication Status String Table.
Definition: DynaComm.cxx:81
const char* DynaComm::GetDeviceUri ( ) const
inline

Get the Dynamixel Bus Uniform Resource Identifier.

Returns
Returns URI.

Definition at line 136 of file DynaComm.h.

References m_sDevUri.

137  {
138  return m_sDevUri;
139  }
char * m_sDevUri
dynamixel bus device URI
Definition: DynaComm.h:499
virtual int DynaComm::GetResourceId ( ) const
pure virtual

Get system-unique resource identifier.

Returns
Resource id.

Implemented in DynaCommBotSense, and DynaCommSerial.

Referenced by GetBaudRate().

virtual bool DynaComm::IsOpen ( )
inlinevirtual

Test if Dynamixel Bus is open.

Returns
Returns true or false.

Definition at line 383 of file DynaComm.h.

References m_bIsOpen.

Referenced by DynaShellCmd::ChkComm(), DynaShellCmdCreate::CommNew(), DynaShellCmdMegaScan::CommNew(), and New().

384  {
385  return m_bIsOpen;
386  }
bool m_bIsOpen
dynamixel bus communication is [not] open
Definition: DynaComm.h:501
DynaComm * DynaComm::New ( const char *  sUri,
int  nBaudRate 
)
static

Archetype constructor to create a new Dynamixel bus communication derived instance.

The specific DynaComm object created depends on the URI specified. Currently two derived objects are supported:

DynaCommSerial Direct connected serial device.
DynaCommBotSense BotSense proxied serial device.
Supported URIs:
/devicepath
botsense://[hostname][:port]/devicepath
Parameters
sUriUniform Resource Identifier string.
nBaudRateDynamixel bus supported baud rate.
Returns
On succes, returns pointer to the allocated DynaComm derived object.
On failure, NULL is returned.

Definition at line 179 of file DynaComm.cxx.

References BaudRateToNum(), DYNA_ECODE_BAD_DEV, DYNA_ECODE_BAD_VAL, DYNA_LOG_ERROR, and IsOpen().

Referenced by DynaShellCmdCreate::CommNew(), DynaShellCmdMegaScan::CommNew(), and MainInitArgs().

180 {
181  Uri_T *pUri; // parsed URI
182  const char *sHostName; // parsed/default hostname
183  int nPortNum; // parsed/default IP port number
184  DynaComm *pDynaComm; // new derived Dynamixel bus communication object
185  int rc; // return code
186 
187  pUri = NULL;
188  pDynaComm = NULL;
189 
190  //
191  // No uri string.
192  //
193  if( sUri == NULL )
194  {
195  DYNA_LOG_ERROR(DYNA_ECODE_BAD_VAL, "No URI specified.");
196  }
197 
198  //
199  // Bad baud rate.
200  //
201  else if( (rc = DynaComm::BaudRateToNum(nBaudRate)) < 0 )
202  {
203  DYNA_LOG_ERROR(rc, "%d: Unsupported baudrate.", nBaudRate);
204  }
205 
206  //
207  // Bad uri parse.
208  //
209  else if( (pUri = UriParseNew(sUri)) == NULL )
210  {
211  DYNA_LOG_ERROR(DYNA_ECODE_BAD_VAL, "Failed to parse URI \"%s\".", sUri);
212  }
213 
214  //
215  // Required device path in uri not specified.
216  //
217  else if( pUri->m_sPath == NULL )
218  {
220  "URI \"%s\" does not specify device path.", sUri);
221  }
222 
223  //
224  // Direct connect serial Dynamixel bus.
225  //
226  else if( pUri->m_sScheme == NULL )
227  {
228  pDynaComm = new DynaCommSerial(pUri->m_sPath, nBaudRate);
229  }
230 
231  //
232  // BotSense proxied Dynamixel bus.
233  //
234  else if( !strcasecmp(pUri->m_sScheme, BSPROXY_URI_SCHEME) )
235  {
236  sHostName = pUri->m_sHostName;
237  nPortNum = pUri->m_nPortNum;
238 
239  if( sHostName == NULL )
240  {
241  sHostName = BSPROXY_URI_HOSTNAME_DFT;
242  }
243 
244  if( nPortNum == URI_PORT_NONE )
245  {
246  nPortNum = BSPROXY_LISTEN_PORT_DFT;
247  }
248 
249  pDynaComm = new DynaCommBotSense(pUri->m_sPath, nBaudRate,
250  sHostName, nPortNum);
251  }
252 
253  //
254  // File scheme is also direct connect, but only locally.
255  //
256  else if( !strcasecmp(pUri->m_sScheme, URI_SCHEME_FILE) )
257  {
258  if( (pUri->m_sHostName == NULL) ||
259  !strcasecmp(pUri->m_sHostName, URI_LOCAL_HOST) )
260  {
261  pDynaComm = new DynaCommSerial(pUri->m_sPath, nBaudRate);
262  }
263  else
264  {
266  "URI \"%s\" remote file device access not supported - "
267  "use botsense proxy services.", sUri);
268  }
269  }
270 
271  //
272  // Bad scheme.
273  //
274  else
275  {
276  DYNA_LOG_ERROR(DYNA_ECODE_BAD_VAL, "URI \"%s\" unknown scheme.", sUri);
277  }
278 
279  if( pUri != NULL )
280  {
281  UriDelete(pUri);
282  }
283 
284  //
285  // Final checks
286  //
287  if( (pDynaComm != NULL) && !pDynaComm->IsOpen() )
288  {
290  "Failed to open the device \"%s\" at %d baud.", sUri, nBaudRate);
291  delete pDynaComm;
292  pDynaComm = NULL;
293  }
294 
295  return pDynaComm;
296 }
Dynamixel Serial Bus Communications Class.
virtual bool IsOpen()
Test if Dynamixel Bus is open.
Definition: DynaComm.h:383
#define DYNA_ECODE_BAD_DEV
no or bad serial device
Definition: Dynamixel.h:87
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
BotSense IP Proxied Dynamixel Bus Communications Class.
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
static int BaudRateToNum(int nBaudRate)
Map baud rate to Dynamixel baud number.
Definition: DynaComm.cxx:368
Dynamixel Bus Communications Abstract Base Class.
Definition: DynaComm.h:80
virtual int DynaComm::Open ( const char *  sDevUri,
int  nBaudRate 
)
pure virtual

Open communication to dynamixel bus.

The given serial device is opened at the given baud rate.

Parameters
sDevUriDevice Uniform Resource Identifier.
nBaudRateDevice baud rate.

Implemented in DynaCommBotSense, and DynaCommSerial.

virtual int DynaComm::Open ( )
pure virtual

(Re)Open communication to dynamixel bus.

Implemented in DynaCommBotSense, and DynaCommSerial.

Referenced by GetBaudRate().

virtual bool DynaComm::Ping ( int  nServoId)
pure virtual

Ping the servo.

Parameters
nServoIdServo id.
Returns
Returns true if the servo responded, else false.

Implemented in DynaCommBotSense, and DynaCommSerial.

Referenced by DynaShellCmdPing::Exec(), DynaShellCmdMegaScan::Exec(), DynaServo::Ping(), DynaServoGeneric::Ping(), and Write16().

virtual int DynaComm::Read16 ( int  nServoId,
uint_t  uAddr,
uint_t *  pVal 
)
inlinevirtual

Read a 16-bit value from Dynamixel servo control table.

Parameters
nServoIdServo id.
uAddrServo control table address.
[out]pValValue read.

Definition at line 290 of file DynaComm.h.

References DYNA_OK, Read16(), and Write16().

291  {
292  ushort_t val;
293  int rc;
294 
295  if( (rc = Read16(nServoId, uAddr, &val)) == DYNA_OK )
296  {
297  *pVal = (uint_t)val;
298  }
299  return rc;
300  }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int Read16(int nServoId, uint_t uAddr, ushort_t *pVal)=0
Read a 16-bit value from Dynamixel servo control table.
virtual int DynaComm::Read8 ( int  nServoId,
uint_t  uAddr,
uint_t *  pVal 
)
inlinevirtual

Read an 8-bit value from Dynamixel servo control table.

Parameters
nServoIdServo id.
uAddrServo control table address.
[out]pValValue read.

Definition at line 231 of file DynaComm.h.

References DYNA_OK, Read8(), and Write8().

232  {
233  byte_t val;
234  int rc;
235 
236  if( (rc = Read8(nServoId, uAddr, &val)) == DYNA_OK )
237  {
238  *pVal = (uint_t)val;
239  }
240  return rc;
241  }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int Read8(int nServoId, uint_t uAddr, byte_t *pVal)=0
Read an 8-bit value from Dynamixel servo control table.
virtual int DynaComm::Reset ( int  nServoId)
pure virtual

Reset a servo back to default values.

Warning
All configuration is lost.
Parameters
nServoIdServo id.

Implemented in DynaCommBotSense, and DynaCommSerial.

Referenced by DynaServo::Reset(), DynaServoGeneric::Reset(), and Write16().

virtual int DynaComm::SetBaudRate ( int  nNewBaudRate)
pure virtual

Set the Dynamixel Bus new baud rate.

Parameters
nNewBaudRateNew baud rate.

Implemented in DynaCommBotSense, and DynaCommSerial.

Referenced by GetBaudRate().

virtual int DynaComm::SetHalfDuplexCtl ( int  nSignal,
HalfDuplexTxFunc_T  fnEnableTx = NULL,
HalfDuplexRxFunc_T  fnEnableRx = NULL 
)
pure virtual

Set Dynamixel Bus half-duplex software control.

The Dynamixel 3-wire bus is half-duplex. Hardware may automatically control toggling between transmit and receive (e.g. RoadNarrows DynaUSB dongle). If there is no hardware support, then software must provide the tx/rx toggle functions.

Parameters
nSignalSignal assign to toggle.
fnEnableTxEnable transmit function.
fnEnableRxEnable receive function.

Implemented in DynaCommBotSense, and DynaCommSerial.

Referenced by DynaShellCmdSetHalfDuplexCtl::Exec(), and GetBaudRate().

virtual int DynaComm::SyncWrite ( uint_t  uAddr,
uint_t  uValSize,
DynaSyncWriteTuple_T  tuples[],
uint_t  uCount 
)
pure virtual

Synchronous Write 8/16-bit values to a list of Dynamixel servos.

Parameters
uAddrServo control table write address.
uValSizeValue storage size at addtess. 1 or 2 bytes.
tuplesArray of servo id, write value 2-tuples.
uCountNumber of tuples.

Implemented in DynaCommBotSense, and DynaCommSerial.

Referenced by DynaShellCmdWriteByte::doExec(), DynaShellCmdWriteWord::doExec(), DynaChain::SyncWriteGoalPos(), DynaChain::SyncWriteGoalSpeed(), DynaChain::SyncWriteTorqueEnable(), and Write16().

int DynaComm::vSyncWrite ( uint_t  uAddr,
uint_t  uValSize,
uint_t  uCount,
  ... 
)
virtual

Synchronous write 8/16-bit values to a list of Dynamixel servos.

Parameters
uAddrServo control table write address.
uValSizeValue storage size of field at addtess. 1 or 2 bytes.
uCountNumber of tuples.
...A variable argument list of uCount 2-tuples of type (int,uint_t) specifying the servo id and the packed raw field value.

Definition at line 420 of file DynaComm.cxx.

References DYNA_ID_NUMOF, DynaSyncWriteTuple_T::m_nServoId, and DynaSyncWriteTuple_T::m_uVal.

Referenced by DynaServoGeneric::CfgWriteAlarmShutdownMask(), DynaServoEX106P::CfgWriteDriveMode(), DynaServoGeneric::CfgWriteMaxTorqueLimit(), DynaServoGeneric::CfgWriteRotationLimits(), DynaServoGeneric::CfgWriteTemperatureLimit(), DynaServoGeneric::CfgWriteVoltageLimits(), Write16(), DynaServoGeneric::WriteCtlMethodCompliance(), DynaServoGeneric::WriteCtlMethodPid(), DynaServoGeneric::WriteGoalPos(), DynaServoGeneric::WriteGoalSpeed(), DynaServoGeneric::WriteLed(), DynaServoGeneric::WriteMaxTorqueLimit(), and DynaServoGeneric::WriteTorqueEnable().

421 {
423  va_list ap;
424  int i;
425 
426  va_start(ap, uCount);
427 
428  for(i=0; i<uCount && i<DYNA_ID_NUMOF; ++i)
429  {
430  tuples[i].m_nServoId = va_arg(ap, int);
431  tuples[i].m_uVal = va_arg(ap, uint_t);
432  }
433 
434  va_end(ap);
435 
436  return SyncWrite(uAddr, uValSize, tuples, (uint_t)i);
437 }
int m_nServoId
servo id
Definition: DynaTypes.h:296
#define DYNA_ID_NUMOF
number of unique servo id&#39;s
Definition: Dynamixel.h:148
uint_t m_uVal
write value
Definition: DynaTypes.h:297
virtual int SyncWrite(uint_t uAddr, uint_t uValSize, DynaSyncWriteTuple_T tuples[], uint_t uCount)=0
Synchronous Write 8/16-bit values to a list of Dynamixel servos.
virtual int DynaComm::Write16 ( int  nServoId,
uint_t  uAddr,
ushort_t  uhVal 
)
pure virtual
virtual int DynaComm::Write16 ( int  nServoId,
uint_t  uAddr,
uint_t  uVal 
)
inlinevirtual

Write a 16-bit value to Dynamixel servo control table.

Parameters
nServoIdServo id.
uAddrServo control table address.
uValValue written.

Definition at line 322 of file DynaComm.h.

References Ping(), Reset(), SyncWrite(), vSyncWrite(), and Write16().

323  {
324  ushort_t val = (ushort_t)uVal;
325 
326  return Write16(nServoId, uAddr, val);
327  }
virtual int Write16(int nServoId, uint_t uAddr, ushort_t uhVal)=0
Write a 16-bit value to Dynamixel servo control table.
virtual int DynaComm::Write8 ( int  nServoId,
uint_t  uAddr,
uint_t  uVal 
)
inlinevirtual

Write an 8-bit value to Dynamixel servo control table.

Parameters
nServoIdServo id.
uAddrServo control table address.
uValValue written.

Definition at line 263 of file DynaComm.h.

References Read16(), and Write8().

264  {
265  byte_t val = (byte_t)uVal;
266 
267  return Write8(nServoId, uAddr, val);
268  }
virtual int Write8(int nServoId, uint_t uAddr, byte_t byVal)=0
Write an 8-bit value to Dynamixel servo control table.

Member Data Documentation

const key_t DynaComm::ShmKey = 0x70add12a
staticprotected

shared memory key

Shared memory mutex key: roaddyna.

Definition at line 497 of file DynaComm.h.


The documentation for this class was generated from the following files: