Dynamixel  2.9.5
RoadNarrows Robotics Dynamixel Package
DynaCommBotSense Class Reference

BotSense IP Proxied Dynamixel Bus Communications Class. More...

#include <DynaCommBotSense.h>

Inheritance diagram for DynaCommBotSense:
DynaComm

Public Member Functions

 DynaCommBotSense ()
 Default constructor.
 
 DynaCommBotSense (const char *sSerialDevName, int nBaudRate, const char *sBsProxyHostName=BSPROXY_URI_HOSTNAME_DFT, int nBsProxyIPPort=BSPROXY_LISTEN_PORT_DFT)
 Initialization constructor. More...
 
virtual ~DynaCommBotSense ()
 Destructor.
 
const char * GetSerialDeviceName ()
 Get the Dynamixel Bus serial device name. More...
 
const char * GetProxyServerHostName ()
 Get the BotSense proxy server host name. More...
 
const int GetProxyServerPort () const
 Get the BotSense proxy server port. More...
 
const BsClient_P GetProxyClient () const
 Get this BotSense proxy client. More...
 
virtual int GetResourceId () const
 Get System-unique resource identifier. More...
 
virtual int Open (const char *sSerialDevName, int nBaudRate)
 Open serial communication to dynamixel bus. More...
 
virtual int Open (const char *sSerialDevName, int nBaudRate, const char *sBsProxyHostName=BSPROXY_URI_HOSTNAME_DFT, int nBsProxyIPPort=BSPROXY_LISTEN_PORT_DFT)
 Open serial communication to dynamixel bus. More...
 
virtual int Open ()
 (Re)Open serial communication to dynamixel bus. More...
 
virtual int Close ()
 Close serial communication to dynamixel bus and connection to BotSense proxy server. More...
 
virtual int SetBaudRate (int nNewBaudRate)
 
virtual int SetHalfDuplexCtl (int nSignal, HalfDuplexTxFunc_T fnEnableTx=NULL, HalfDuplexRxFunc_T fnEnableRx=NULL)
 
virtual int SetMsgTracing (bool bEnabled)
 
virtual int Read8 (int nServoId, uint_t uAddr, byte_t *pVal)
 Read an 8-bit value from Dynamixel servo control table. More...
 
virtual int Write8 (int nServoId, uint_t uAddr, byte_t byVal)
 Write an 8-bit value to Dynamixel servo control table. More...
 
virtual int Read16 (int nServoId, uint_t uAddr, ushort_t *pVal)
 Read a 16-bit value from Dynamixel servo control table. More...
 
virtual int Write16 (int nServoId, uint_t uAddr, ushort_t uhVal)
 Write a 16-bit value to Dynamixel servo control table. More...
 
virtual int SyncWrite (uint_t uAddr, uint_t uValSize, DynaSyncWriteTuple_T tuples[], uint_t uCount)
 Synchronous Write 8/16-bit values to a list of Dynamixel servos. More...
 
virtual bool Ping (int nServoId)
 Ping the servo. More...
 
virtual int Reset (int nServoId)
 Reset a servo back to default values. More...
 
- Public Member Functions inherited from DynaComm
 DynaComm ()
 
 DynaComm (const char *sUri, int nBaudRate)
 
virtual ~DynaComm ()
 Destructor.
 
const char * GetDeviceUri () const
 
const int GetBaudRate () const
 
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, uint_t uVal)
 Write an 8-bit value to 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, 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 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...
 

Protected Attributes

char * m_sSerialDevName
 proxied serial device name
 
char * m_sBsProxyHostName
 BotSense proxy server domain/IP address.
 
int m_nBsProxyIPPort
 BotSense proxy server IP port number.
 
BsClient_P m_pBsClient
 BotSense client.
 
BsVConnHnd_T m_hndBsVConn
 virtual connection to proxied device
 
bool m_bBsTrace
 do [not] trace messaging
 
- Protected Attributes inherited from DynaComm
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
 

Additional Inherited Members

- Public Types inherited from DynaComm
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.
 
- Static Public Member Functions inherited from DynaComm
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...
 
- Static Protected Attributes inherited from DynaComm
static const key_t ShmKey = 0x70add12a
 shared memory key More...
 

Detailed Description

BotSense IP Proxied Dynamixel Bus Communications Class.

