Dynamixel  2.9.5
RoadNarrows Robotics Dynamixel Package
DynaShellCmdScan Class Reference

Scan command. More...

Inheritance diagram for DynaShellCmdScan:
DynaShellCmd

Public Member Functions

void Exec (DynaShell &shell, int argc, char *argv[])
 Scan for all connected servos and add to chain. 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 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...
 

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

Detailed Description

Scan command.

Definition at line 324 of file dynashell_cmd_if.cxx.

Member Function Documentation

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

Scan for all connected servos and add to chain.

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

Implements DynaShellCmd.

Definition at line 348 of file dynashell_cmd_if.cxx.

References DynaChain::AddNewServosByScan(), DynaBgThread::BgThreadStatePaused, DynaBgThread::BgThreadStateRunning, DynaBgThread::GetCurrentState(), DynaChain::GetNumberInChain(), DynaShell::m_pDynaBgThread, DynaShell::m_pDynaChain, DynaBgThread::RegisterChainAgent(), DynaShell::Response(), DynaBgThread::Run(), DynaBgThread::Stop(), TRY, and DynaBgThread::UnregisterAgent().

349  {
350  DynaBgThread::BgThreadState eOldState;
351  int nNumServos;
352 
353  TRY( ChkArgCnt(shell, argc) );
354  TRY( ChkComm(shell) );
355  TRY( ChkChain(shell) );
356 
357  switch( (eOldState = shell.m_pDynaBgThread->GetCurrentState()) )
358  {
361  shell.m_pDynaBgThread->Stop();
362  break;
363  default:
364  break;
365  }
366 
368 
370 
372 
373  nNumServos = shell.m_pDynaChain->GetNumberInChain();
374 
375  if( (eOldState == DynaBgThread::BgThreadStateRunning) && (nNumServos > 0) )
376  {
377  shell.m_pDynaBgThread->Run();
378  }
379 
380  shell.Response("Added %d servos to chain.\n", nNumServos);
381  }
virtual void RegisterChainAgent(DynaChain *pChain)
Register the Dynamixel chain for control and monitoring.
BgThreadState
Background thread states.
Definition: DynaBgThread.h:251
bool ChkChain(DynaShell &shell)
Check that the servo chain exists.
BgThreadState GetCurrentState()
Get current background thread state.
Definition: DynaBgThread.h:415
virtual uint_t GetNumberInChain() const
Get the number of servos currently in chain.
Definition: DynaChain.h:140
virtual int Run()
Run the background thread control and monitoring tasks.
virtual int AddNewServosByScan()
Scan and add all discovered and created servos to the Dynamixel chain.
Definition: DynaChain.cxx:229
virtual int Stop()
Stop control and monitoring tasks.
virtual void UnregisterAgent()
Unregister any chain or servo from control and monitoring.
void Response(const char *sFmt,...)
Print formatted success response.
Definition: dynashell.cxx:763
virtual bool ChkArgCnt(DynaShell &shell, int argc)
Check that the argument count is within the class (min,max).
DynaBgThread * m_pDynaBgThread
dynamixel chain
Definition: dynashell.h:361
#define TRY(boolexpr,...)
Try boolean expression.
Definition: dynashell_cmd.h:89
bool ChkComm(DynaShell &shell)
Check that Dynamixel communication exists and is open.
DynaChain * m_pDynaChain
dynamixel chain
Definition: dynashell.h:360

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