ev3_dc.h
Go to the documentation of this file.
1 
2 /* ev3_dc.h was generated by yup.py (yupp) 1.0c3
3  out of ev3_dc.yu-h
4  */
11 #ifndef EV3_DC_H
12 #define EV3_DC_H
13 
14 #ifdef EV3_DC_IMPLEMENT
15 #define EV3_DC_VAR( decl ) \
16  decl
17 #define EV3_DC_VAR_INIT( decl, ... ) \
18  decl = __VA_ARGS__
19 
20 #define EV3_DC_INL
21 
22 #else /* EV3_DC_IMPLEMENT */
23 #define EV3_DC_VAR( decl ) \
24  extern decl
25 #define EV3_DC_VAR_INIT( decl, ... ) \
26  extern decl
27 
28 #if __GNUC__ && !__GNUC_STDC_INLINE__
29 #define EV3_DC_INL \
30  extern inline
31 #else
32 #define EV3_DC_INL \
33  inline
34 #endif
35 
36 #endif /* EV3_DC_IMPLEMENT */
37 
38 #include <stddef.h>
39 #include <stdint.h>
40 #include <stdbool.h>
41 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 #define DC_DIR "/sys/class/dc-motor"
59 typedef struct {
60  INX_T type_inx;
61  uint8_t port;
62  uint8_t extport;
64 } EV3_DC;
65 
66 #define DC_DESC__LIMIT_ DESC_LIMIT
68 #define DC__NONE_ DC_DESC__LIMIT_
73 EV3_DC_VAR( EV3_DC ev3_dc[ DC_DESC__LIMIT_ ] );
74 
78 enum {
79  DC_TYPE__NONE_ = 0, /* XXX: memset( 0 ) is used */
80 
81  RCX_MOTOR,
82 
84  DC_TYPE__UNKNOWN_ = DC_TYPE__COUNT_
85 };
86 
90 enum {
91  DC_COMMAND__NONE_ = 0,
92 
93  DC_RUN_FOREVER,
94  DC_RUN_TIMED,
95  DC_RUN_DIRECT,
96  DC_STOP,
97 
99  DC_COMMAND__UNKNOWN_ = DC_COMMAND__COUNT_
100 };
101 
105 enum {
106  DC_POLARITY__NONE_ = 0,
107 
108  DC_NORMAL,
109  DC_INVERSED,
110 
112  DC_POLARITY__UNKNOWN_ = DC_POLARITY__COUNT_
113 };
114 
118 enum {
119  DC_STOP_ACTION__NONE_ = 0,
120 
121  DC_COAST,
122  DC_BRAKE,
123 
125  DC_STOP_ACTION__UNKNOWN_ = DC_STOP_ACTION__COUNT_
126 };
127 
131 enum {
132  DC_STATE__NONE_ = 0,
133 
134  DC_RUNNING = 0x1L,
135  DC_RAMPING = 0x2L,
136 
137 };
138 
146 extern size_t get_dc_address( uint8_t sn, char *buf, size_t sz );
147 
155 extern size_t set_dc_command( uint8_t sn, char *value );
156 
164 extern size_t multi_set_dc_command( uint8_t *sn, char *value );
165 
173 extern size_t get_dc_commands( uint8_t sn, char *buf, size_t sz );
174 
182 extern size_t get_dc_driver_name( uint8_t sn, char *buf, size_t sz );
183 
191 extern size_t get_dc_duty_cycle( uint8_t sn, int *buf );
192 
200 extern size_t get_dc_duty_cycle_sp( uint8_t sn, int *buf );
201 
209 extern size_t set_dc_duty_cycle_sp( uint8_t sn, int value );
210 
218 extern size_t multi_set_dc_duty_cycle_sp( uint8_t *sn, int value );
219 
227 extern size_t get_dc_polarity( uint8_t sn, char *buf, size_t sz );
228 
236 extern size_t set_dc_polarity( uint8_t sn, char *value );
237 
245 extern size_t multi_set_dc_polarity( uint8_t *sn, char *value );
246 
254 extern size_t get_dc_state( uint8_t sn, char *buf, size_t sz );
255 
263 extern size_t set_dc_stop_action( uint8_t sn, char *value );
264 
272 extern size_t multi_set_dc_stop_action( uint8_t *sn, char *value );
273 
281 extern size_t get_dc_stop_actions( uint8_t sn, char *buf, size_t sz );
282 
290 extern size_t get_dc_ramp_down_sp( uint8_t sn, int *buf );
291 
299 extern size_t set_dc_ramp_down_sp( uint8_t sn, int value );
300 
308 extern size_t multi_set_dc_ramp_down_sp( uint8_t *sn, int value );
309 
317 extern size_t get_dc_ramp_up_sp( uint8_t sn, int *buf );
318 
326 extern size_t set_dc_ramp_up_sp( uint8_t sn, int value );
327 
335 extern size_t multi_set_dc_ramp_up_sp( uint8_t *sn, int value );
336 
344 extern size_t get_dc_time_sp( uint8_t sn, int *buf );
345 
353 extern size_t set_dc_time_sp( uint8_t sn, int value );
354 
362 extern size_t multi_set_dc_time_sp( uint8_t *sn, int value );
363 
369 extern const char *ev3_dc_type( INX_T type_inx );
370 
376 extern INX_T get_dc_type_inx( uint8_t sn );
377 
384 extern size_t get_dc_desc( uint8_t sn, EV3_DC *desc );
385 
391 extern EV3_DC *ev3_dc_desc( uint8_t sn );
392 
398 extern INX_T ev3_dc_desc_type_inx( uint8_t sn );
399 
405 extern uint8_t ev3_dc_desc_port( uint8_t sn );
406 
412 extern uint8_t ev3_dc_desc_extport( uint8_t sn );
413 
420 extern char *ev3_dc_port_name( uint8_t sn, char *buf );
421 
429 extern bool ev3_search_dc( INX_T type_inx, uint8_t *sn, uint8_t from );
430 
439 extern bool ev3_search_dc_plugged_in( uint8_t port, uint8_t extport, uint8_t *sn, uint8_t from );
440 
446 extern const char *ev3_dc_command( INX_T command_inx );
447 
454 extern size_t set_dc_command_inx( uint8_t sn, INX_T command_inx );
455 
462 extern size_t multi_set_dc_command_inx( uint8_t *sn, INX_T command_inx );
463 
469 extern const char *ev3_dc_polarity( INX_T polarity_inx );
470 
476 extern INX_T get_dc_polarity_inx( uint8_t sn );
477 
484 extern size_t set_dc_polarity_inx( uint8_t sn, INX_T polarity_inx );
485 
492 extern size_t multi_set_dc_polarity_inx( uint8_t *sn, INX_T polarity_inx );
493 
499 extern const char *ev3_dc_stop_action( INX_T stop_action_inx );
500 
507 extern size_t set_dc_stop_action_inx( uint8_t sn, INX_T stop_action_inx );
508 
515 extern size_t multi_set_dc_stop_action_inx( uint8_t *sn, INX_T stop_action_inx );
516 
523 extern size_t get_dc_state_flags( uint8_t sn, FLAGS_T *flags );
524 
529 extern int ev3_dc_init( void );
530 
531 #ifdef __cplusplus
532 }
533 #endif
534 
537 #undef EV3_DC_VAR
538 #undef EV3_DC_VAR_INIT
539 #undef EV3_DC_INL
540 #endif
541 
size_t get_dc_polarity(uint8_t sn, char *buf, size_t sz)
Read "polarity" attribute of the DC motor.
Definition: ev3_dc.c:108
size_t multi_set_dc_duty_cycle_sp(uint8_t *sn, int value)
Write "duty_cycle_sp" attribute of several DC motors.
Definition: ev3_dc.c:101
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.
Definition: ev3_dc.c:308
INX_T ev3_dc_desc_type_inx(uint8_t sn)
Get type from the DC motor descriptor.
Definition: ev3_dc.c:273
size_t set_dc_time_sp(uint8_t sn, int value)
Write "time_sp" attribute of the DC motor.
Definition: ev3_dc.c:216
size_t set_dc_stop_action(uint8_t sn, char *value)
Write "stop_action" attribute of the DC motor.
Definition: ev3_dc.c:139
int ev3_dc_init(void)
Detect connected DC motors.
Definition: ev3_dc.c:429
size_t multi_set_dc_polarity_inx(uint8_t *sn, INX_T polarity_inx)
Write "polarity" attribute of several DC motors by the index.
Definition: ev3_dc.c:385
const char * ev3_dc_stop_action(INX_T stop_action_inx)
Get name of the specified DC motor stop_action.
Definition: ev3_dc.c:390
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.
Definition: ev3_dc.c:402
size_t set_dc_command_inx(uint8_t sn, INX_T command_inx)
Write "command" attribute of the DC motor by the index.
Definition: ev3_dc.c:346
size_t set_dc_command(uint8_t sn, char *value)
Write "command" attribute of the DC motor.
Definition: ev3_dc.c:46
size_t get_dc_state(uint8_t sn, char *buf, size_t sz)
Read "state" attribute of the DC motor.
Definition: ev3_dc.c:131
size_t set_dc_polarity_inx(uint8_t sn, INX_T polarity_inx)
Write "polarity" attribute of the DC motor by the index.
Definition: ev3_dc.c:380
size_t multi_set_dc_command_inx(uint8_t *sn, INX_T command_inx)
Write "command" attribute of several DC motors by the index.
Definition: ev3_dc.c:351
size_t multi_set_dc_polarity(uint8_t *sn, char *value)
Write "polarity" attribute of several DC motors.
Definition: ev3_dc.c:124
EV3_DC * ev3_dc_desc(uint8_t sn)
Get descriptor of the DC motor.
Definition: ev3_dc.c:267
const char * ev3_dc_polarity(INX_T polarity_inx)
Get name of the specified DC motor polarity.
Definition: ev3_dc.c:356
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.
Definition: ev3_dc.c:293
size_t get_dc_duty_cycle(uint8_t sn, int *buf)
Read "duty_cycle" attribute of the DC motor.
Definition: ev3_dc.c:77
INX_T type_inx
Definition: ev3_dc.h:60
INX_T get_dc_type_inx(uint8_t sn)
Read "driver_name" attribute and get index of the DC motor type.
Definition: ev3_dc.c:241
size_t set_dc_ramp_up_sp(uint8_t sn, int value)
Write "ramp_up_sp" attribute of the DC motor.
Definition: ev3_dc.c:193
size_t get_dc_time_sp(uint8_t sn, int *buf)
Read "time_sp" attribute of the DC motor.
Definition: ev3_dc.c:208
size_t multi_set_dc_time_sp(uint8_t *sn, int value)
Write "time_sp" attribute of several DC motors.
Definition: ev3_dc.c:224
size_t set_dc_duty_cycle_sp(uint8_t sn, int value)
Write "duty_cycle_sp" attribute of the DC motor.
Definition: ev3_dc.c:93
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.
Definition: ev3_dc.c:407
size_t get_dc_ramp_up_sp(uint8_t sn, int *buf)
Read "ramp_up_sp" attribute of the DC motor.
Definition: ev3_dc.c:185
size_t multi_set_dc_ramp_down_sp(uint8_t *sn, int value)
Write "ramp_down_sp" attribute of several DC motors.
Definition: ev3_dc.c:178
Definition: ev3_dc.h:111
uint8_t ev3_dc_desc_port(uint8_t sn)
Get EV3 port from the DC motor descriptor.
Definition: ev3_dc.c:278
Definition: ev3_dc.h:124
size_t set_dc_ramp_down_sp(uint8_t sn, int value)
Write "ramp_down_sp" attribute of the DC motor.
Definition: ev3_dc.c:170
size_t get_dc_driver_name(uint8_t sn, char *buf, size_t sz)
Read "driver_name" attribute of the DC motor.
Definition: ev3_dc.c:69
size_t get_dc_state_flags(uint8_t sn, FLAGS_T *flags)
Read "state" attribute of the DC motor and get the flags.
Definition: ev3_dc.c:412
size_t get_dc_ramp_down_sp(uint8_t sn, int *buf)
Read "ramp_down_sp" attribute of the DC motor.
Definition: ev3_dc.c:162
size_t multi_set_dc_command(uint8_t *sn, char *value)
Write "command" attribute of several DC motors.
Definition: ev3_dc.c:54
Definition: ev3_dc.h:98
size_t multi_set_dc_ramp_up_sp(uint8_t *sn, int value)
Write "ramp_up_sp" attribute of several DC motors.
Definition: ev3_dc.c:201
size_t get_dc_stop_actions(uint8_t sn, char *buf, size_t sz)
Read "stop_actions" attribute of the DC motor.
Definition: ev3_dc.c:154
const char * ev3_dc_command(INX_T command_inx)
Get name of the specified DC motor command.
Definition: ev3_dc.c:330
uint8_t extport
Definition: ev3_dc.h:62
Definition: ev3_dc.h:83
size_t get_dc_desc(uint8_t sn, EV3_DC *desc)
Read DC motor attributes that are required for filling the descriptor.
Definition: ev3_dc.c:252
size_t set_dc_polarity(uint8_t sn, char *value)
Write "polarity" attribute of the DC motor.
Definition: ev3_dc.c:116
size_t get_dc_address(uint8_t sn, char *buf, size_t sz)
Read "address" attribute of the DC motor.
Definition: ev3_dc.c:38
uint8_t port
Definition: ev3_dc.h:61
uint8_t ev3_dc_desc_extport(uint8_t sn)
Get extended port from the DC motor descriptor.
Definition: ev3_dc.c:283
char * ev3_dc_port_name(uint8_t sn, char *buf)
Assemble EV3 port name from the DC motor descriptor.
Definition: ev3_dc.c:288
size_t get_dc_duty_cycle_sp(uint8_t sn, int *buf)
Read "duty_cycle_sp" attribute of the DC motor.
Definition: ev3_dc.c:85
INX_T get_dc_polarity_inx(uint8_t sn)
Read "polarity" attribute of the DC motor and get the index.
Definition: ev3_dc.c:368
size_t multi_set_dc_stop_action(uint8_t *sn, char *value)
Write "stop_action" attribute of several DC motors.
Definition: ev3_dc.c:147
size_t get_dc_commands(uint8_t sn, char *buf, size_t sz)
Read "commands" attribute of the DC motor.
Definition: ev3_dc.c:61
Structure of a DC motor descriptor.
Definition: ev3_dc.h:59
const char * ev3_dc_type(INX_T type_inx)
Get name of the specified DC motor type.
Definition: ev3_dc.c:231