Dynamixel  2.9.5
RoadNarrows Robotics Dynamixel Package
DynaShellCmd Class Referenceabstract

Dynamixel shell command abstract base class. More...

#include <dynashell_cmd.h>

Inheritance diagram for DynaShellCmd:
DynaShellCmdBgtGetState DynaShellCmdBgtStart DynaShellCmdBgtStop DynaShellCmdChainIn DynaShellCmdChainOut DynaShellCmdCreate DynaShellCmdDestroy DynaShellCmdEStop DynaShellCmdExit DynaShellCmdFreeze DynaShellCmdHelp DynaShellCmdLink DynaShellCmdList DynaShellCmdLoadRecording DynaShellCmdLog DynaShellCmdMegaScan DynaShellCmdMoveAtSpeedTo DynaShellCmdNULL DynaShellCmdPing DynaShellCmdPlay DynaShellCmdQuit DynaShellCmdReadByte DynaShellCmdReadMaxTorqueLimit DynaShellCmdRelease DynaShellCmdSaveRecording DynaShellCmdScan DynaShellCmdScript DynaShellCmdSetHalfDuplexCtl DynaShellCmdSetOdometer DynaShellCmdSetPid DynaShellCmdSetSoftTorqueTh DynaShellCmdTrain DynaShellCmdUnlink DynaShellCmdWait DynaShellCmdWriteByte DynaShellCmdWriteMaxTorqueLimit

Public Member Functions

 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 Exec (DynaShell &shell, int argc, char *argv[])=0
 Execute command abstract function. 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 char * TabCompletion (DynaShell &shell, const char *sText, size_t uTextLen, int nState, const char *sContext)
 Default command tab completion generator. More...
 
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 Member Functions

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...
 

Protected Attributes

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
 

Detailed Description

Dynamixel shell command abstract base class.

Definition at line 80 of file dynashell_cmd.h.

Member Function Documentation

virtual bool DynaShellCmd::ChkArgCnt ( DynaShell shell,
int  argc 
)
inlinevirtual

Check that the argument count is within the class (min,max).

Parameters
shellDynamixel shell.
argcArgument count.
Returns
Returns true if the check passed.
Otherwise a shell error is printed and false is returned.

Definition at line 219 of file dynashell_cmd.h.

220  {
221  if( (m_nArgCntMin == 0) && (m_nArgCntMax == 0) )
222  {
223  return ChkArgCnt0(shell, argc);
224  }
225  else if( m_nArgCntMin == m_nArgCntMax )
226  {
227  return ChkArgCntEQ(shell, argc, m_nArgCntMin);
228  }
229 
230  if( (m_nArgCntMin > 0) && !ChkArgCntGE(shell, argc, m_nArgCntMin) )
231  {
232  return false;
233  }
234 
235  if( (m_nArgCntMax > 0) && !ChkArgCntLE(shell, argc, m_nArgCntMax) )
236  {
237  return false;
238  }
239 
240  return true;
241  }
bool ChkArgCntEQ(DynaShell &shell, int argc, int eq)
Check that the argument count is equal to the required.
bool ChkArgCnt0(DynaShell &shell, int argc)
Check that the argument count is zero.
const int m_nArgCntMax
maximum argument count (0 if not max)
const int m_nArgCntMin
minimum argument count
bool ChkArgCntGE(DynaShell &shell, int argc, int min)
Check argument count against minimum required.
bool ChkArgCntLE(DynaShell &shell, int argc, int max)
Check argument count against maximum allowed.
bool DynaShellCmd::ChkArgCnt0 ( DynaShell shell,
int  argc 
)
inline

Check that the argument count is zero.

Parameters
shellDynamixel shell.
argcArgument count.
Returns
Returns true if the check passed.
Otherwise a shell error is printed and false is returned.

Definition at line 253 of file dynashell_cmd.h.

References DynaShell::Error().

