Data Structures | Macros | Enumerations | Functions
Servo motors

Access to EV3 servo motors. More...

Data Structures

struct  EV3_SERVO
 Structure of a servo motor descriptor. More...
 

Macros

#define SERVO_DIR   "/sys/class/servo-motor"
 
#define SERVO_DESC__LIMIT_   DESC_LIMIT
 
#define SERVO__NONE_   SERVO_DESC__LIMIT_
 

Enumerations

enum  { SERVO_TYPE__NONE_ = 0, SERVO_MOTOR, SERVO_TYPE__COUNT_, SERVO_TYPE__UNKNOWN_ = SERVO_TYPE__COUNT_ }
 Identifiers of servo motor types. More...
 
enum  {
  SERVO_COMMAND__NONE_ = 0, SERVO_RUN, SERVO_FLOAT, SERVO_COMMAND__COUNT_,
  SERVO_COMMAND__UNKNOWN_ = SERVO_COMMAND__COUNT_
}
 Common identifiers of servo motor "command" attribute. More...
 
enum  {
  SERVO_POLARITY__NONE_ = 0, SERVO_NORMAL, SERVO_INVERSED, SERVO_POLARITY__COUNT_,
  SERVO_POLARITY__UNKNOWN_ = SERVO_POLARITY__COUNT_
}
 Common identifiers of servo motor "polarity" attribute. More...
 
enum  { SERVO_STATE__NONE_ = 0, SERVO_RUNNING = 0x1L }
 Common identifiers of servo motor "state" attribute.
 

Functions

 EV3_SERVO_VAR (EV3_SERVO ev3_servo[SERVO_DESC__LIMIT_])
 Vector of servo motor descriptors (filled by ev3_servo_init).
 
size_t get_servo_address (uint8_t sn, char *buf, size_t sz)
 Read "address" attribute of the servo motor. More...
 
size_t get_servo_command (uint8_t sn, char *buf, size_t sz)
 Read "command" attribute of the servo motor. More...
 
size_t set_servo_command (uint8_t sn, char *value)
 Write "command" attribute of the servo motor. More...
 
size_t multi_set_servo_command (uint8_t *sn, char *value)
 Write "command" attribute of several servo motors. More...
 
size_t get_servo_driver_name (uint8_t sn, char *buf, size_t sz)
 Read "driver_name" attribute of the servo motor. More...
 
size_t get_servo_max_pulse_sp (uint8_t sn, int *buf)
 Read "max_pulse_sp" attribute of the servo motor. More...
 
size_t set_servo_max_pulse_sp (uint8_t sn, int value)
 Write "max_pulse_sp" attribute of the servo motor. More...
 
size_t multi_set_servo_max_pulse_sp (uint8_t *sn, int value)
 Write "max_pulse_sp" attribute of several servo motors. More...
 
size_t get_servo_mid_pulse_sp (uint8_t sn, int *buf)
 Read "mid_pulse_sp" attribute of the servo motor. More...
 
size_t set_servo_mid_pulse_sp (uint8_t sn, int value)
 Write "mid_pulse_sp" attribute of the servo motor. More...
 
size_t multi_set_servo_mid_pulse_sp (uint8_t *sn, int value)
 Write "mid_pulse_sp" attribute of several servo motors. More...
 
size_t get_servo_min_pulse_sp (uint8_t sn, int *buf)
 Read "min_pulse_sp" attribute of the servo motor. More...
 
size_t set_servo_min_pulse_sp (uint8_t sn, int value)
 Write "min_pulse_sp" attribute of the servo motor. More...
 
size_t multi_set_servo_min_pulse_sp (uint8_t *sn, int value)
 Write "min_pulse_sp" attribute of several servo motors. More...
 
size_t get_servo_polarity (uint8_t sn, char *buf, size_t sz)
 Read "polarity" attribute of the servo motor. More...
 
size_t set_servo_polarity (uint8_t sn, char *value)
 Write "polarity" attribute of the servo motor. More...
 
size_t multi_set_servo_polarity (uint8_t *sn, char *value)
 Write "polarity" attribute of several servo motors. More...
 
size_t get_servo_position_sp (uint8_t sn, int *buf)
 Read "position_sp" attribute of the servo motor. More...
 
size_t set_servo_position_sp (uint8_t sn, int value)
 Write "position_sp" attribute of the servo motor. More...
 
size_t multi_set_servo_position_sp (uint8_t *sn, int value)
 Write "position_sp" attribute of several servo motors. More...
 
size_t get_servo_rate_sp (uint8_t sn, int *buf)
 Read "rate_sp" attribute of the servo motor. More...
 
size_t set_servo_rate_sp (uint8_t sn, int value)
 Write "rate_sp" attribute of the servo motor. More...
 
size_t multi_set_servo_rate_sp (uint8_t *sn, int value)
 Write "rate_sp" attribute of several servo motors. More...
 