The host with the direct serial connection acts as the bsProxy server.

Definition at line 77 of file DynaCommBotSense.h.

Constructor & Destructor Documentation

DynaCommBotSense::DynaCommBotSense ( const char *  sSerialDevName,
int  nBaudRate,
const char *  sBsProxyHostName = BSPROXY_URI_HOSTNAME_DFT,
int  nBsProxyIPPort = BSPROXY_LISTEN_PORT_DFT 
)

Initialization constructor.

The given proxied serial device is opened at the baud rate on the host of the given BotSense proxy server.

Parameters
sSerialDevNameProxied serial device name.
nBaudRateProxied serial device baud rate.
sBsProxyHostNameBotSense proxy server host name (domain name or IP address).
nBsProxyIPPortBotSense proxy server IP port number.

Definition at line 89 of file DynaCommBotSense.cxx.

References m_bBsTrace, m_hndBsVConn, DynaComm::m_nBaudRate, m_nBsProxyIPPort, m_pBsClient, m_sBsProxyHostName, DynaComm::m_sDevUri, m_sSerialDevName, newstr(), and Open().

92  : DynaComm()
93 {
94  Uri_T uri;
95 
96  // fill in URI structure
97  uri.m_sScheme = (char *)BSPROXY_URI_SCHEME;
98  uri.m_sUserInfo = NULL;
99  uri.m_sHostName = (char *)sBsProxyHostName;
100  uri.m_nPortNum = nBsProxyIPPort;
101  uri.m_sPath = (char *)sSerialDevName;
102  uri.m_sQuery = NULL;
103 
104  m_sDevUri = UriStrNew(&uri);
105  m_nBaudRate = nBaudRate;
106 
107  m_sSerialDevName = newstr(sSerialDevName);
108  m_sBsProxyHostName = newstr(sBsProxyHostName);
109  m_nBsProxyIPPort = nBsProxyIPPort;
110  m_pBsClient = bsClientNew("Dynamixel");
111  m_hndBsVConn = BSPROXY_VCONN_UNDEF;
112  m_bBsTrace = false;
113 
114  Open();
115 }
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
char * m_sSerialDevName
proxied serial device name
BsClient_P m_pBsClient
BotSense client.
BsVConnHnd_T m_hndBsVConn
virtual connection to proxied device
char * m_sBsProxyHostName
BotSense proxy server domain/IP address.
int m_nBsProxyIPPort
BotSense proxy server IP port number.
virtual int Open()
(Re)Open serial communication to dynamixel bus.
bool m_bBsTrace
do [not] trace messaging

Member Function Documentation

int DynaCommBotSense::Close ( )
virtual

Close serial communication to dynamixel bus and connection to BotSense proxy server.

Implements DynaComm.

Definition at line 219 of file DynaCommBotSense.cxx.

References DYNA_OK, DynaComm::m_bIsOpen, m_hndBsVConn, and m_pBsClient.

Referenced by Open(), and ~DynaCommBotSense().

