Dynamixel  2.9.5
RoadNarrows Robotics Dynamixel Package
spintest.c File Reference

Simple continuous spin test of a servo. More...

#include <sys/select.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <libgen.h>
#include <ctype.h>
#include "rnr/rnrconfig.h"
#include "rnr/opts.h"
#include "rnr/log.h"
#include "dynamixel/Dynamixel.h"
#include "dynamixel/libDynamixel.h"
#include "version.h"

Go to the source code of this file.

Macros

#define APP_EC_OK   0
 
#define APP_EC_USAGE   2
 
#define APP_EC_EXEC   4
 

Functions

bool_t peekc (uint_t msec)
 
static void MainInitArgs (int argc, char *argv[])
 Main argument initialization. More...
 
static int AppDynaInit ()
 
static void AppDynaRun ()
 
static void AppDynaDeinit ()
 
static void AppBanner ()
 
int main (int argc, char *argv[])
 Main. More...
 

Variables

static char * Argv0
 the command
 
static char * OptsSerDev = "/dev/ttyUSB0"
 the serial device
 
static int OptsBaudRate = 1000000
 serial baudrate
 
static int OptsSpeed = 200
 servo speed
 
static int ArgServoId = -1
 servo id
 
static OptsPgmInfo_T AppPgmInfo
 Program information. More...
 
static OptsInfo_T AppOptsInfo []
 Command line options information.
 
int ServoDir = DYNA_DIR_CW
 
DynaHandle_T * DynaHandle
 

Detailed Description

Simple continuous spin test of a servo.

LastChangedDate
2011-07-15 14:10:46 -0600 (Fri, 15 Jul 2011)
Rev
1139
Author
Robin Knight (robin.nosp@m..kni.nosp@m.ght@r.nosp@m.oadn.nosp@m.arrow.nosp@m.s.co.nosp@m.m)

Definition in file spintest.c.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Main.

Parameters
argcCommand-line argument count.
argvCommand-line argument list.
Exit Status:
Program exits with 0 success, > 0 on failure.

Definition at line 321 of file spintest.c.

References MainInitArgs().

322 {
323  int rc;
324 
325  MainInitArgs(argc, argv);
326 
327  if( (rc = AppDynaInit()) == APP_EC_OK )
328  {
329  AppBanner();
330  AppDynaRun();
331  AppDynaDeinit();
332  }
333 
334  return rc >= 0? APP_EC_OK: -rc;
335 }
static void MainInitArgs(int argc, char *argv[])
Main argument initialization.
Definition: spintest.c:183
static void MainInitArgs ( int  argc,
char *  argv[] 
)
static

Main argument initialization.

Parameters
argcCommand-line argument count.
argvCommand-line argument list.
Exits:
Program terminates on conversion error.

Definition at line 183 of file spintest.c.

References AppOptsInfo, AppPgmInfo, ArgServoId, Argv0, DYNA_ADDR_GOAL_SPEED_LSB, DYNA_ADDR_LIM_CCW_LSB, DYNA_ADDR_LIM_CW_LSB, DYNA_CCW_POS_CONT_MODE, DYNA_CW_POS_CONT_MODE, DYNA_DIR_CCW, DYNA_DIR_CW, DYNA_GOAL_SPEED_DIR_CCW, DYNA_GOAL_SPEED_DIR_CW, DYNA_GOAL_SPEED_MAG_MASK, DYNA_OK, DYNA_TORQUE_MAX_RAW, OptsBaudRate, OptsSerDev, OptsSpeed, and PkgInfo.

Referenced by main().

184 {
185  // name of this process
186  Argv0 = basename(argv[0]);
187 
188  // parse input options
189  argv = OptsGet(Argv0, &PkgInfo, &AppPgmInfo, AppOptsInfo, true,
190  &argc, argv);
191 
192  if( argc < 1 )
193  {
194  OptsInvalid(Argv0, "no servo id specified.");
195  }
196  else
197  {
198  ArgServoId = atoi(argv[0]);
199  }
200 
201  if( OptsSpeed < 0 )
202  {
203  ServoDir = DYNA_DIR_CCW;
204  OptsSpeed = -OptsSpeed;
205  }
206  else
207  {
208  ServoDir = DYNA_DIR_CW;
209  }
210 }
static int OptsSpeed
servo speed
Definition: spintest.c:75
#define DYNA_DIR_CW
clockwise direction
Definition: Dynamixel.h:191
static OptsPgmInfo_T AppPgmInfo
Program information.
Definition: spintest.c:82
static char * Argv0
the command
Definition: spintest.c:72
#define DYNA_DIR_CCW
counterclockwise direction
Definition: Dynamixel.h:193
static const PkgInfo_T PkgInfo
Definition: version.h:45
static int ArgServoId
servo id
Definition: spintest.c:76
static OptsInfo_T AppOptsInfo[]
Command line options information.
Definition: spintest.c:101

Variable Documentation

OptsPgmInfo_T AppPgmInfo
static
Initial value:
=
{
"id",
"Spin dynamixel servo continuously.",
"The %P test application spins the given servo continuously at the given "
"speed.",
NULL
}

Program information.

Definition at line 82 of file spintest.c.

Referenced by MainInitArgs().