Dynamixel  2.9.5
RoadNarrows Robotics Dynamixel Package
DynaShellCmdSetHalfDuplexCtl Class Reference

Set halfduplex control command. More...

Inheritance diagram for DynaShellCmdSetHalfDuplexCtl:
DynaShellCmd

Public Member Functions

void Exec (DynaShell &shell, int argc, char *argv[])
 Set software half-duplex control signal. More...
 
virtual char * TabCompletion (DynaShell &shell, const char *sText, size_t uTextLen, int nState, const char *sContext)
 Command tab completion generator. More...
 
- Public Member Functions inherited from DynaShellCmd
 DynaShellCmd (int nArgCntMin=0, int nArgCntMax=0)
 Default constructor.
 
virtual ~DynaShellCmd ()
 Default destructor.
 
const char * GetCmdName ()
 Get dynamixel shell command name. More...
 
const char * GetCmdHelpBrief ()
 Get shell command name brief description. More...
 
virtual void PrintHelp (int indent=0, int width=80)
 Print command help with the description aligned at the given indentation. More...
 
int GetPublishedLevel () const
 
const char * GetPublishedName () const
 
int SetPublishedInfo (int nLevel, const char *sParent=NULL)
 
virtual bool ChkArgCnt (DynaShell &shell, int argc)
 Check that the argument count is within the class (min,max). More...
 
bool ChkArgCnt0 (DynaShell &shell, int argc)
 Check that the argument count is zero. More...
 
bool ChkArgCntEQ (DynaShell &shell, int argc, int eq)
 Check that the argument count is equal to the required. More...
 
bool ChkArgCntGE (DynaShell &shell, int argc, int min)
 Check argument count against minimum required. More...
 
bool ChkArgCntLE (DynaShell &shell, int argc, int max)
 Check argument count against maximum allowed. More...
 
bool ChkComm (DynaShell &shell)
 Check that Dynamixel communication exists and is open. More...
 
bool ChkChain (DynaShell &shell)
 Check that the servo chain exists. More...
 
bool ChkChainNotEmpty (DynaShell &shell)
 Check that the servo chain exists and is not empty. More...
 
bool ChkChainHasServo (DynaShell &shell, int nServoId)
 Check that the given servo is present in the chain. More...
 
bool ChkChainIsMasterServo (DynaShell &shell, int nServoId)
 Check that the given servo is a master. More...
 
bool ToInt (DynaShell &shell, const char *sArg, int *pVal)
 Convert command argument to integer. More...
 
bool ToUInt (DynaShell &shell, const char *sArg, uint_t *pVal)
 Convert command argument to unsigned integer. More...
 
bool ToDouble (DynaShell &shell, const char *sArg, double *pVal)
 Convert command argument to double. More...
 
bool ToBool (DynaShell &shell, const char *sArg, bool *pVal)
 Convert command argument to boolean. More...
 

Protected Attributes

int m_nTabIndex
 tab completion: keyword index
 
- Protected Attributes inherited from DynaShellCmd
const char * m_sCmdName
 command name
 
const char * m_sCmdHelpBrief
 command help brief
 
const char * m_sCmdHelpArgs
 command help arguments
 
const char * m_sCmdHelpDesc
 command help description
 
const int m_nArgCntMin
 minimum argument count
 
const int m_nArgCntMax
 maximum argument count (0 if not max)
 
int m_nPubLevel
 command's published level (depth)
 
char * m_sPubName
 command's published name
 

Additional Inherited Members

- Protected Member Functions inherited from DynaShellCmd
virtual void PrintSynopses (int indent, int width)
 Print synsopses. More...
 
virtual void PrintBlock (int col, int indent, int width, const char *sText)
 Print a block of indented text of width. More...
 
virtual void PrintDelim (int width, const char cDelim)
 
char * eow (const char *s)
 Find end of word. More...
 

Detailed Description

Set halfduplex control command.

Definition at line 1280 of file dynashell_cmd_if.cxx.

Member Function Documentation

void DynaShellCmdSetHalfDuplexCtl::Exec ( DynaShell shell,
int  argc,
char *  argv[] 
)
inlinevirtual

Set software half-duplex control signal.

Parameters
shellDynamixel shell.
argcCommand argument count.
argvArray of arguments.

Implements DynaShellCmd.

Definition at line 1313 of file dynashell_cmd_if.cxx.

References DynaCommSerial::CtlSignalModemCTS, DynaCommSerial::CtlSignalModemRTS, DynaCommSerial::CtlSignalNone, DYNA_ECODE_BAD_VAL, DYNA_OK, DynaShell::Error(), DynaShell::m_pDynaComm, DynaShell::Ok(), DynaComm::SetHalfDuplexCtl(), and TRY.

