Data Structures | Macros | Enumerations | Functions
DC motors

Access to EV3 DC motors. More...

Data Structures

struct  EV3_DC
 Structure of a DC motor descriptor. More...
 

Macros

#define DC_DIR   "/sys/class/dc-motor"
 
#define DC_DESC__LIMIT_   DESC_LIMIT
 
#define DC__NONE_   DC_DESC__LIMIT_
 

Enumerations

enum  { DC_TYPE__NONE_ = 0, RCX_MOTOR, DC_TYPE__COUNT_, DC_TYPE__UNKNOWN_ = DC_TYPE__COUNT_ }
 Identifiers of DC motor types. More...
 
enum  {
  DC_COMMAND__NONE_ = 0, DC_RUN_FOREVER, DC_RUN_TIMED, DC_RUN_DIRECT,
  DC_STOP, DC_COMMAND__COUNT_, DC_COMMAND__UNKNOWN_ = DC_COMMAND__COUNT_
}
 Common identifiers of DC motor "command" attribute. More...
 
enum  {
  DC_POLARITY__NONE_ = 0, DC_NORMAL, DC_INVERSED, DC_POLARITY__COUNT_,
  DC_POLARITY__UNKNOWN_ = DC_POLARITY__COUNT_
}
 Common identifiers of DC motor "polarity" attribute. More...
 
enum  {
  DC_STOP_ACTION__NONE_ = 0, DC_COAST, DC_BRAKE, DC_STOP_ACTION__COUNT_,
  DC_STOP_ACTION__UNKNOWN_ = DC_STOP_ACTION__COUNT_
}
 Common identifiers of DC motor "stop_action" attribute. More...
 
enum  { DC_STATE__NONE_ = 0, DC_RUNNING = 0x1L, DC_RAMPING = 0x2L }
 Common identifiers of DC motor "state" attribute.
 

Functions

 EV3_DC_VAR (EV3_DC ev3_dc[DC_DESC__LIMIT_])
 Vector of DC motor descriptors (filled by ev3_dc_init).
 
size_t get_dc_address (uint8_t sn, char *buf, size_t sz)
 Read "address" attribute of the DC motor. More...
 
size_t set_dc_command (uint8_t sn, char *value)
 Write "command" attribute of the DC motor. More...
 
size_t multi_set_dc_command (uint8_t *sn, char *value)
 Write "command" attribute of several DC motors. More...
 
size_t get_dc_commands (uint8_t sn, char *buf, size_t sz)
 Read "commands" attribute of the DC motor. More...
 
size_t get_dc_driver_name (uint8_t sn, char *buf, size_t sz)
 Read "driver_name" attribute of the DC motor. More...
 
size_t get_dc_duty_cycle (uint8_t sn, int *buf)
 Read "duty_cycle" attribute of the DC motor. More...
 
size_t get_dc_duty_cycle_sp (uint8_t sn, int *buf)
 Read "duty_cycle_sp" attribute of the DC motor. More...
 
size_t set_dc_duty_cycle_sp (uint8_t sn, int value)
 Write "duty_cycle_sp" attribute of the DC motor. More...
 
size_t multi_set_dc_duty_cycle_sp (uint8_t *sn, int value)
 Write "duty_cycle_sp" attribute of several DC motors. More...
 
size_t get_dc_polarity (uint8_t sn, char *buf, size_t sz)
 Read "polarity" attribute of the DC motor. More...
 
size_t set_dc_polarity (uint8_t sn, char *value)
 Write "polarity" attribute of the DC motor. More...
 
size_t multi_set_dc_polarity (uint8_t *sn, char *value)
 Write "polarity" attribute of several DC motors. More...
 
size_t get_dc_state (uint8_t sn, char *buf, size_t sz)
 Read "state" attribute of the DC motor. More...
 
size_t set_dc_stop_action (uint8_t sn, char *value)
 Write "stop_action" attribute of the DC motor. More...
 
size_t multi_set_dc_stop_action (uint8_t *sn, char *value)
 Write "stop_action" attribute of several DC motors. More...
 
size_t get_dc_stop_actions (uint8_t sn, char *buf, size_t sz)
 Read "stop_actions" attribute of the DC motor. More...
 
size_t get_dc_ramp_down_sp (uint8_t sn, int *buf)
 Read "ramp_down_sp" attribute of the DC motor. More...
 
size_t set_dc_ramp_down_sp (uint8_t sn, int value)
 Write "ramp_down_sp" attribute of the DC motor. More...
 
