Macros | Functions
ev3_servo.c File Reference

EV3 Servo Motors. More...

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "modp_numtoa.h"
#include "ev3.h"
#include "ev3_port.h"
#include "ev3_servo.h"

Macros

#define EV3_SERVO_IMPLEMENT
 
#define PATH_PREF_LEN   28
 
#define DESC_SPOT   "///"
 
#define PATH_ADDRESS   "/sys/class/servo-motor/motor" DESC_SPOT "address"
 
#define PATH_COMMAND   "/sys/class/servo-motor/motor" DESC_SPOT "command"
 
#define PATH_DRIVER_NAME   "/sys/class/servo-motor/motor" DESC_SPOT "driver_name"
 
#define PATH_MAX_PULSE_SP   "/sys/class/servo-motor/motor" DESC_SPOT "max_pulse_sp"
 
#define PATH_MID_PULSE_SP   "/sys/class/servo-motor/motor" DESC_SPOT "mid_pulse_sp"
 
#define PATH_MIN_PULSE_SP   "/sys/class/servo-motor/motor" DESC_SPOT "min_pulse_sp"
 
#define PATH_POLARITY   "/sys/class/servo-motor/motor" DESC_SPOT "polarity"
 
#define PATH_POSITION_SP   "/sys/class/servo-motor/motor" DESC_SPOT "position_sp"
 
#define PATH_RATE_SP   "/sys/class/servo-motor/motor" DESC_SPOT "rate_sp"
 
#define PATH_STATE   "/sys/class/servo-motor/motor" DESC_SPOT "state"
 

Functions

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

EV3 Servo Motors.

(ev3_servo.yu-c)

Author
Vitaly Kravtsov (in4li.nosp@m.o@gm.nosp@m.ail.c.nosp@m.om)