1314  {
1315  int nSignal;
1316  int rc;
1317 
1318  TRY( ChkArgCnt(shell, argc) );
1319  TRY( ChkComm(shell) );
1320 
1321  if( !strncmp("none", argv[0], strlen(argv[0])) )
1322  {
1324  }
1325  else if( !strncmp("modem", argv[0], strlen(argv[0])) )
1326  {
1327  TRY( ChkArgCntEQ(shell, argc, 2) );
1328  if( !strncmp("cts", argv[1], strlen(argv[1])) )
1329  {
1331  }
1332  else if( !strncmp("rts", argv[1], strlen(argv[1])) )
1333  {
1335  }
1336  else
1337  {
1338  shell.Error(-DYNA_ECODE_BAD_VAL, "Unknown modem signal '%s'", argv[1]);
1339  return;
1340  }
1341  }
1342  else if( !strncmp("gpio", argv[0], strlen(argv[0])) )
1343  {
1344  TRY( ChkArgCntEQ(shell, argc, 2) );
1345  TRY( ToInt(shell, argv[1], &nSignal) );
1346  }
1347  else
1348  {
1349  shell.Error(-DYNA_ECODE_BAD_VAL, "Unknown signal type '%s'", argv[0]);
1350  return;
1351  }
1352 
1353  rc = shell.m_pDynaComm->SetHalfDuplexCtl(nSignal);
1354 
1355  if( rc != DYNA_OK )
1356  {
1357  shell.Error(rc, "Failed to set half-duplex %s signal control.", argv[0]);
1358  }
1359  else
1360  {
1361  shell.Ok();
1362  }
1363  }
bool ChkArgCntEQ(DynaShell &shell, int argc, int eq)
Check that the argument count is equal to the required.
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
DynaComm * m_pDynaComm
dynamixel bus communication
Definition: dynashell.h:359
not a signal, but a value to clear signal
bool ToInt(DynaShell &shell, const char *sArg, int *pVal)
Convert command argument to integer.
virtual void Ok()
Print standard ok success response.
Definition: dynashell.h:425
virtual int SetHalfDuplexCtl(int nSignal, HalfDuplexTxFunc_T fnEnableTx=NULL, HalfDuplexRxFunc_T fnEnableRx=NULL)=0
virtual bool ChkArgCnt(DynaShell &shell, int argc)
Check that the argument count is within the class (min,max).
#define TRY(boolexpr,...)
Try boolean expression.
Definition: dynashell_cmd.h:89
bool ChkComm(DynaShell &shell)
Check that Dynamixel communication exists and is open.
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
void Error(int rc, const char *sFmt,...)
Raise error on dynamixel error code.
Definition: dynashell.cxx:808
virtual char* DynaShellCmdSetHalfDuplexCtl::TabCompletion ( DynaShell shell,
const char *  sText,
size_t  uTextLen,
int  nState,
const char *  sContext 
)
inlinevirtual

Command tab completion generator.

Completes none | modem sig | gpio number

Parameters
shellDynamixel shell.
sTextPartial text string to complete.
uTextLenLength of text.
nStateGenerator state. If FIRST, then initialize any statics.
sContextGenerator context (i.e. canonical command path).
Returns
If a first/next match is made, return allocated completed match.
Otherwise return NULL.

Reimplemented from DynaShellCmd.

Definition at line 1380 of file dynashell_cmd_if.cxx.

References ReadLine::dupstr(), ReadLine::FIRST, and ReadLine::wc().

1385  {
1386  static const char *keywordsSigType[] = {"gpio", "modem", "none"};
1387  static const char *keywordsSigModem[] = {"cts", "rts"};
1388  static char cSigType = '\0';
1389 
1390  int nArgNum;
1391  int nServoId;
1392  const char *s;
1393  char buf[16];
1394 
1395  // argument number of already (expanded) arguments
1396  nArgNum = ReadLine::wc(sContext) - ReadLine::wc(m_sPubName);
1397 
1398  //
1399  // New command argument to complete - initialize.
1400  //
1401  if( nState == ReadLine::FIRST )
1402  {
1403  m_nTabIndex = 0;
1404  }
1405 
1406  // gpio | modem | none
1407  if( nArgNum == 0 )
1408  {
1409  while( m_nTabIndex < arraysize(keywordsSigType) )
1410  {
1411  s = keywordsSigType[m_nTabIndex++];
1412 
1413  if( !strncmp(s, sText, uTextLen) )
1414  {
1415  cSigType = *s;
1416  return ReadLine::dupstr(s);
1417  }
1418  }
1419  }
1420 
1421  else if( nArgNum == 1 )
1422  {
1423  // rts | cts
1424  if( cSigType == 'm' )
1425  {
1426  while( m_nTabIndex < arraysize(keywordsSigModem) )
1427  {
1428  s = keywordsSigModem[m_nTabIndex++];
1429 
1430  if( !strncmp(s, sText, uTextLen) )
1431  {
1432  return ReadLine::dupstr(s);
1433  }
1434  }
1435  }
1436  // NUM
1437  else if( cSigType == 'g' )
1438  {
1439  }
1440  //
1441  else if( cSigType == 'n' )
1442  {
1443  }
1444  }
1445 
1446  // no more matches
1447  return NULL;
1448  }
static const int FIRST
first state
static char * dupstr(const string &str)
Duplicate string.
char * m_sPubName
command&#39;s published name
static int wc(const string &str)
Count the words in the string.
int m_nTabIndex
tab completion: keyword index

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