size_t get_servo_state (uint8_t sn, char *buf, size_t sz)
 Read "state" attribute of the servo motor. More...
 
const char * ev3_servo_type (INX_T type_inx)
 Get name of the specified servo motor type. More...
 
INX_T get_servo_type_inx (uint8_t sn)
 Read "driver_name" attribute and get index of the servo motor type. More...
 
size_t get_servo_desc (uint8_t sn, EV3_SERVO *desc)
 Read servo motor attributes that are required for filling the descriptor. More...
 
EV3_SERVOev3_servo_desc (uint8_t sn)
 Get descriptor of the servo motor. More...
 
INX_T ev3_servo_desc_type_inx (uint8_t sn)
 Get type from the servo motor descriptor. More...
 
uint8_t ev3_servo_desc_port (uint8_t sn)
 Get EV3 port from the servo motor descriptor. More...
 
uint8_t ev3_servo_desc_extport (uint8_t sn)
 Get extended port from the servo motor descriptor. More...
 
uint8_t ev3_servo_desc_addr (uint8_t sn)
 Get I2C address from the servo motor descriptor. More...
 
char * ev3_servo_port_name (uint8_t sn, char *buf)
 Assemble EV3 port name from the servo motor descriptor. More...
 
bool ev3_search_servo (INX_T type_inx, uint8_t *sn, uint8_t from)
 Search of a sequence number of the specified servo motor type. More...
 
bool ev3_search_servo_plugged_in (uint8_t port, uint8_t extport, uint8_t *sn, uint8_t from)
 Search of a sequence number the servo motor by plug-in attributes. More...
 
const char * ev3_servo_command (INX_T command_inx)
 Get name of the specified servo motor command. More...
 
INX_T get_servo_command_inx (uint8_t sn)
 Read "command" attribute of the servo motor and get the index. More...
 
size_t set_servo_command_inx (uint8_t sn, INX_T command_inx)
 Write "command" attribute of the servo motor by the index. More...
 
size_t multi_set_servo_command_inx (uint8_t *sn, INX_T command_inx)
 Write "command" attribute of several servo motors by the index. More...
 
const char * ev3_servo_polarity (INX_T polarity_inx)
 Get name of the specified servo motor polarity. More...
 
INX_T get_servo_polarity_inx (uint8_t sn)
 Read "polarity" attribute of the servo motor and get the index. More...
 
size_t set_servo_polarity_inx (uint8_t sn, INX_T polarity_inx)
 Write "polarity" attribute of the servo motor by the index. More...
 
size_t multi_set_servo_polarity_inx (uint8_t *sn, INX_T polarity_inx)
 Write "polarity" attribute of several servo motors by the index. More...
 
size_t get_servo_state_flags (uint8_t sn, FLAGS_T *flags)
 Read "state" attribute of the servo motor and get the flags. More...
 
int ev3_servo_init (void)
 Detect connected servo motors. More...
 

Detailed Description

Access to EV3 servo motors.

See also
http://www.ev3dev.org/docs/drivers/servo-motor-class/

Macro Definition Documentation

#define SERVO__NONE_   SERVO_DESC__LIMIT_

Servo motor is not found.

#define SERVO_DESC__LIMIT_   DESC_LIMIT

Limit of servo motor descriptors.

#define SERVO_DIR   "/sys/class/servo-motor"

Directory of servo motors.

Enumeration Type Documentation

anonymous enum

Identifiers of servo motor types.

Enumerator
SERVO_TYPE__COUNT_ 

Count of servo motor types.

anonymous enum

Common identifiers of servo motor "command" attribute.

Enumerator
SERVO_COMMAND__COUNT_ 

Count of servo motor "command" attribute.

anonymous enum

Common identifiers of servo motor "polarity" attribute.

Enumerator
SERVO_POLARITY__COUNT_ 

Count of servo motor "polarity" attribute.

Function Documentation

bool ev3_search_servo ( INX_T  type_inx,
uint8_t *  sn,
uint8_t  from 
)

Search of a sequence number of the specified servo motor type.

Parameters
type_inxServo motor type.
[out]snBuffer for the sequence number.
fromSearch initial value.
Returns
Flag - the servo motor is found.
bool ev3_search_servo_plugged_in ( uint8_t  port,
uint8_t  extport,
uint8_t *  sn,
uint8_t  from 
)

Search of a sequence number the servo motor by plug-in attributes.

Parameters
portEV3 port.
extportExtended port.
[out]snBuffer for the sequence number.
fromSearch initial value.
Returns
Flag - the servo motor is found.
const char* ev3_servo_command ( INX_T  command_inx)

Get name of the specified servo motor command.

Parameters
command_inxIndex of the servo motor command.
Returns
Requested value.
EV3_SERVO* ev3_servo_desc ( uint8_t  sn)

