56 #include "rnr/rnrconfig.h" 58 #include "rnr/netmsgs.h" 60 #include "botsense/BotSense.h" 61 #include "botsense/libBotSense.h" 62 #include "botsense/bsProxyMsgs.h" 77 "The proxied Dynamixel servo chain.",
81 "(C) 2012-2015 RoadNarrows LLC. All rights reserved.",
90 BsVConnHnd_T hndVConn,
93 const NMMsgDef_T *pMsgDef;
97 return pMsgDef!=NULL? pMsgDef->m_sMsgName:
"unknown";
101 const char *sDevName,
108 byte_t buf[BSPROXY_MSG_MAX_LEN];
113 bTrace = bsClientAttrGetTraceState(pClient, BSPROXY_VCONN_SERVER);
126 BSCLIENT_TRY_NM_ECODE(pClient, n,
"MsgId=%u", msgIdReq);
136 BSCLIENT_TRY_ECODE(pClient, n,
"bsServerReqOpenDev(dev='%s') failed.",
145 return bsServerReqCloseDev(pClient, hndVConn);
149 BsVConnHnd_T hndVConn,
153 static BsProxyMsgId_T msgIdRsp = BsProxyMsgIdRspOk;
156 byte_t buf[BSPROXY_MSG_MAX_LEN];
163 BSCLIENT_TRY_EXPR(pClient, BSCLIENT_HAS_VCONN(pClient, hndVConn),
164 BS_ECODE_BAD_VAL,
"VConn=%d", hndVConn);
167 bTrace = bsClientAttrGetTraceState(pClient, hndVConn);
180 BSCLIENT_TRY_NM_ECODE(pClient, n,
"MsgId=%u", msgIdReq);
185 n = bsClientTrans(pClient, hndVConn,
186 msgIdReq, buf, (
size_t)n,
187 msgIdRsp, buf,
sizeof(buf));
190 BSCLIENT_TRY_ECODE(pClient, n,
"MsgId=%u: Transaction failed.", msgIdReq);
192 LOGDIAG3(
"%s: SetBaudRate: %d", bsClientAttrGetName(pClient), nBaudRate);
198 BsVConnHnd_T hndVConn,
209 byte_t buf[BSPROXY_MSG_MAX_LEN];
216 BSCLIENT_TRY_EXPR(pClient, BSCLIENT_HAS_VCONN(pClient, hndVConn),
217 BS_ECODE_BAD_VAL,
"VConn=%d", hndVConn);
220 bTrace = bsClientAttrGetTraceState(pClient, hndVConn);
226 msgReq.
m_addr = (byte_t)uAddr;
234 BSCLIENT_TRY_NM_ECODE(pClient, n,
"MsgId=%u", msgIdReq);
239 n = bsClientTrans(pClient, hndVConn,
240 msgIdReq, buf, (
size_t)n,
241 msgIdRsp, buf,
sizeof(buf));
244 BSCLIENT_TRY_ECODE(pClient, n,
"MsgId=%u: Transaction failed.", msgIdReq);
252 BSCLIENT_TRY_NM_ECODE(pClient, n,
"MsgId=%u", msgIdRsp);
258 *pVal = msgRsp.
m_val;
260 LOGDIAG3(
"%s: Read8: 0x%02x --> 0x%02x.",
261 bsClientAttrGetName(pClient), uAddr, *pVal);
267 BsVConnHnd_T hndVConn,
278 byte_t buf[BSPROXY_MSG_MAX_LEN];
285 BSCLIENT_TRY_EXPR(pClient, BSCLIENT_HAS_VCONN(pClient, hndVConn),
286 BS_ECODE_BAD_VAL,
"VConn=%d", hndVConn);
289 bTrace = bsClientAttrGetTraceState(pClient, hndVConn);
295 msgReq.
m_addr = (byte_t)uAddr;
303 BSCLIENT_TRY_NM_ECODE(pClient, n,
"MsgId=%u", msgIdReq);
308 n = bsClientTrans(pClient, hndVConn,
309 msgIdReq, buf, (
size_t)n,
310 msgIdRsp, buf,
sizeof(buf));
313 BSCLIENT_TRY_ECODE(pClient, n,
"MsgId=%u: Transaction failed.", msgIdReq);
321 BSCLIENT_TRY_NM_ECODE(pClient, n,
"MsgId=%u", msgIdRsp);
327 *pVal = msgRsp.
m_val;
329 LOGDIAG3(
"%s: Read16: 0x%02x --> 0x%04x.",
330 bsClientAttrGetName(pClient), uAddr, *pVal);
336 BsVConnHnd_T hndVConn,
347 byte_t buf[BSPROXY_MSG_MAX_LEN];
354 BSCLIENT_TRY_EXPR(pClient, BSCLIENT_HAS_VCONN(pClient, hndVConn),
355 BS_ECODE_BAD_VAL,
"VConn=%d", hndVConn);
358 bTrace = bsClientAttrGetTraceState(pClient, hndVConn);
364 msgReq.
m_addr = (byte_t)uAddr;
365 msgReq.
m_val = byVal;
373 BSCLIENT_TRY_NM_ECODE(pClient, n,
"MsgId=%u", msgIdReq);
378 n = bsClientTrans(pClient, hndVConn,
379 msgIdReq, buf, (
size_t)n,
380 msgIdRsp, buf,
sizeof(buf));
383 BSCLIENT_TRY_ECODE(pClient, n,
"MsgId=%u: Transaction failed.", msgIdReq);
391 BSCLIENT_TRY_NM_ECODE(pClient, n,
"MsgId=%u", msgIdRsp);
398 LOGDIAG3(
"%s: Write8: 0x%02x <-- 0x%02x.",
399 bsClientAttrGetName(pClient), uAddr, byVal);
405 BsVConnHnd_T hndVConn,
416 byte_t buf[BSPROXY_MSG_MAX_LEN];
423 BSCLIENT_TRY_EXPR(pClient, BSCLIENT_HAS_VCONN(pClient, hndVConn),
424 BS_ECODE_BAD_VAL,
"VConn=%d", hndVConn);
427 bTrace = bsClientAttrGetTraceState(pClient, hndVConn);
433 msgReq.
m_addr = (byte_t)uAddr;
434 msgReq.
m_val = huVal;
442 BSCLIENT_TRY_NM_ECODE(pClient, n,
"MsgId=%u", msgIdReq);
447 n = bsClientTrans(pClient, hndVConn,
448 msgIdReq, buf, (
size_t)n,
449 msgIdRsp, buf,
sizeof(buf));
452 BSCLIENT_TRY_ECODE(pClient, n,
"MsgId=%u: Transaction failed.", msgIdReq);
460 BSCLIENT_TRY_NM_ECODE(pClient, n,
"MsgId=%u", msgIdRsp);
467 LOGDIAG3(
"%s: Write16: 0x%02x <-- 0x%04x.",
468 bsClientAttrGetName(pClient), uAddr, huVal);
474 BsVConnHnd_T hndVConn,
481 static BsProxyMsgId_T msgIdRsp = BsProxyMsgIdRspOk;
484 byte_t buf[BSPROXY_MSG_MAX_LEN];
491 BSCLIENT_TRY_EXPR(pClient, BSCLIENT_HAS_VCONN(pClient, hndVConn),
492 BS_ECODE_BAD_VAL,
"VConn=%d", hndVConn);
495 bTrace = bsClientAttrGetTraceState(pClient, hndVConn);
500 msgReq.
m_addr = (byte_t)uAddr;
505 msgReq.
m_tuples.
u.m_buf[n].m_servo_id = (byte_t)tuples[n].m_nServoId;
506 msgReq.
m_tuples.
u.m_buf[n].m_val = (ushort_t)tuples[n].m_uVal;
516 BSCLIENT_TRY_NM_ECODE(pClient, n,
"MsgId=%u", msgIdReq);
521 n = bsClientTrans(pClient, hndVConn,
522 msgIdReq, buf, (
size_t)n,
523 msgIdRsp, buf,
sizeof(buf));
526 BSCLIENT_TRY_ECODE(pClient, n,
"MsgId=%u: Transaction failed.", msgIdReq);
528 LOGDIAG3(
"%s: SyncWrite: %u tuples to 0x%02x",
529 bsClientAttrGetName(pClient), uCount, uAddr);
535 BsVConnHnd_T hndVConn,
544 byte_t buf[BSPROXY_MSG_MAX_LEN];
551 BSCLIENT_TRY_EXPR(pClient, BSCLIENT_HAS_VCONN(pClient, hndVConn),
552 BS_ECODE_BAD_VAL,
"VConn=%d", hndVConn);
555 bTrace = bsClientAttrGetTraceState(pClient, hndVConn);
568 BSCLIENT_TRY_NM_ECODE(pClient, n,
"MsgId=%u", msgIdReq);
573 n = bsClientTrans(pClient, hndVConn,
574 msgIdReq, buf, (
size_t)n,
575 msgIdRsp, buf,
sizeof(buf));
578 BSCLIENT_TRY_ECODE(pClient, n,
"MsgId=%u: Transaction failed.", msgIdReq);
586 BSCLIENT_TRY_NM_ECODE(pClient, n,
"MsgId=%u", msgIdRsp);
588 *pPong = msgRsp.
m_pong?
true:
false;
594 BsVConnHnd_T hndVConn,
598 static BsProxyMsgId_T msgIdRsp = BsProxyMsgIdRspOk;
601 byte_t buf[BSPROXY_MSG_MAX_LEN];
608 BSCLIENT_TRY_EXPR(pClient, BSCLIENT_HAS_VCONN(pClient, hndVConn),
609 BS_ECODE_BAD_VAL,
"VConn=%d", hndVConn);
612 bTrace = bsClientAttrGetTraceState(pClient, hndVConn);
625 BSCLIENT_TRY_NM_ECODE(pClient, n,
"MsgId=%u", msgIdReq);
630 n = bsClientTrans(pClient, hndVConn,
631 msgIdReq, buf, (
size_t)n,
632 msgIdRsp, buf,
sizeof(buf));
635 BSCLIENT_TRY_ECODE(pClient, n,
"MsgId=%u: Transaction failed.", msgIdReq);
641 BsVConnHnd_T hndVConn,
645 static BsProxyMsgId_T msgIdRsp = BsProxyMsgIdRspOk;
648 byte_t buf[BSPROXY_MSG_MAX_LEN];
655 BSCLIENT_TRY_EXPR(pClient, BSCLIENT_HAS_VCONN(pClient, hndVConn),
656 BS_ECODE_BAD_VAL,
"VConn=%d", hndVConn);
659 bTrace = bsClientAttrGetTraceState(pClient, hndVConn);
672 BSCLIENT_TRY_NM_ECODE(pClient, n,
"MsgId=%u", msgIdReq);
677 n = bsClientTrans(pClient, hndVConn,
678 msgIdReq, buf, (
size_t)n,
679 msgIdRsp, buf,
sizeof(buf));
682 BSCLIENT_TRY_ECODE(pClient, n,
"MsgId=%u: Transaction failed.", msgIdReq);
684 LOGDIAG3(
"%s: SetHalfDuplexCtl: %d", bsClientAttrGetName(pClient), nSignal);
INLINE_IN_H int BsDynaPackReqSyncWrite(BsDynaReqSyncWrite_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsDynaReqSyncWrite ITV message in big-endian byte order into the output buffer.
bsProxy client library Dynamixel interface.
INLINE_IN_H int BsDynaPackReqSetHalfDuplexCtl(BsDynaReqSetHalfDuplexCtl_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsDynaReqSetHalfDuplexCtl ITV message in big-endian byte order into the output buffer...
byte_t m_data_size
data_size
INLINE_IN_H int BsDynaPackReqWrite8(BsDynaReqWrite8_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsDynaReqWrite8 ITV message in big-endian byte order into the output buffer.
INLINE_IN_H int BsDynaUnpackRspWrite8(byte_t buf[], size_t uMsgLen, BsDynaRspWrite8_T *pStruct, bool_t bTrace)
Unpack a BsDynaRspWrite8 ITV message in big-endian byte order from the input buffer.
INLINE_IN_H int BsDynaPackReqReset(BsDynaReqReset_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsDynaReqReset ITV message in big-endian byte order into the output buffer.
INLINE_IN_H int BsDynaPackReqOpenArgs(BsDynaReqOpenArgs_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsDynaReqOpenArgs ITV message in big-endian byte order into the output buffer.
byte_t m_servo_id
servo_id
uint_t m_baudrate
baudrate
static BsClientAppInfo_T bsDynaAppInfo
client application information.
struct BsDynaReqSyncWrite_T::@0 m_tuples
vector
const char * bsDynaGetMsgName(BsClient_P pClient, BsVConnHnd_T hndVConn, uint_t uMsgId)
Get the Dynamixel message name.
byte_t m_servo_id
servo_id
byte_t m_servo_id
servo_id
#define DYNA_ID_NUMOF
number of unique servo id's
int bsDynaRead8(BsClient_P pClient, BsVConnHnd_T hndVConn, int nServoId, uint_t uAddr, byte_t *pVal, uint_t *pAlarms)
Proxied request to read an 8-bit value from a servo's control table.
INLINE_IN_H int BsDynaUnpackRspRead8(byte_t buf[], size_t uMsgLen, BsDynaRspRead8_T *pStruct, bool_t bTrace)
Unpack a BsDynaRspRead8 ITV message in big-endian byte order from the input buffer.
const NMMsgDef_T * BsDynaLookupMsgDef(BsDynaMsgId_T eMsgId)
Look up the message definition associated with the message id.
INLINE_IN_H int BsDynaPackReqRead8(BsDynaReqRead8_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsDynaReqRead8 ITV message in big-endian byte order into the output buffer.
INLINE_IN_H int BsDynaPackReqWrite16(BsDynaReqWrite16_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsDynaReqWrite16 ITV message in big-endian byte order into the output buffer.
uint_t m_baudrate
baudrate
int bsDynaWrite16(BsClient_P pClient, BsVConnHnd_T hndVConn, int nServoId, uint_t uAddr, ushort_t huVal, uint_t *pAlarms)
Proxied request to write a 16-bit value to a servo's control table.
size_t m_count
vector item count
byte_t m_servo_id
servo_id
INLINE_IN_H int BsDynaUnpackRspWrite16(byte_t buf[], size_t uMsgLen, BsDynaRspWrite16_T *pStruct, bool_t bTrace)
Unpack a BsDynaRspWrite16 ITV message in big-endian byte order from the input buffer.
int bsDynaClose(BsClient_P pClient, BsVConnHnd_T hndVConn)
Request proxy server to close client's proxied Dynamixel servo chain vitual connection.
INLINE_IN_H int BsDynaPackReqPing(BsDynaReqPing_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsDynaReqPing ITV message in big-endian byte order into the output buffer. ...
INLINE_IN_H int BsDynaUnpackRspRead16(byte_t buf[], size_t uMsgLen, BsDynaRspRead16_T *pStruct, bool_t bTrace)
Unpack a BsDynaRspRead16 ITV message in big-endian byte order from the input buffer.
int bsDynaOpen(BsClient_P pClient, const char *sDevName, int nBaudRate, bool_t bInitTrace)
Request proxy server to establish a virtual connection to the Dynamixel servo chain using the USB2Dyn...
byte_t m_servo_id
servo_id
INLINE_IN_H int BsDynaUnpackRspPing(byte_t buf[], size_t uMsgLen, BsDynaRspPing_T *pStruct, bool_t bTrace)
Unpack a BsDynaRspPing ITV message in big-endian byte order from the input buffer.
int bsDynaWrite8(BsClient_P pClient, BsVConnHnd_T hndVConn, int nServoId, uint_t uAddr, byte_t byVal, uint_t *pAlarms)
Proxied request to write an 8-bit value to a servo's control table.
INLINE_IN_H int BsDynaPackReqRead16(BsDynaReqRead16_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsDynaReqRead16 ITV message in big-endian byte order into the output buffer.
byte_t m_servo_id
servo_id
int bsDynaRead16(BsClient_P pClient, BsVConnHnd_T hndVConn, int nServoId, uint_t uAddr, ushort_t *pVal, uint_t *pAlarms)
Proxied request to read a 16-bit value from a servo's control table.
Server/Client Dynamixel NetMsgs XML Definitions.
#define BS_DYNA_SERVER_MOD
server plugin dll module
INLINE_IN_H int BsDynaPackReqSetBaudRate(BsDynaReqSetBaudRate_T *pStruct, byte_t buf[], size_t bufSize, bool_t bTrace)
Pack a BsDynaReqSetBaudRate ITV message in big-endian byte order into the output buffer.
int bsDynaSetBaudRate(BsClient_P pClient, BsVConnHnd_T hndVConn, int nBaudRate)
Proxied request to set the Dynamixel Bus baud rate.
int bsDynaSetHalfDuplexCtl(BsClient_P pClient, BsVConnHnd_T hndVConn, int nSignal)
Proxied request to set the half-duplex control signal.
int bsDynaSyncWrite(BsClient_P pClient, BsVConnHnd_T hndVConn, uint_t uAddr, uint_t uDataSize, DynaSyncWriteTuple_T tuples[], uint_t uCount)
Proxied request to synchronously write values to servos.
int bsDynaPing(BsClient_P pClient, BsVConnHnd_T hndVConn, int nServoId, bool_t *pPong)
Proxied request to ping a servo.
union BsDynaReqSyncWrite_T::@0::@1 u
aligned vector items
int bsDynaReset(BsClient_P pClient, BsVConnHnd_T hndVConn, int nServoId)
Proxied request to reset a servo to defaults.