254  {
255  if( argc != 0 )
256  {
257  shell.Error("Command has no arguments.");
258  return false;
259  }
260  return true;
261  }
void Error(int rc, const char *sFmt,...)
Raise error on dynamixel error code.
Definition: dynashell.cxx:808
bool DynaShellCmd::ChkArgCntEQ ( DynaShell shell,
int  argc,
int  eq 
)
inline

Check that the argument count is equal to the required.

Parameters
shellDynamixel shell.
argcArgument count.
minRequired minimum count.
Returns
Returns true if the check passed.
Otherwise a shell error is printed and false is returned.

Definition at line 274 of file dynashell_cmd.h.

References DynaShell::Error().

275  {
276  if( argc != eq )
277  {
278  shell.Error("Argument count %d != required %d.", argc, eq);
279  return false;
280  }
281  return true;
282  }
void Error(int rc, const char *sFmt,...)
Raise error on dynamixel error code.
Definition: dynashell.cxx:808
bool DynaShellCmd::ChkArgCntGE ( DynaShell shell,
int  argc,
int  min 
)
inline

Check argument count against minimum required.

Parameters
shellDynamixel shell.
argcArgument count.
minRequired minimum count.
Returns
Returns true if the check passed.
Otherwise a shell error is printed and false is returned.

Definition at line 295 of file dynashell_cmd.h.

References DynaShell::Error().

296  {
297  if( argc < min )
298  {
299  shell.Error("Argument count %d < minimum %d.", argc, min);
300  return false;
301  }
302  return true;
303  }
void Error(int rc, const char *sFmt,...)
Raise error on dynamixel error code.
Definition: dynashell.cxx:808
bool DynaShellCmd::ChkArgCntLE ( DynaShell shell,
int  argc,
int  max 
)
inline

Check argument count against maximum allowed.

Parameters
shellDynamixel shell.
argcArgument count.
minMaximum count.
Returns
Returns true if the check passed.
Otherwise a shell error is printed and false is returned.

Definition at line 316 of file dynashell_cmd.h.

References DynaShell::Error().

317  {
318  if( argc > max )
319  {
320  shell.Error("Argument count %d > maximum %d.", argc, max);
321  return false;
322  }
323  return true;
324  }
void Error(int rc, const char *sFmt,...)
Raise error on dynamixel error code.
Definition: dynashell.cxx:808
bool DynaShellCmd::ChkChain ( DynaShell shell)
inline

Check that the servo chain exists.

Parameters
shellDynamixel shell.
Returns
Returns true if the check passed.
Otherwise a shell error is printed and false is returned.

Definition at line 354 of file dynashell_cmd.h.

References DynaShell::Error(), and DynaShell::m_pDynaChain.

355  {
356  if( shell.m_pDynaChain == NULL )
357  {
358  shell.Error("No dynamixel chain.");
359  return false;
360  }
361  return true;
362  }
DynaChain * m_pDynaChain
dynamixel chain
Definition: dynashell.h:360
void Error(int rc, const char *sFmt,...)
Raise error on dynamixel error code.
Definition: dynashell.cxx:808
bool DynaShellCmd::ChkChainHasServo ( DynaShell shell,
int  nServoId 
)
inline

Check that the given servo is present in the chain.

Parameters
shellDynamixel shell.
nServoIdServo id.
Returns
Returns true if the check passed.
Otherwise a shell error is printed and false is returned.

Definition at line 398 of file dynashell_cmd.h.

References DynaShell::Error(), DynaChain::HasServo(), and DynaShell::m_pDynaChain.

399  {
400  if( !ChkChainNotEmpty(shell) )
401  {
402  return false;
403  }
404 
405  if( !shell.m_pDynaChain->HasServo(nServoId) )
406  {
407  shell.Error("Servo %d not found in chain.", nServoId);
408  return false;
409  }
410  return true;
411  }
bool ChkChainNotEmpty(DynaShell &shell)
Check that the servo chain exists and is not empty.
virtual bool HasServo(int nServoId) const
Definition: DynaChain.h:113
DynaChain * m_pDynaChain
dynamixel chain
Definition: dynashell.h:360
void Error(int rc, const char *sFmt,...)
Raise error on dynamixel error code.
Definition: dynashell.cxx:808
bool DynaShellCmd::ChkChainIsMasterServo ( DynaShell shell,
int  nServoId 
)
inline