size_t multi_set_dc_ramp_down_sp (uint8_t *sn, int value)
 Write "ramp_down_sp" attribute of several DC motors. More...
 
size_t get_dc_ramp_up_sp (uint8_t sn, int *buf)
 Read "ramp_up_sp" attribute of the DC motor. More...
 
size_t set_dc_ramp_up_sp (uint8_t sn, int value)
 Write "ramp_up_sp" attribute of the DC motor. More...
 
size_t multi_set_dc_ramp_up_sp (uint8_t *sn, int value)
 Write "ramp_up_sp" attribute of several DC motors. More...
 
size_t get_dc_time_sp (uint8_t sn, int *buf)
 Read "time_sp" attribute of the DC motor. More...
 
size_t set_dc_time_sp (uint8_t sn, int value)
 Write "time_sp" attribute of the DC motor. More...
 
size_t multi_set_dc_time_sp (uint8_t *sn, int value)
 Write "time_sp" attribute of several DC motors. More...
 
const char * ev3_dc_type (INX_T type_inx)
 Get name of the specified DC motor type. More...
 
INX_T get_dc_type_inx (uint8_t sn)
 Read "driver_name" attribute and get index of the DC motor type. More...
 
size_t get_dc_desc (uint8_t sn, EV3_DC *desc)
 Read DC motor attributes that are required for filling the descriptor. More...
 
EV3_DCev3_dc_desc (uint8_t sn)
 Get descriptor of the DC motor. More...
 
INX_T ev3_dc_desc_type_inx (uint8_t sn)
 Get type from the DC motor descriptor. More...
 
uint8_t ev3_dc_desc_port (uint8_t sn)
 Get EV3 port from the DC motor descriptor. More...
 
uint8_t ev3_dc_desc_extport (uint8_t sn)
 Get extended port from the DC motor descriptor. More...
 
char * ev3_dc_port_name (uint8_t sn, char *buf)
 Assemble EV3 port name from the DC motor descriptor. More...
 
bool ev3_search_dc (INX_T type_inx, uint8_t *sn, uint8_t from)
 Search of a sequence number of the specified DC motor type. More...
 
bool ev3_search_dc_plugged_in (uint8_t port, uint8_t extport, uint8_t *sn, uint8_t from)
 Search of a sequence number the DC motor by plug-in attributes. More...
 
const char * ev3_dc_command (INX_T command_inx)
 Get name of the specified DC motor command. More...
 
size_t set_dc_command_inx (uint8_t sn, INX_T command_inx)
 Write "command" attribute of the DC motor by the index. More...
 
size_t multi_set_dc_command_inx (uint8_t *sn, INX_T command_inx)
 Write "command" attribute of several DC motors by the index. More...
 
const char * ev3_dc_polarity (INX_T polarity_inx)
 Get name of the specified DC motor polarity. More...
 
INX_T get_dc_polarity_inx (uint8_t sn)
 Read "polarity" attribute of the DC motor and get the index. More...
 
size_t set_dc_polarity_inx (uint8_t sn, INX_T polarity_inx)
 Write "polarity" attribute of the DC motor by the index. More...
 
size_t multi_set_dc_polarity_inx (uint8_t *sn, INX_T polarity_inx)
 Write "polarity" attribute of several DC motors by the index. More...
 
const char * ev3_dc_stop_action (INX_T stop_action_inx)
 Get name of the specified DC motor stop_action. More...
 
size_t set_dc_stop_action_inx (uint8_t sn, INX_T stop_action_inx)
 Write "stop_action" attribute of the DC motor by the index. More...
 
size_t multi_set_dc_stop_action_inx (uint8_t *sn, INX_T stop_action_inx)
 Write "stop_action" attribute of several DC motors by the index. More...
 
size_t get_dc_state_flags (uint8_t sn, FLAGS_T *flags)
 Read "state" attribute of the DC motor and get the flags. More...
 
int ev3_dc_init (void)
 Detect connected DC motors. More...
 

Detailed Description

Access to EV3 DC motors.

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

Macro Definition Documentation

#define DC__NONE_   DC_DESC__LIMIT_

DC motor is not found.

#define DC_DESC__LIMIT_   DESC_LIMIT

Limit of DC motor descriptors.

#define DC_DIR   "/sys/class/dc-motor"

Directory of DC motors.

Enumeration Type Documentation

anonymous enum

Identifiers of DC motor types.