220 {
221  if( m_bIsOpen )
222  {
223  bsDynaClose(m_pBsClient, m_hndBsVConn);
224  bsServerDisconnect(m_pBsClient);
225  m_hndBsVConn = BSPROXY_VCONN_UNDEF;
226  m_bIsOpen = false;
227  }
228  return DYNA_OK;
229 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
BsClient_P m_pBsClient
BotSense client.
bool m_bIsOpen
dynamixel bus communication is [not] open
Definition: DynaComm.h:501
BsVConnHnd_T m_hndBsVConn
virtual connection to proxied device
const BsClient_P DynaCommBotSense::GetProxyClient ( ) const
inline

Get this BotSense proxy client.

Returns
Returns port number.

Definition at line 142 of file DynaCommBotSense.h.

References m_pBsClient.

143  {
144  return m_pBsClient;
145  }
BsClient_P m_pBsClient
BotSense client.
const char* DynaCommBotSense::GetProxyServerHostName ( )
inline

Get the BotSense proxy server host name.

Returns
Returns name.

Definition at line 122 of file DynaCommBotSense.h.

References m_sBsProxyHostName.

123  {
124  return m_sBsProxyHostName;
125  }
char * m_sBsProxyHostName
BotSense proxy server domain/IP address.
const int DynaCommBotSense::GetProxyServerPort ( ) const
inline

Get the BotSense proxy server port.

Returns
Returns port number.

Definition at line 132 of file DynaCommBotSense.h.

References m_nBsProxyIPPort.

133  {
134  return m_nBsProxyIPPort;
135  }
int m_nBsProxyIPPort
BotSense proxy server IP port number.
virtual int DynaCommBotSense::GetResourceId ( ) const
inlinevirtual

Get System-unique resource identifier.

Returns
Resource id.

Implements DynaComm.

Definition at line 152 of file DynaCommBotSense.h.

References m_hndBsVConn.

153  {
154  return (int)m_hndBsVConn;
155  }
BsVConnHnd_T m_hndBsVConn
virtual connection to proxied device
const char* DynaCommBotSense::GetSerialDeviceName ( )
inline

Get the Dynamixel Bus serial device name.

Returns
Returns name.

Definition at line 112 of file DynaCommBotSense.h.

References m_sSerialDevName.

113  {
114  return m_sSerialDevName;
115  }
char * m_sSerialDevName
proxied serial device name
virtual int DynaCommBotSense::Open ( const char *  sSerialDevName,
int  nBaudRate 
)
inlinevirtual

Open serial communication to dynamixel bus.

The given proxied serial device is opened at the baud rate on the local host with default port number.

Parameters
sSerialDevNameProxied serial device name.
nBaudRateProxied serial device baud rate.

Implements DynaComm.

Definition at line 168 of file DynaCommBotSense.h.

References Close(), DynaCommBotSense(), Open(), Ping(), Read16(), Read8(), Reset(), SetBaudRate(), SetHalfDuplexCtl(), SetMsgTracing(), SyncWrite(), Write16(), and Write8().

169  {
170  DynaCommBotSense(sSerialDevName, nBaudRate, BSPROXY_URI_HOSTNAME_DFT,
171  BSPROXY_LISTEN_PORT_DFT);
172  }
DynaCommBotSense()
Default constructor.
int DynaCommBotSense::Open ( const char *  sSerialDevName,
int  nBaudRate,
const char *  sBsProxyHostName = BSPROXY_URI_HOSTNAME_DFT,
int  nBsProxyIPPort = BSPROXY_LISTEN_PORT_DFT 
)
virtual

Open serial communication to dynamixel bus.

The given proxied serial device is opened at the baud rate on the host of the given BotSense proxy server.

Parameters
sSerialDevNameProxied serial device name.
nBaudRateProxied serial device baud rate.
sBsProxyHostNameBotSense proxy server host name (domain name or IP address).
sBsProxyHostNameBotSense proxy server host.
nBsProxyIPPortBotSense proxy server IP port number.

Definition at line 134 of file DynaCommBotSense.cxx.

References Close(), m_hndBsVConn, DynaComm::m_nBaudRate, m_nBsProxyIPPort, m_sBsProxyHostName, m_sSerialDevName, newstr(), and Open().

138 {
139  // close if open
140  Close();
141 
142  if( m_sSerialDevName != NULL )
143  {
144  delete[] m_sSerialDevName;
145  }
146 
147  if( m_sBsProxyHostName != NULL )
148  {
149  delete[] m_sBsProxyHostName;
150  }
151 
152  m_sSerialDevName = newstr(sSerialDevName);
153  m_nBaudRate = nBaudRate;
154  m_sBsProxyHostName = newstr(sBsProxyHostName);
155  m_nBsProxyIPPort = nBsProxyIPPort;
156  m_hndBsVConn = BSPROXY_VCONN_UNDEF;
157 
158  // (re)open
159  return Open();
160 }
char * newstr(const char *s)
Allocate new duplicated string.
int m_nBaudRate
baud rate
Definition: DynaComm.h:500
char * m_sSerialDevName
proxied serial device name
BsVConnHnd_T m_hndBsVConn
virtual connection to proxied device
char * m_sBsProxyHostName
BotSense proxy server domain/IP address.
int m_nBsProxyIPPort
BotSense proxy server IP port number.
virtual int Open()
(Re)Open serial communication to dynamixel bus.
virtual int Close()
Close serial communication to dynamixel bus and connection to BotSense proxy server.
int DynaCommBotSense::Open ( )
virtual

(Re)Open serial communication to dynamixel bus.

Implements DynaComm.

Definition at line 162 of file DynaCommBotSense.cxx.

References Close(), DYNA_ECODE_BAD_VAL, DYNA_ECODE_BOTSENSE, DYNA_LOG_ERROR, DYNA_OK, m_bBsTrace, DynaComm::m_bIsOpen, m_hndBsVConn, DynaComm::m_nBaudRate, m_nBsProxyIPPort, m_pBsClient, m_sBsProxyHostName, and m_sSerialDevName.

Referenced by DynaCommBotSense(), and Open().

163 {
164  int nSerialIndex;
165  int nBaudNum;
166  int rc;
167 
168  // close if open
169  Close();
170 
171  // check proxied serial device name
172  if( (m_sSerialDevName == NULL) || (*m_sSerialDevName == 0) )
173  {
174  rc = -DYNA_ECODE_BAD_VAL;
175  DYNA_LOG_ERROR(rc, "Unspecified serial device.");
176  }
177 
178  // check proxy server host name
179  else if( (m_sBsProxyHostName == NULL) || (*m_sBsProxyHostName == 0) )
180  {
181  rc = -DYNA_ECODE_BOTSENSE;
182  DYNA_LOG_ERROR(rc, "Unspecified BotSense server host name.");
183  }
184 
185  // connect to bsProxy server
186  else if((rc =
187  bsServerConnect(m_pBsClient, m_sBsProxyHostName, m_nBsProxyIPPort)) < 0)
188  {
189  LOGERROR("bsProxy server %s:%d: %s.",
190  m_sBsProxyHostName, m_nBsProxyIPPort, bsStrError(rc));
191  rc = -DYNA_ECODE_BOTSENSE;
192  }
193 
194  // open proxied serial device
195  else if( (m_hndBsVConn = bsDynaOpen(m_pBsClient,
197  m_nBaudRate,
198  m_bBsTrace)) < 0 )
199  {
200  rc = m_hndBsVConn;
201  m_hndBsVConn = BSPROXY_VCONN_UNDEF;
202  DYNA_LOG_ERROR(rc, "Failed to open %s@%d on bsProxy server %s:%d.",
204  }
205 
206  // success
207  else
208  {
209  m_bIsOpen = true;
210  rc = DYNA_OK;
211  LOGDIAG3("Dynamixel bus communication opened on %s@%d "
212  "via bsProxy server %s:%d.",
214  }
215 
216  return rc;
217 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_ECODE_BOTSENSE
BotSense proxy error.
Definition: Dynamixel.h:100
int m_nBaudRate
baud rate
Definition: DynaComm.h:500
char * m_sSerialDevName
proxied serial device name
BsClient_P m_pBsClient
BotSense client.
bool m_bIsOpen
dynamixel bus communication is [not] open
Definition: DynaComm.h:501
BsVConnHnd_T m_hndBsVConn
virtual connection to proxied device
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
char * m_sBsProxyHostName
BotSense proxy server domain/IP address.
int m_nBsProxyIPPort
BotSense proxy server IP port number.
bool m_bBsTrace
do [not] trace messaging
virtual int Close()
Close serial communication to dynamixel bus and connection to BotSense proxy server.
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
bool DynaCommBotSense::Ping ( int  nServoId)
virtual

Ping the servo.

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

Implements DynaComm.

Definition at line 405 of file DynaCommBotSense.cxx.

References DYNA_ECODE_BOTSENSE, DYNA_LOG_ERROR, DYNA_TRY_COMM, m_hndBsVConn, DynaComm::m_mutexComm, and m_pBsClient.

Referenced by Open().

406 {
407  bool_t bPong;
408  int rc;
409 
410  DYNA_TRY_COMM(*this);
411 
412  shm_mutex_lock(&m_mutexComm);
413 
414  rc = bsDynaPing(m_pBsClient, m_hndBsVConn, nServoId, &bPong);
415 
416  shm_mutex_unlock(&m_mutexComm);
417 
418  if( rc == BS_OK )
419  {
420  return bPong? true: false;
421  }
422  else
423  {
424  rc = -DYNA_ECODE_BOTSENSE;
425  DYNA_LOG_ERROR(rc, "Ping(%d)", nServoId);
426  return false;
427  }
428 }
#define DYNA_ECODE_BOTSENSE
BotSense proxy error.
Definition: Dynamixel.h:100
shm_mutex_t m_mutexComm
synchonization mutex
Definition: DynaComm.h:504
BsClient_P m_pBsClient
BotSense client.
BsVConnHnd_T m_hndBsVConn
virtual connection to proxied device
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaCommBotSense::Read16 ( int  nServoId,
uint_t  uAddr,
ushort_t *  pVal 
)
virtual

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

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

Implements DynaComm.

Definition at line 323 of file DynaCommBotSense.cxx.

References DYNA_ECODE_BOTSENSE, DYNA_LOG_ERROR, DYNA_OK, DYNA_TRY_COMM, m_hndBsVConn, DynaComm::m_mutexComm, m_pBsClient, and DynaComm::m_uAlarms.

Referenced by Open().

324 {
325  int rc;
326 
327  DYNA_TRY_COMM(*this);
328 
329  shm_mutex_lock(&m_mutexComm);
330 
331  rc = bsDynaRead16(m_pBsClient, m_hndBsVConn,
332  nServoId, uAddr, pVal, &m_uAlarms);
333 
334  shm_mutex_unlock(&m_mutexComm);
335 
336  if( rc == BS_OK )
337  {
338  rc = DYNA_OK;
339  }
340  else
341  {
342  rc = -DYNA_ECODE_BOTSENSE;
343  DYNA_LOG_ERROR(rc, "Read16(%d, 0x%02x)", nServoId, uAddr);
344  }
345 
346  return rc;
347 }
uint_t m_uAlarms
servo alarms from last I/O operation
Definition: DynaComm.h:503
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_ECODE_BOTSENSE
BotSense proxy error.
Definition: Dynamixel.h:100
shm_mutex_t m_mutexComm
synchonization mutex
Definition: DynaComm.h:504
BsClient_P m_pBsClient
BotSense client.
BsVConnHnd_T m_hndBsVConn
virtual connection to proxied device
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaCommBotSense::Read8 ( int  nServoId,
uint_t  uAddr,
byte_t *  pVal 
)
virtual

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

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

Implements DynaComm.

Definition at line 271 of file DynaCommBotSense.cxx.

References DYNA_ECODE_BOTSENSE, DYNA_LOG_ERROR, DYNA_OK, DYNA_TRY_COMM, m_hndBsVConn, DynaComm::m_mutexComm, m_pBsClient, and DynaComm::m_uAlarms.

Referenced by Open().

272 {
273  int rc;
274 
275  DYNA_TRY_COMM(*this);
276 
277  shm_mutex_lock(&m_mutexComm);
278 
279  rc = bsDynaRead8(m_pBsClient, m_hndBsVConn,
280  nServoId, uAddr, pVal, &m_uAlarms);
281 
282  shm_mutex_unlock(&m_mutexComm);
283 
284  if( rc == BS_OK )
285  {
286  rc = DYNA_OK;
287  }
288  else
289  {
290  rc = -DYNA_ECODE_BOTSENSE;
291  DYNA_LOG_ERROR(rc, "Read8(%d, 0x%02x)", nServoId, uAddr);
292  }
293 
294  return rc;
295 }
uint_t m_uAlarms
servo alarms from last I/O operation
Definition: DynaComm.h:503
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_ECODE_BOTSENSE
BotSense proxy error.
Definition: Dynamixel.h:100
shm_mutex_t m_mutexComm
synchonization mutex
Definition: DynaComm.h:504
BsClient_P m_pBsClient
BotSense client.
BsVConnHnd_T m_hndBsVConn
virtual connection to proxied device
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaCommBotSense::Reset ( int  nServoId)
virtual

Reset a servo back to default values.

Warning
All configuration is lost.
Parameters
nServoIdServo id.

Implements DynaComm.

Definition at line 430 of file DynaCommBotSense.cxx.

References DYNA_ECODE_BOTSENSE, DYNA_LOG_ERROR, DYNA_OK, DYNA_TRY_COMM, m_hndBsVConn, DynaComm::m_mutexComm, and m_pBsClient.

Referenced by Open().

431 {
432  int rc;
433 
434  DYNA_TRY_COMM(*this);
435 
436  shm_mutex_lock(&m_mutexComm);
437 
438  rc = bsDynaReset(m_pBsClient, m_hndBsVConn, nServoId);
439 
440  shm_mutex_unlock(&m_mutexComm);
441 
442  if( rc == BS_OK )
443  {
444  rc = DYNA_OK;
445  }
446  else
447  {
448  rc = -DYNA_ECODE_BOTSENSE;
449  DYNA_LOG_ERROR(rc, "Reset(%d)", nServoId);
450  }
451 
452  return rc;
453 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_ECODE_BOTSENSE
BotSense proxy error.
Definition: Dynamixel.h:100
shm_mutex_t m_mutexComm
synchonization mutex
Definition: DynaComm.h:504
BsClient_P m_pBsClient
BotSense client.
BsVConnHnd_T m_hndBsVConn
virtual connection to proxied device
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaCommBotSense::SetBaudRate ( int  nNewBaudRate)
virtual

Set the Dynamixel Bus new baud rate.

Parameters
nNewBaudRateNew baudrate.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaComm.

Definition at line 231 of file DynaCommBotSense.cxx.

References DYNA_OK, DYNA_TRY_RC, DynaComm::m_bIsOpen, m_hndBsVConn, DynaComm::m_nBaudRate, and m_pBsClient.

Referenced by Open().

232 {
233  int rc; // return code
234 
235  if( m_bIsOpen )
236  {
237  rc = bsDynaSetBaudRate(m_pBsClient, m_hndBsVConn, nNewBaudRate);
238 
239  DYNA_TRY_RC(rc, "SetBaudRate(%d)", nNewBaudRate);
240  }
241 
242  m_nBaudRate = nNewBaudRate;
243 
244  return DYNA_OK;
245 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
int m_nBaudRate
baud rate
Definition: DynaComm.h:500
BsClient_P m_pBsClient
BotSense client.
bool m_bIsOpen
dynamixel bus communication is [not] open
Definition: DynaComm.h:501
BsVConnHnd_T m_hndBsVConn
virtual connection to proxied device
#define DYNA_TRY_RC(rc, fmt,...)
Test if Dynamixel return code is not an error.
int DynaCommBotSense::SetHalfDuplexCtl ( int  nSignal,
HalfDuplexTxFunc_T  fnEnableTx = NULL,
HalfDuplexRxFunc_T  fnEnableRx = NULL 
)
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.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaComm.

Definition at line 247 of file DynaCommBotSense.cxx.

References DYNA_OK, DYNA_TRY_RC, DynaComm::m_bIsOpen, m_hndBsVConn, and m_pBsClient.

Referenced by Open().

250 {
251  int rc; // return code
252 
253  if( m_bIsOpen )
254  {
255  // Note: do not know how got generalize this for non-builtin signal support.
256  rc = bsDynaSetHalfDuplexCtl(m_pBsClient, m_hndBsVConn, nSignal);
257 
258  DYNA_TRY_RC(rc, "SetHalfDuplexCtl(%d)", nSignal);
259  }
260 
261  return DYNA_OK;
262 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
BsClient_P m_pBsClient
BotSense client.
bool m_bIsOpen
dynamixel bus communication is [not] open
Definition: DynaComm.h:501
BsVConnHnd_T m_hndBsVConn
virtual connection to proxied device
#define DYNA_TRY_RC(rc, fmt,...)
Test if Dynamixel return code is not an error.
int DynaCommBotSense::SetMsgTracing ( bool  bEnabled)
virtual

Enable/disable botsense message tracing.

Parameters
bEnableEnable [disable].
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 264 of file DynaCommBotSense.cxx.

References DYNA_OK, and m_bBsTrace.

Referenced by Open().

265 {
266  m_bBsTrace = bEnabled;
267 
268  return DYNA_OK;
269 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
bool m_bBsTrace
do [not] trace messaging
int DynaCommBotSense::SyncWrite ( uint_t  uAddr,
uint_t  uValSize,
DynaSyncWriteTuple_T  tuples[],
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 at addtess. 1 or 2 bytes.
tuplesArray of servo id, write value tuples.
uCountNumber of tuples.

Implements DynaComm.

Definition at line 375 of file DynaCommBotSense.cxx.

References DYNA_ECODE_BOTSENSE, DYNA_LOG_ERROR, DYNA_OK, DYNA_TRY_COMM, m_hndBsVConn, DynaComm::m_mutexComm, and m_pBsClient.

Referenced by Open().

379 {
380  int rc;
381 
382  DYNA_TRY_COMM(*this);
383 
384  shm_mutex_lock(&m_mutexComm);
385 
386  rc = bsDynaSyncWrite(m_pBsClient, m_hndBsVConn,
387  uAddr, uValSize, tuples, uCount);
388 
389  shm_mutex_unlock(&m_mutexComm);
390 
391  if( rc == BS_OK )
392  {
393  rc = DYNA_OK;
394  }
395  else
396  {
397  rc = -DYNA_ECODE_BOTSENSE;
398  DYNA_LOG_ERROR(rc, "SyncWrite(0x%02x, %d, tuples, %d)",
399  uAddr, uValSize, uCount);
400  }
401 
402  return rc;
403 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_ECODE_BOTSENSE
BotSense proxy error.
Definition: Dynamixel.h:100
shm_mutex_t m_mutexComm
synchonization mutex
Definition: DynaComm.h:504
BsClient_P m_pBsClient
BotSense client.
BsVConnHnd_T m_hndBsVConn
virtual connection to proxied device
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaCommBotSense::Write16 ( int  nServoId,
uint_t  uAddr,
ushort_t  uhVal 
)
virtual

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

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

Implements DynaComm.

Definition at line 349 of file DynaCommBotSense.cxx.

References DYNA_ECODE_BOTSENSE, DYNA_LOG_ERROR, DYNA_OK, DYNA_TRY_COMM, m_hndBsVConn, DynaComm::m_mutexComm, m_pBsClient, and DynaComm::m_uAlarms.

Referenced by Open().

350 {
351  int rc;
352 
353  DYNA_TRY_COMM(*this);
354 
355  shm_mutex_lock(&m_mutexComm);
356 
357  rc = bsDynaWrite16(m_pBsClient, m_hndBsVConn,
358  nServoId, uAddr, huVal, &m_uAlarms);
359 
360  shm_mutex_unlock(&m_mutexComm);
361 
362  if( rc == BS_OK )
363  {
364  rc = DYNA_OK;
365  }
366  else
367  {
368  rc = -DYNA_ECODE_BOTSENSE;
369  DYNA_LOG_ERROR(rc, "Write16(%d, 0x%02x, 0x%04x)", nServoId, uAddr, huVal);
370  }
371 
372  return rc;
373 }
uint_t m_uAlarms
servo alarms from last I/O operation
Definition: DynaComm.h:503
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_ECODE_BOTSENSE
BotSense proxy error.
Definition: Dynamixel.h:100
shm_mutex_t m_mutexComm
synchonization mutex
Definition: DynaComm.h:504
BsClient_P m_pBsClient
BotSense client.
BsVConnHnd_T m_hndBsVConn
virtual connection to proxied device
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaCommBotSense::Write8 ( int  nServoId,
uint_t  uAddr,
byte_t  byVal 
)
virtual

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

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

Implements DynaComm.

Definition at line 297 of file DynaCommBotSense.cxx.

References DYNA_ECODE_BOTSENSE, DYNA_LOG_ERROR, DYNA_OK, DYNA_TRY_COMM, m_hndBsVConn, DynaComm::m_mutexComm, m_pBsClient, and DynaComm::m_uAlarms.

Referenced by Open().

298 {
299  int rc;
300 
301  DYNA_TRY_COMM(*this);
302 
303  shm_mutex_lock(&m_mutexComm);
304 
305  rc = bsDynaWrite8(m_pBsClient, m_hndBsVConn,
306  nServoId, uAddr, byVal, &m_uAlarms);
307 
308  shm_mutex_unlock(&m_mutexComm);
309 
310  if( rc == BS_OK )
311  {
312  rc = DYNA_OK;
313  }
314  else
315  {
316  rc = -DYNA_ECODE_BOTSENSE;
317  DYNA_LOG_ERROR(rc, "Write8(%d, 0x%02x, 0x%02x)", nServoId, uAddr, byVal);
318  }
319 
320  return rc;
321 }
uint_t m_uAlarms
servo alarms from last I/O operation
Definition: DynaComm.h:503
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_ECODE_BOTSENSE
BotSense proxy error.
Definition: Dynamixel.h:100
shm_mutex_t m_mutexComm
synchonization mutex
Definition: DynaComm.h:504
BsClient_P m_pBsClient
BotSense client.
BsVConnHnd_T m_hndBsVConn
virtual connection to proxied device
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.

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