Check that the given servo is a master.

Parameters
shellDynamixel shell.
nServoIdServo id.
Returns
Returns true if the check passed.
Otherwise a shell error is printed and false is returned.

Definition at line 423 of file dynashell_cmd.h.

References DynaShell::Error(), DynaChain::GetServo(), DynaServo::IsMaster(), and DynaShell::m_pDynaChain.

424  {
425  if( !ChkChainHasServo(shell, nServoId) )
426  {
427  return false;
428  }
429 
430  if( !shell.m_pDynaChain->GetServo(nServoId)->IsMaster() )
431  {
432  shell.Error("Servo %d not a master.", nServoId);
433  return false;
434  }
435  return true;
436  }
bool ChkChainHasServo(DynaShell &shell, int nServoId)
Check that the given servo is present in the chain.
bool IsMaster() const
Test if this servo is a master.
Definition: DynaServo.h:223
virtual DynaServo * GetServo(int nServoId)
Definition: DynaChain.h:129
DynaChain * m_pDynaChain
dynamixel chain
Definition: dynashell.h:360
void Error(int rc, const char *sFmt,...)
Raise error on dynamixel error code.
Definition: dynashell.cxx:808
bool DynaShellCmd::ChkChainNotEmpty ( DynaShell shell)
inline

Check that the servo chain exists and is not empty.

Parameters
shellDynamixel shell.
Returns
Returns true if the check passed.
Otherwise a shell error is printed and false is returned.

Definition at line 373 of file dynashell_cmd.h.

References DynaShell::Error(), DynaChain::GetNumberInChain(), and DynaShell::m_pDynaChain.

374  {
375  if( !ChkChain(shell) )
376  {
377  return false;
378  }
379 
380  if( shell.m_pDynaChain->GetNumberInChain() == 0 )
381  {
382  shell.Error("No servos in dynamixel chain. Try scanning.");
383  return false;
384  }
385  return true;
386  }
bool ChkChain(DynaShell &shell)
Check that the servo chain exists.
virtual uint_t GetNumberInChain() const
Get the number of servos currently in chain.
Definition: DynaChain.h:140
DynaChain * m_pDynaChain
dynamixel chain
Definition: dynashell.h:360
void Error(int rc, const char *sFmt,...)
Raise error on dynamixel error code.
Definition: dynashell.cxx:808
bool DynaShellCmd::ChkComm ( DynaShell shell)
inline

Check that Dynamixel communication exists and is open.

Parameters
shellDynamixel shell.
Returns
Returns true if the check passed.
Otherwise a shell error is printed and false is returned.

Definition at line 335 of file dynashell_cmd.h.

References DynaShell::Error(), DynaComm::IsOpen(), and DynaShell::m_pDynaComm.

336  {
337  if( (shell.m_pDynaComm == NULL) || !shell.m_pDynaComm->IsOpen() )
338  {
339  shell.Error("No open dynamixel communication.");
340  return false;
341  }
342  return true;
343  }
DynaComm * m_pDynaComm
dynamixel bus communication
Definition: dynashell.h:359
virtual bool IsOpen()
Test if Dynamixel Bus is open.
Definition: DynaComm.h:383
void Error(int rc, const char *sFmt,...)
Raise error on dynamixel error code.
Definition: dynashell.cxx:808
char * DynaShellCmd::eow ( const char *  s)
protected

Find end of word.

A word is define as a set of non-whitespace characters delimitedd by white space.

Parameters
sNull-terminated string to search.
Returns
Returns a pointer to the first trailing white space character or NULL if no white space found.

Definition at line 264 of file dynashell_cmd.cxx.