Enumerator
DC_TYPE__COUNT_ 

Count of DC motor types.

anonymous enum

Common identifiers of DC motor "command" attribute.

Enumerator
DC_COMMAND__COUNT_ 

Count of DC motor "command" attribute.

anonymous enum

Common identifiers of DC motor "polarity" attribute.

Enumerator
DC_POLARITY__COUNT_ 

Count of DC motor "polarity" attribute.

anonymous enum

Common identifiers of DC motor "stop_action" attribute.

Enumerator
DC_STOP_ACTION__COUNT_ 

Count of DC motor "stop_action" attribute.

Function Documentation

const char* ev3_dc_command ( INX_T  command_inx)

Get name of the specified DC motor command.

Parameters
command_inxIndex of the DC motor command.
Returns
Requested value.
EV3_DC* ev3_dc_desc ( uint8_t  sn)

Get descriptor of the DC motor.

Parameters
snSequence number.
Returns
Pointer to the DC motor descriptor.
uint8_t ev3_dc_desc_extport ( uint8_t  sn)

Get extended port from the DC motor descriptor.

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

Get EV3 port from the DC motor descriptor.

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

Get type from the DC motor descriptor.

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

Detect connected DC motors.

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

Get name of the specified DC motor polarity.

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

Assemble EV3 port name from the DC motor descriptor.

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

Get name of the specified DC motor stop_action.

Parameters
stop_action_inxIndex of the DC motor stop_action.
Returns
Requested value.
const char* ev3_dc_type ( INX_T  type_inx)

Get name of the specified DC motor type.

Parameters
type_inxIndex of the DC motor type.
Returns
Requested value.
bool ev3_search_dc ( INX_T  type_inx,
uint8_t *  sn,
uint8_t  from 
)

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

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

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

Parameters
portEV3 port.
extportExtended port.
[out]snBuffer for the sequence number.
fromSearch initial value.
Returns
Flag - the DC motor is found.
size_t get_dc_address ( uint8_t  sn,
char *  buf,
size_t  sz 
)

Read "address" attribute of the DC motor.

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

Read "commands" attribute of the DC motor.

Parameters
snSequence number.
[out]bufBuffer for result.
szBuffer size.
Returns
Count of read bytes.
size_t get_dc_desc ( uint8_t  sn,
EV3_DC desc 
)

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

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

Read "driver_name" attribute of the DC motor.

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

Read "duty_cycle" attribute of the DC motor.

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

Read "duty_cycle_sp" attribute of the DC motor.

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

Read "polarity" attribute of the DC motor.

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

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

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

Read "ramp_down_sp" attribute of the DC motor.

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

Read "ramp_up_sp" attribute of the DC motor.

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

Read "state" attribute of the DC motor.

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

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

Parameters
snSequence number.
flagsBuffer for the flags.
Returns
Count of read bytes.
size_t get_dc_stop_actions ( uint8_t  sn,
char *  buf,
size_t  sz 
)

Read "stop_actions" attribute of the DC motor.

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

Read "time_sp" attribute of the DC motor.

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

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

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

Write "command" attribute of several DC motors.

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

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

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

Write "duty_cycle_sp" attribute of several DC motors.

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

Write "polarity" attribute of several DC motors.

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

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

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

Write "ramp_down_sp" attribute of several DC motors.

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

Write "ramp_up_sp" attribute of several DC motors.

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

Write "stop_action" attribute of several DC motors.

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

Write "stop_action" attribute of several DC motors by the index.

Parameters
snVector of sequence numbers ending with DESC_LIMIT.
stop_action_inxIndex of the DC motor stop_action.
Returns
Count of written bytes.
size_t multi_set_dc_time_sp ( uint8_t *  sn,
int  value 
)

Write "time_sp" attribute of several DC motors.

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

Write "command" attribute of the DC motor.

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

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

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

Write "duty_cycle_sp" attribute of the DC motor.

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

Write "polarity" attribute of the DC motor.

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

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

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

Write "ramp_down_sp" attribute of the DC motor.

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

Write "ramp_up_sp" attribute of the DC motor.

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

Write "stop_action" attribute of the DC motor.

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

Write "stop_action" attribute of the DC motor by the index.

Parameters
snSequence number.
stop_action_inxIndex of the DC motor stop_action.
Returns
Count of written bytes.
size_t set_dc_time_sp ( uint8_t  sn,
int  value 
)

Write "time_sp" attribute of the DC motor.

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