Get descriptor of the servo motor.

Parameters
snSequence number.
Returns
Pointer to the servo motor descriptor.
uint8_t ev3_servo_desc_addr ( uint8_t  sn)

Get I2C address from the servo motor descriptor.

Parameters
snSequence number.
Returns
Requested value.
uint8_t ev3_servo_desc_extport ( uint8_t  sn)

Get extended port from the servo motor descriptor.

Parameters
snSequence number.
Returns
Requested value.
uint8_t ev3_servo_desc_port ( uint8_t  sn)

Get EV3 port from the servo motor descriptor.

Parameters
snSequence number.
Returns
Requested value.
INX_T ev3_servo_desc_type_inx ( uint8_t  sn)

Get type from the servo motor descriptor.

Parameters
snSequence number.
Returns
Requested value.
int ev3_servo_init ( void  )

Detect connected servo motors.

Returns
Number of found servo motors or -1 in case of an error.
const char* ev3_servo_polarity ( INX_T  polarity_inx)

Get name of the specified servo motor polarity.

Parameters
polarity_inxIndex of the servo motor polarity.
Returns
Requested value.
char* ev3_servo_port_name ( uint8_t  sn,
char *  buf 
)

Assemble EV3 port name from the servo motor descriptor.

Parameters
snSequence number.
[out]bufBuffer for result.
Returns
Requested value.
const char* ev3_servo_type ( INX_T  type_inx)

Get name of the specified servo motor type.

Parameters
type_inxIndex of the servo motor type.
Returns
Requested value.
size_t get_servo_address ( uint8_t  sn,
char *  buf,
size_t  sz 
)

Read "address" attribute of the servo motor.

Parameters
snSequence number.
[out]bufBuffer for result.
szBuffer size.
Returns
Count of read bytes.
size_t get_servo_command ( uint8_t  sn,
char *  buf,
size_t  sz 
)

Read "command" attribute of the servo motor.

Parameters
snSequence number.
[out]bufBuffer for result.
szBuffer size.
Returns
Count of read bytes.
INX_T get_servo_command_inx ( uint8_t  sn)

Read "command" attribute of the servo motor and get the index.

Parameters
snSequence number.
Returns
Requested value.
size_t get_servo_desc ( uint8_t  sn,
EV3_SERVO desc 
)

Read servo motor attributes that are required for filling the descriptor.

Parameters
snSequence number.
descBuffer for the descriptor.
Returns
Count of read bytes.
size_t get_servo_driver_name ( uint8_t  sn,
char *  buf,
size_t  sz 
)

Read "driver_name" attribute of the servo motor.

Parameters
snSequence number.
[out]bufBuffer for result.
szBuffer size.
Returns
Count of read bytes.
size_t get_servo_max_pulse_sp ( uint8_t  sn,
int *  buf 
)

Read "max_pulse_sp" attribute of the servo motor.

Parameters
snSequence number.
[out]bufBuffer for result.
Returns
Count of read bytes.
size_t get_servo_mid_pulse_sp ( uint8_t  sn,
int *  buf 
)

Read "mid_pulse_sp" attribute of the servo motor.

Parameters
snSequence number.
[out]bufBuffer for result.
Returns
Count of read bytes.
size_t get_servo_min_pulse_sp ( uint8_t  sn,
int *  buf 
)

Read "min_pulse_sp" attribute of the servo motor.

Parameters
snSequence number.
[out]bufBuffer for result.
Returns
Count of read bytes.
size_t get_servo_polarity ( uint8_t  sn,
char *  buf,
size_t  sz 
)

Read "polarity" attribute of the servo motor.

Parameters
snSequence number.
[out]bufBuffer for result.
szBuffer size.
Returns
Count of read bytes.
INX_T get_servo_polarity_inx ( uint8_t  sn)

Read "polarity" attribute of the servo motor and get the index.

Parameters
snSequence number.
Returns
Requested value.
size_t get_servo_position_sp ( uint8_t  sn,
int *  buf 
)

Read "position_sp" attribute of the servo motor.

Parameters
snSequence number.
[out]bufBuffer for result.
Returns
Count of read bytes.
size_t get_servo_rate_sp ( uint8_t  sn,
int *  buf 
)

Read "rate_sp" attribute of the servo motor.

Parameters
snSequence number.
[out]bufBuffer for result.
Returns
Count of read bytes.
size_t get_servo_state ( uint8_t  sn,
char *  buf,
size_t  sz 
)

Read "state" attribute of the servo motor.

Parameters
snSequence number.
[out]bufBuffer for result.
szBuffer size.
Returns
Count of read bytes.
size_t get_servo_state_flags ( uint8_t  sn,
FLAGS_T *  flags 
)

Read "state" attribute of the servo motor and get the flags.