265 {
266  char *t;
267 
268  if( (s == NULL) || (*s == 0) )
269  {
270  return NULL;
271  }
272 
273  for(t=(char *)s; *t; ++t)
274  {
275  if( isspace(*t) )
276  {
277  break;
278  }
279  }
280 
281  return *t? t: NULL;
282 }
Definition: t.py:1
const char* DynaShellCmd::GetCmdHelpBrief ( )
inline

Get shell command name brief description.

Returns
Command name string.

Definition at line 124 of file dynashell_cmd.h.

Referenced by DynaShell::PublishCommand().

124 { return m_sCmdHelpBrief; }
const char * m_sCmdHelpBrief
command help brief
const char* DynaShellCmd::GetCmdName ( )
inline

Get dynamixel shell command name.

Returns
Command name string.

Definition at line 117 of file dynashell_cmd.h.

Referenced by DynaShell::PublishCommand().

117 { return m_sCmdName; }
const char * m_sCmdName
command name
int DynaShellCmd::GetPublishedLevel ( ) const
inline

Get the command's published level.

The root level is 0.

Returns
Published level.

Definition at line 144 of file dynashell_cmd.h.

Referenced by DynaShell::Run().

145  {
146  return m_nPubLevel;
147  }
int m_nPubLevel
command&#39;s published level (depth)
const char* DynaShellCmd::GetPublishedName ( ) const
inline

Get the command's published name.

Returns
Published name.

Definition at line 154 of file dynashell_cmd.h.

Referenced by DynaShell::PublishCommand().

155  {
156  return m_sPubName;
157  }
char * m_sPubName
command&#39;s published name
void DynaShellCmd::PrintBlock ( int  col,
int  indent,
int  width,
const char *  sText 
)
protectedvirtual

Print a block of indented text of width.

Parameters
colCurrent column position.
indentColumn indentation from 0.
widthColumn width from 0;
sTextText to print.

Definition at line 178 of file dynashell_cmd.cxx.

179 {
180  int n; // word length
181  const char *s, *t; // working pointers
182 
183  if( col >= width )
184  {
185  printf("\n");
186  col = 0;
187  }
188 
189  for(s=sText; *s != 0; )
190  {
191  // find end of word
192  t = eow(s);
193 
194  // end of string
195  if( t == NULL )
196  {
197  n = (int)strlen(s);
198  t = s + n;
199  }
200 
201  // got a word
202  else
203  {
204  n = (int)(t - s);
205  }
206 
207  // will exceed line limit, go to next line
208  if( col+n >= width )
209  {
210  printf("\n");
211  col = printf("%*s", indent, "");
212  }
213 
214  // print help word
215  if( n > 0 )
216  {
217  col += printf("%.*s", n, s);
218  }
219  //col += printf("|");
220 
221  switch(*t)
222  {
223  case ' ':
224  case '\t':
225  case '\v':
226  col += printf(" ");
227  s = ++t;
228  break;
229  case '\n':
230  case '\r':
231  printf("\n");
232  col = printf("%*s", indent, "");
233  s = ++t;
234  break;
235  case 0:
236  default:
237  s = t;
238  }
239  }
240 
241  printf("\n");
242 }
char * eow(const char *s)
Find end of word.
Definition: t.py:1
void DynaShellCmd::PrintHelp ( int  indent = 0,
int  width = 80 
)
virtual

Print command help with the description aligned at the given indentation.

Parameters
indentColumn indentation.
widthColumn width.

Definition at line 87 of file dynashell_cmd.cxx.

Referenced by DynaShellCmdHelp::Exec().

