Dynamixel  2.9.5
RoadNarrows Robotics Dynamixel Package
DynaShellCmdMegaScan Class Reference

MegaScan command. More...

Inheritance diagram for DynaShellCmdMegaScan:
DynaShellCmd

Public Member Functions

void Exec (DynaShell &shell, int argc, char *argv[])
 Scan interface at all supported baudrates for connected servos. 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 Member Functions

DynaCommCommNew (DynaShell &shell, const char *sUri, int nBaudRate)
 Create a new open dynamixel bus object. More...
 
- 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...
 

Additional Inherited Members

- 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

MegaScan command.

Definition at line 825 of file dynashell_cmd_if.cxx.

Member Function Documentation

DynaComm* DynaShellCmdMegaScan::CommNew ( DynaShell shell,
const char *  sUri,
int  nBaudRate 
)
inlineprotected

Create a new open dynamixel bus object.

Parameters
shellDynamixel shell.
sUriDynamixel bus [proxied] device Uniform Resource Id.
nBaudRateDevice and servo baudrate.
Returns
Returns new DynaComm object on success, NULL on failure.

Definition at line 959 of file dynashell_cmd_if.cxx.

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

960  {
961  DynaComm *pDynaComm = DynaComm::New(sUri, nBaudRate);
962 
963  if( pDynaComm == NULL )
964  {
965  shell.Error("Failed to create %s@%d.", sUri, nBaudRate);
966  }
967 
968  else if( !pDynaComm->IsOpen() )
969  {
970  shell.Error("Failed to open %s@%d.", sUri, nBaudRate);
971  delete pDynaComm;
972  pDynaComm = NULL;
973  }
974 
975  return pDynaComm;
976  }
virtual bool IsOpen()
Test if Dynamixel Bus is open.
Definition: DynaComm.h:383
static DynaComm * New(const char *sUri, int nBaudRate)
Archetype constructor to create a new Dynamixel bus communication derived instance.
Definition: DynaComm.cxx:179
void Error(int rc, const char *sFmt,...)
Raise error on dynamixel error code.
Definition: dynashell.cxx:808
Dynamixel Bus Communications Abstract Base Class.
Definition: DynaComm.h:80
void DynaShellCmdMegaScan::Exec ( DynaShell shell,
int  argc,
char *  argv[] 
)
inlinevirtual

Scan interface at all supported baudrates for connected servos.

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

Implements DynaShellCmd.

Definition at line 860 of file dynashell_cmd_if.cxx.

References DYNA_ID_MIN, DYNA_ID_NUMOF, DYNA_MODEL_NUM_GENERIC, DynaComm::Ping(), DynaServo::ReadModelNumber(), DynaShell::Response(), and TRY.

861  {
862  static int baudTbl[] =
863  {
864  1000000, 500000, 400000, 250000, 200000, 115200, 57600, 19200, 9600
865  };
866 
867  char *sUri;
868  DynaComm *pComm;
869  int nBaudRate;
870  int i;
871  int nServoId;
872  uint_t cnt;
873  uint_t uModelNum;
874 
875  TRY( ChkArgCnt(shell, argc) );
876 
877  sUri = argv[0];
878 
879  shell.Response("Mega Scan on Interface %s.\n", sUri);
880 
881  for(i=0; i<arraysize(baudTbl); ++i)
882  {
883  shell.Response("%8d baudrate\n", baudTbl[i]);
884 
885  pComm = CommNew(shell, sUri, baudTbl[i]);
886 
887  if( pComm == NULL )
888  {
889  continue;
890  }
891 
892  for(nServoId=DYNA_ID_MIN, cnt=0; nServoId<DYNA_ID_NUMOF; ++nServoId)
893  {
894  if( pComm->Ping(nServoId) )
895  {
896  if( DynaServo::ReadModelNumber(*pComm, nServoId, &uModelNum) < 0 )
897  {
898  uModelNum = DYNA_MODEL_NUM_GENERIC;
899  }
900  shell.Response("%4d:0x%04x", nServoId, uModelNum);
901  fflush(stdout);
902  ++cnt;
903  if( (cnt % 5) == 0 )
904  {
905  shell.Response("\n");
906  }
907  }
908  }
909 
910  if( cnt > 0 )
911  {
912  if( (cnt % 5) != 0 )
913  {
914  shell.Response("\n");
915  }
916  shell.Response(" %d servos found @%d baudrate\n", cnt, baudTbl[i]);
917  }
918 
919  delete pComm;
920  }
921  }
#define DYNA_MODEL_NUM_GENERIC
generic, base model
Definition: Dynamixel.h:119
static int ReadModelNumber(DynaComm &comm, int nServoId, uint_t *pModelNum)
Read the servo model number from the servo&#39;s EEPROM.
Definition: DynaServo.cxx:256
#define DYNA_ID_MIN
minimum servo id
Definition: Dynamixel.h:146
virtual bool Ping(int nServoId)=0
Ping the servo.
DynaComm * CommNew(DynaShell &shell, const char *sUri, int nBaudRate)
Create a new open dynamixel bus object.
#define DYNA_ID_NUMOF
number of unique servo id&#39;s
Definition: Dynamixel.h:148
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).
#define TRY(boolexpr,...)
Try boolean expression.
Definition: dynashell_cmd.h:89
Dynamixel Bus Communications Abstract Base Class.
Definition: DynaComm.h:80
virtual char* DynaShellCmdMegaScan::TabCompletion ( DynaShell shell,
const char *  sText,
size_t  uTextLen,
int  nState,
const char *  sContext 
)
inlinevirtual

Command tab completion generator.

Completes <device>

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 938 of file dynashell_cmd_if.cxx.

References ReadLine::FileCompletionGenerator().

943  {
944  // <device>
945  return ReadLine::FileCompletionGenerator(sText, nState);
946  }
static char * FileCompletionGenerator(const char *sText, int nState)
File name tab completion generator.

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