Parameters
snSequence number.
flagsBuffer for the flags.
Returns
Count of read bytes.
INX_T get_servo_type_inx ( uint8_t  sn)

Read "driver_name" attribute and get index of the servo motor type.

Parameters
snSequence number.
Returns
Requested value.
size_t multi_set_servo_command ( uint8_t *  sn,
char *  value 
)

Write "command" attribute of several servo motors.

Parameters
snVector of sequence numbers ending with DESC_LIMIT.
valueAttribute value.
Returns
Count of written bytes.
size_t multi_set_servo_command_inx ( uint8_t *  sn,
INX_T  command_inx 
)

Write "command" attribute of several servo motors by the index.

Parameters
snVector of sequence numbers ending with DESC_LIMIT.
command_inxIndex of the servo motor command.
Returns
Count of written bytes.
size_t multi_set_servo_max_pulse_sp ( uint8_t *  sn,
int  value 
)

Write "max_pulse_sp" attribute of several servo motors.

Parameters
snVector of sequence numbers ending with DESC_LIMIT.
valueAttribute value.
Returns
Count of written bytes.
size_t multi_set_servo_mid_pulse_sp ( uint8_t *  sn,
int  value 
)

Write "mid_pulse_sp" attribute of several servo motors.

Parameters
snVector of sequence numbers ending with DESC_LIMIT.
valueAttribute value.
Returns
Count of written bytes.
size_t multi_set_servo_min_pulse_sp ( uint8_t *  sn,
int  value 
)

Write "min_pulse_sp" attribute of several servo motors.

Parameters
snVector of sequence numbers ending with DESC_LIMIT.
valueAttribute value.
Returns
Count of written bytes.
size_t multi_set_servo_polarity ( uint8_t *  sn,
char *  value 
)

Write "polarity" attribute of several servo motors.

Parameters
snVector of sequence numbers ending with DESC_LIMIT.
valueAttribute value.
Returns
Count of written bytes.
size_t multi_set_servo_polarity_inx ( uint8_t *  sn,
INX_T  polarity_inx 
)

Write "polarity" attribute of several servo motors by the index.

Parameters
snVector of sequence numbers ending with DESC_LIMIT.
polarity_inxIndex of the servo motor polarity.
Returns
Count of written bytes.
size_t multi_set_servo_position_sp ( uint8_t *  sn,
int  value 
)

Write "position_sp" attribute of several servo motors.

Parameters
snVector of sequence numbers ending with DESC_LIMIT.
valueAttribute value.
Returns
Count of written bytes.
size_t multi_set_servo_rate_sp ( uint8_t *  sn,
int  value 
)

Write "rate_sp" attribute of several servo motors.

Parameters
snVector of sequence numbers ending with DESC_LIMIT.
valueAttribute value.
Returns
Count of written bytes.
size_t set_servo_command ( uint8_t  sn,
char *  value 
)

Write "command" attribute of the servo motor.

Parameters
snSequence number.
valueAttribute value.
Returns
Count of written bytes.
size_t set_servo_command_inx ( uint8_t  sn,
INX_T  command_inx 
)

Write "command" attribute of the servo motor by the index.

Parameters
snSequence number.
command_inxIndex of the servo motor command.
Returns
Count of written bytes.
size_t set_servo_max_pulse_sp ( uint8_t  sn,
int  value 
)

Write "max_pulse_sp" attribute of the servo motor.

Parameters
snSequence number.
valueAttribute value.
Returns
Count of written bytes.
size_t set_servo_mid_pulse_sp ( uint8_t  sn,
int  value 
)

Write "mid_pulse_sp" attribute of the servo motor.

Parameters
snSequence number.
valueAttribute value.
Returns
Count of written bytes.
size_t set_servo_min_pulse_sp ( uint8_t  sn,
int  value 
)

Write "min_pulse_sp" attribute of the servo motor.

Parameters
snSequence number.
valueAttribute value.
Returns
Count of written bytes.
size_t set_servo_polarity ( uint8_t  sn,
char *  value 
)

Write "polarity" attribute of the servo motor.

Parameters
snSequence number.
valueAttribute value.
Returns
Count of written bytes.
size_t set_servo_polarity_inx ( uint8_t  sn,
INX_T  polarity_inx 
)

Write "polarity" attribute of the servo motor by the index.

Parameters
snSequence number.
polarity_inxIndex of the servo motor polarity.
Returns
Count of written bytes.
size_t set_servo_position_sp ( uint8_t  sn,
int  value 
)

Write "position_sp" attribute of the servo motor.

Parameters
snSequence number.
valueAttribute value.
Returns
Count of written bytes.
size_t set_servo_rate_sp ( uint8_t  sn,
int  value 
)

Write "rate_sp" attribute of the servo motor.

Parameters
snSequence number.
valueAttribute value.
Returns
Count of written bytes.