88 {
89  int col; // current column position
90 
91  // print brief
92  PrintDelim(width, '-');
93  col = printf("%s - ", m_sPubName);
94  PrintBlock(col, indent, width, m_sCmdHelpBrief);
95 
96  // print synopses
97  if( (m_sCmdHelpArgs != NULL) && (*m_sCmdHelpArgs != 0) )
98  {
99  printf("\n");
100  PrintSynopses(indent, width);
101  }
102 
103 
104  // print description
105  if( (m_sCmdHelpDesc != NULL) && (*m_sCmdHelpDesc != 0) )
106  {
107  printf("\n");
108  PrintBlock(0, indent, width, m_sCmdHelpDesc);
109  }
110 }
virtual void PrintBlock(int col, int indent, int width, const char *sText)
Print a block of indented text of width.
const char * m_sCmdHelpDesc
command help description
char * m_sPubName
command&#39;s published name
const char * m_sCmdHelpBrief
command help brief
const char * m_sCmdHelpArgs
command help arguments
virtual void PrintSynopses(int indent, int width)
Print synsopses.
void DynaShellCmd::PrintSynopses ( int  indent,
int  width 
)
protectedvirtual

Print synsopses.

Parameters
indentColumn indentation.
widthColumn width.

Definition at line 118 of file dynashell_cmd.cxx.

119 {
120  int col; // current column position
121  char buf[256]; // working buffer
122  const char *s, *t; // working pointers
123  size_t len; // working length
124  bool bFirst; // first synopsis
125  bool bLast ; // last synopsis
126 
127  if( (m_sCmdHelpArgs != NULL) && (*m_sCmdHelpArgs != 0) )
128  {
129  for(s=m_sCmdHelpArgs, bFirst=true, bLast=false; !bLast; )
130  {
131  t = strchr(s, '\n');
132 
133  if( t != NULL )
134  {
135  len = (size_t)(t-s);
136  }
137  else
138  {
139  len = strlen(s);
140  bLast = true;
141  }
142  if( len >= sizeof(buf) )
143  {
144  len = sizeof(buf)-1;
145  }
146 
147  strncpy(buf, s, len);
148  buf[len] = 0;
149 
150  if( bFirst )
151  {
152  col = printf("%*sUsage: %s ", indent, "", m_sPubName);
153  bFirst = false;
154  }
155  else
156  {
157  col = printf("%*s %s ", indent, "", m_sPubName);
158  }
159 
160  PrintBlock(col, col, width, buf);
161 
162  if( t != NULL )
163  {
164  s = t + 1;
165  }
166  }
167  }
168 }
Definition: t.py:1
virtual void PrintBlock(int col, int indent, int width, const char *sText)
Print a block of indented text of width.
char * m_sPubName
command&#39;s published name
const char * m_sCmdHelpArgs
command help arguments
int DynaShellCmd::SetPublishedInfo ( int  nLevel,
const char *  sParent = NULL 
)
inline

Set the command's published information.

Parameters
nLevelPublished level. The root level is 0.
sParentParent to which this command was published.

Definition at line 165 of file dynashell_cmd.h.

References newstr().

Referenced by DynaShell::PublishCommand().

166  {
167  m_nPubLevel = nLevel;
168 
169  if( m_sPubName != NULL )
170  {
171  delete[] m_sPubName;
172  }
173  if( sParent == NULL )
174  {
176  }
177  else
178  {
179  m_sPubName = new char[strlen(sParent)+1+strlen(m_sCmdName)+1];
180  sprintf(m_sPubName, "%s %s", sParent, m_sCmdName);
181  }
182  }
const char * m_sCmdName
command name
char * newstr(const char *s)
Allocate new duplicated string.
int m_nPubLevel
command&#39;s published level (depth)
char * m_sPubName
command&#39;s published name
virtual char* DynaShellCmd::TabCompletion ( DynaShell shell,
const char *  sText,
size_t  uTextLen,
int  nState,
const char *  sContext 
)
inlinevirtual

Default command tab completion generator.

The default is no completion.

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 in DynaShellCmdWriteByte, DynaShellCmdReadByte, DynaShellCmdPlay, DynaShellCmdWriteMaxTorqueLimit, DynaShellCmdSetHalfDuplexCtl, DynaShellCmdTrain, DynaShellCmdReadMaxTorqueLimit, DynaShellCmdSaveRecording, DynaShellCmdBgtStart, DynaShellCmdMegaScan, DynaShellCmdUnlink, DynaShellCmdChainOut, DynaShellCmdScript, DynaShellCmdLink, DynaShellCmdChainIn, DynaShellCmdLog, DynaShellCmdLoadRecording, DynaShellCmdSetPid, DynaShellCmdHelp, and DynaShellCmdCreate.

Definition at line 199 of file dynashell_cmd.h.

204  {
205  //return ReadLine::FileCompletionGenerator(sText, nState);
206  return NULL;
207  }
bool DynaShellCmd::ToBool ( DynaShell shell,
const char *  sArg,
bool *  pVal 
)
inline

Convert command argument to boolean.

Parameters
shellDynamixel shell.
sArgString argument to convert.
[out]pValConverted argument.
Returns
Returns true on success, otherwise a shell error is printed and false is returned.

Definition at line 507 of file dynashell_cmd.h.

References DynaShell::Error().

508  {
509  int i;
510  char *t;
511 
512  if( !strcasecmp(sArg, "t") || !strcasecmp(sArg, "true") )
513  {
514  *pVal = true;
515  return true;
516  }
517  else if( !strcasecmp(sArg, "f") || !strcasecmp(sArg, "false") )
518  {
519  *pVal = false;
520  return true;
521  }
522 
523  i = (int)strtol(sArg, &t, 0);
524 
525  if( *t != 0 )
526  {
527  shell.Error("Argument value \"%s\": Not an boolean.", sArg);
528  return false;
529  }
530 
531  *pVal = i? true: false;
532 
533  return true;
534  }
Definition: t.py:1
void Error(int rc, const char *sFmt,...)
Raise error on dynamixel error code.
Definition: dynashell.cxx:808
bool DynaShellCmd::ToDouble ( DynaShell shell,
const char *  sArg,
double *  pVal 
)
inline

Convert command argument to double.

Parameters
shellDynamixel shell.
sArgString argument to convert.
[out]pValConverted argument.
Returns
Returns true on success, otherwise a shell error is printed and false is returned.

Definition at line 487 of file dynashell_cmd.h.

References DynaShell::Error().

488  {
489  if( sscanf(sArg, "%lf", pVal) != 1 )
490  {
491  shell.Error("Argument value \"%s\": Not a floating-point number.", sArg);
492  return false;
493  }
494  return true;
495  }
void Error(int rc, const char *sFmt,...)
Raise error on dynamixel error code.
Definition: dynashell.cxx:808
bool DynaShellCmd::ToInt ( DynaShell shell,
const char *  sArg,
int *  pVal 
)
inline

Convert command argument to integer.

Parameters
shellDynamixel shell.
sArgString argument to convert.
[out]pValConverted argument.
Returns
Returns true on success, otherwise a shell error is printed and false is returned.

Definition at line 448 of file dynashell_cmd.h.

References DynaShell::Error().

449  {
450  char *t;
451 
452  *pVal = (int)strtol(sArg, &t, 0);
453 
454  if( *t != 0 )
455  {
456  shell.Error("Argument value \"%s\": Not an integer.", sArg);
457  return false;
458  }
459  return true;
460  }
Definition: t.py:1
void Error(int rc, const char *sFmt,...)
Raise error on dynamixel error code.
Definition: dynashell.cxx:808
bool DynaShellCmd::ToUInt ( DynaShell shell,
const char *  sArg,
uint_t *  pVal 
)
inline

Convert command argument to unsigned integer.

Parameters
shellDynamixel shell.
sArgString argument to convert.
[out]pValConverted argument.
Returns
Returns true on success, otherwise a shell error is printed and false is returned.

Definition at line 472 of file dynashell_cmd.h.

473  {
474  return ToInt(shell, sArg, (int *)pVal);
475  }
bool ToInt(DynaShell &shell, const char *sArg, int *pVal)
Convert command argument to integer.

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