ev3_tacho.h
Go to the documentation of this file.
1 
2 /* ev3_tacho.h was generated by yup.py (yupp) 1.0c3
3  out of ev3_tacho.yu-h
4  */
11 #ifndef EV3_TACHO_H
12 #define EV3_TACHO_H
13 
14 #ifdef EV3_TACHO_IMPLEMENT
15 #define EV3_TACHO_VAR( decl ) \
16  decl
17 #define EV3_TACHO_VAR_INIT( decl, ... ) \
18  decl = __VA_ARGS__
19 
20 #define EV3_TACHO_INL
21 
22 #else /* EV3_TACHO_IMPLEMENT */
23 #define EV3_TACHO_VAR( decl ) \
24  extern decl
25 #define EV3_TACHO_VAR_INIT( decl, ... ) \
26  extern decl
27 
28 #if __GNUC__ && !__GNUC_STDC_INLINE__
29 #define EV3_TACHO_INL \
30  extern inline
31 #else
32 #define EV3_TACHO_INL \
33  inline
34 #endif
35 
36 #endif /* EV3_TACHO_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 TACHO_DIR "/sys/class/tacho-motor"
59 typedef struct {
60  INX_T type_inx;
61  uint8_t port;
62  uint8_t extport;
64 } EV3_TACHO;
65 
66 #define TACHO_DESC__LIMIT_ DESC_LIMIT
68 #define TACHO__NONE_ TACHO_DESC__LIMIT_
73 EV3_TACHO_VAR( EV3_TACHO ev3_tacho[ TACHO_DESC__LIMIT_ ] );
74 
78 enum {
79  TACHO_TYPE__NONE_ = 0, /* XXX: memset( 0 ) is used */
80 
81  LEGO_EV3_L_MOTOR,
82  LEGO_EV3_M_MOTOR,
83  FI_L12_EV3,
84 
86  TACHO_TYPE__UNKNOWN_ = TACHO_TYPE__COUNT_
87 };
88 
92 enum {
93  TACHO_COMMAND__NONE_ = 0,
94 
95  TACHO_RUN_FOREVER,
96  TACHO_RUN_TO_ABS_POS,
97  TACHO_RUN_TO_REL_POS,
98  TACHO_RUN_TIMED,
99  TACHO_RUN_DIRECT,
100  TACHO_STOP,
101  TACHO_RESET,
102 
104  TACHO_COMMAND__UNKNOWN_ = TACHO_COMMAND__COUNT_
105 };
106 
110 enum {
111  TACHO_POLARITY__NONE_ = 0,
112 
113  TACHO_NORMAL,
114  TACHO_INVERSED,
115 
117  TACHO_POLARITY__UNKNOWN_ = TACHO_POLARITY__COUNT_
118 };
119 
123 enum {
124  TACHO_STOP_ACTION__NONE_ = 0,
125 
126  TACHO_COAST,
127  TACHO_BRAKE,
128  TACHO_HOLD,
129 
131  TACHO_STOP_ACTION__UNKNOWN_ = TACHO_STOP_ACTION__COUNT_
132 };
133 
137 enum {
138  TACHO_STATE__NONE_ = 0,
139 
140  TACHO_RUNNING = 0x1L,
141  TACHO_RAMPING = 0x2L,
142  TACHO_HOLDING = 0x4L,
143  TACHO_OVERLOADED = 0x8L,
144  TACHO_STALLED = 0x10L,
145 
146 };
147 
155 extern size_t get_tacho_address( uint8_t sn, char *buf, size_t sz );
156 
164 extern size_t set_tacho_command( uint8_t sn, char *value );
165 
173 extern size_t multi_set_tacho_command( uint8_t *sn, char *value );
174 
182 extern size_t get_tacho_commands( uint8_t sn, char *buf, size_t sz );
183 
191 extern size_t get_tacho_count_per_rot( uint8_t sn, int *buf );
192 
200 extern size_t get_tacho_count_per_m( uint8_t sn, int *buf );
201 
209 extern size_t get_tacho_full_travel_count( uint8_t sn, int *buf );
210 
218 extern size_t get_tacho_driver_name( uint8_t sn, char *buf, size_t sz );
219 
227 extern size_t get_tacho_duty_cycle( uint8_t sn, int *buf );
228 
236 extern size_t get_tacho_duty_cycle_sp( uint8_t sn, int *buf );
237 
245 extern size_t set_tacho_duty_cycle_sp( uint8_t sn, int value );
246 
254 extern size_t multi_set_tacho_duty_cycle_sp( uint8_t *sn, int value );
255 
263 extern size_t get_tacho_hold_pid_Kd( uint8_t sn, int *buf );
264 
272 extern size_t set_tacho_hold_pid_Kd( uint8_t sn, int value );
273 
281 extern size_t multi_set_tacho_hold_pid_Kd( uint8_t *sn, int value );
282 
290 extern size_t get_tacho_hold_pid_Ki( uint8_t sn, int *buf );
291 
299 extern size_t set_tacho_hold_pid_Ki( uint8_t sn, int value );
300 
308 extern size_t multi_set_tacho_hold_pid_Ki( uint8_t *sn, int value );
309 
317 extern size_t get_tacho_hold_pid_Kp( uint8_t sn, int *buf );
318 
326 extern size_t set_tacho_hold_pid_Kp( uint8_t sn, int value );
327 
335 extern size_t multi_set_tacho_hold_pid_Kp( uint8_t *sn, int value );
336 
344 extern size_t get_tacho_max_speed( uint8_t sn, int *buf );
345 
353 extern size_t get_tacho_polarity( uint8_t sn, char *buf, size_t sz );
354 
362 extern size_t set_tacho_polarity( uint8_t sn, char *value );
363 
371 extern size_t multi_set_tacho_polarity( uint8_t *sn, char *value );
372 
380 extern size_t get_tacho_position( uint8_t sn, int *buf );
381 
389 extern size_t set_tacho_position( uint8_t sn, int value );
390 
398 extern size_t multi_set_tacho_position( uint8_t *sn, int value );
399 
407 extern size_t get_tacho_position_sp( uint8_t sn, int *buf );
408 
416 extern size_t set_tacho_position_sp( uint8_t sn, int value );
417 
425 extern size_t multi_set_tacho_position_sp( uint8_t *sn, int value );
426 
434 extern size_t get_tacho_ramp_down_sp( uint8_t sn, int *buf );
435 
443 extern size_t set_tacho_ramp_down_sp( uint8_t sn, int value );
444 
452 extern size_t multi_set_tacho_ramp_down_sp( uint8_t *sn, int value );
453 
461 extern size_t get_tacho_ramp_up_sp( uint8_t sn, int *buf );
462 
470 extern size_t set_tacho_ramp_up_sp( uint8_t sn, int value );
471 
479 extern size_t multi_set_tacho_ramp_up_sp( uint8_t *sn, int value );
480 
488 extern size_t get_tacho_speed( uint8_t sn, int *buf );
489 
497 extern size_t get_tacho_speed_pid_Kd( uint8_t sn, int *buf );
498 
506 extern size_t set_tacho_speed_pid_Kd( uint8_t sn, int value );
507 
515 extern size_t multi_set_tacho_speed_pid_Kd( uint8_t *sn, int value );
516 
524 extern size_t get_tacho_speed_pid_Ki( uint8_t sn, int *buf );
525 
533 extern size_t set_tacho_speed_pid_Ki( uint8_t sn, int value );
534 
542 extern size_t multi_set_tacho_speed_pid_Ki( uint8_t *sn, int value );
543 
551 extern size_t get_tacho_speed_pid_Kp( uint8_t sn, int *buf );
552 
560 extern size_t set_tacho_speed_pid_Kp( uint8_t sn, int value );
561 
569 extern size_t multi_set_tacho_speed_pid_Kp( uint8_t *sn, int value );
570 
578 extern size_t get_tacho_speed_sp( uint8_t sn, int *buf );
579 
587 extern size_t set_tacho_speed_sp( uint8_t sn, int value );
588 
596 extern size_t multi_set_tacho_speed_sp( uint8_t *sn, int value );
597 
605 extern size_t get_tacho_state( uint8_t sn, char *buf, size_t sz );
606 
614 extern size_t get_tacho_stop_action( uint8_t sn, char *buf, size_t sz );
615 
623 extern size_t set_tacho_stop_action( uint8_t sn, char *value );
624 
632 extern size_t multi_set_tacho_stop_action( uint8_t *sn, char *value );
633 
641 extern size_t get_tacho_stop_actions( uint8_t sn, char *buf, size_t sz );
642 
650 extern size_t get_tacho_time_sp( uint8_t sn, int *buf );
651 
659 extern size_t set_tacho_time_sp( uint8_t sn, int value );
660 
668 extern size_t multi_set_tacho_time_sp( uint8_t *sn, int value );
669 
675 extern const char *ev3_tacho_type( INX_T type_inx );
676 
682 extern INX_T get_tacho_type_inx( uint8_t sn );
683 
690 extern size_t get_tacho_desc( uint8_t sn, EV3_TACHO *desc );
691 
697 extern EV3_TACHO *ev3_tacho_desc( uint8_t sn );
698 
704 extern INX_T ev3_tacho_desc_type_inx( uint8_t sn );
705 
711 extern uint8_t ev3_tacho_desc_port( uint8_t sn );
712 
718 extern uint8_t ev3_tacho_desc_extport( uint8_t sn );
719 
726 extern char *ev3_tacho_port_name( uint8_t sn, char *buf );
727 
735 extern bool ev3_search_tacho( INX_T type_inx, uint8_t *sn, uint8_t from );
736 
745 extern bool ev3_search_tacho_plugged_in( uint8_t port, uint8_t extport, uint8_t *sn, uint8_t from );
746 
752 extern const char *ev3_tacho_command( INX_T command_inx );
753 
760 extern size_t set_tacho_command_inx( uint8_t sn, INX_T command_inx );
761 
768 extern size_t multi_set_tacho_command_inx( uint8_t *sn, INX_T command_inx );
769 
775 extern const char *ev3_tacho_polarity( INX_T polarity_inx );
776 
782 extern INX_T get_tacho_polarity_inx( uint8_t sn );
783 
790 extern size_t set_tacho_polarity_inx( uint8_t sn, INX_T polarity_inx );
791 
798 extern size_t multi_set_tacho_polarity_inx( uint8_t *sn, INX_T polarity_inx );
799 
805 extern const char *ev3_tacho_stop_action( INX_T stop_action_inx );
806 
812 extern INX_T get_tacho_stop_action_inx( uint8_t sn );
813 
820 extern size_t set_tacho_stop_action_inx( uint8_t sn, INX_T stop_action_inx );
821 
828 extern size_t multi_set_tacho_stop_action_inx( uint8_t *sn, INX_T stop_action_inx );
829 
836 extern size_t get_tacho_state_flags( uint8_t sn, FLAGS_T *flags );
837 
842 extern int ev3_tacho_init( void );
843 
844 #ifdef __cplusplus
845 }
846 #endif
847 
850 #undef EV3_TACHO_VAR
851 #undef EV3_TACHO_VAR_INIT
852 #undef EV3_TACHO_INL
853 #endif
854 
size_t multi_set_tacho_polarity(uint8_t *sn, char *value)
Write "polarity" attribute of several tachos.
Definition: ev3_tacho.c:239
size_t multi_set_tacho_hold_pid_Kd(uint8_t *sn, int value)
Write "hold_pid/Kd" attribute of several tachos.
Definition: ev3_tacho.c:162
size_t get_tacho_speed_pid_Kp(uint8_t sn, int *buf)
Read "speed_pid/Kp" attribute of the tacho.
Definition: ev3_tacho.c:392
size_t multi_set_tacho_position(uint8_t *sn, int value)
Write "position" attribute of several tachos.
Definition: ev3_tacho.c:262
size_t set_tacho_speed_sp(uint8_t sn, int value)
Write "speed_sp" attribute of the tacho.
Definition: ev3_tacho.c:423
size_t set_tacho_hold_pid_Kd(uint8_t sn, int value)
Write "hold_pid/Kd" attribute of the tacho.
Definition: ev3_tacho.c:154
size_t get_tacho_speed_pid_Kd(uint8_t sn, int *buf)
Read "speed_pid/Kd" attribute of the tacho.
Definition: ev3_tacho.c:346
size_t set_tacho_ramp_down_sp(uint8_t sn, int value)
Write "ramp_down_sp" attribute of the tacho.
Definition: ev3_tacho.c:300
size_t get_tacho_polarity(uint8_t sn, char *buf, size_t sz)
Read "polarity" attribute of the tacho.
Definition: ev3_tacho.c:223
size_t get_tacho_driver_name(uint8_t sn, char *buf, size_t sz)
Read "driver_name" attribute of the tacho.
Definition: ev3_tacho.c:107
size_t get_tacho_commands(uint8_t sn, char *buf, size_t sz)
Read "commands" attribute of the tacho.
Definition: ev3_tacho.c:75
INX_T get_tacho_stop_action_inx(uint8_t sn)
Read "stop_action" attribute of the tacho and get the index.
Definition: ev3_tacho.c:685
size_t multi_set_tacho_command_inx(uint8_t *sn, INX_T command_inx)
Write "command" attribute of several tachos by the index.
Definition: ev3_tacho.c:632
EV3_TACHO * ev3_tacho_desc(uint8_t sn)
Get descriptor of the tacho.
Definition: ev3_tacho.c:542
size_t get_tacho_max_speed(uint8_t sn, int *buf)
Read "max_speed" attribute of the tacho.
Definition: ev3_tacho.c:215
size_t get_tacho_desc(uint8_t sn, EV3_TACHO *desc)
Read tacho attributes that are required for filling the descriptor.
Definition: ev3_tacho.c:527
size_t set_tacho_polarity_inx(uint8_t sn, INX_T polarity_inx)
Write "polarity" attribute of the tacho by the index.
Definition: ev3_tacho.c:661
size_t get_tacho_duty_cycle_sp(uint8_t sn, int *buf)
Read "duty_cycle_sp" attribute of the tacho.
Definition: ev3_tacho.c:123
size_t get_tacho_state_flags(uint8_t sn, FLAGS_T *flags)
Read "state" attribute of the tacho and get the flags.
Definition: ev3_tacho.c:708
size_t set_tacho_ramp_up_sp(uint8_t sn, int value)
Write "ramp_up_sp" attribute of the tacho.
Definition: ev3_tacho.c:323
size_t multi_set_tacho_speed_pid_Ki(uint8_t *sn, int value)
Write "speed_pid/Ki" attribute of several tachos.
Definition: ev3_tacho.c:385
size_t multi_set_tacho_ramp_down_sp(uint8_t *sn, int value)
Write "ramp_down_sp" attribute of several tachos.
Definition: ev3_tacho.c:308
uint8_t extport
Definition: ev3_tacho.h:62
size_t multi_set_tacho_speed_pid_Kp(uint8_t *sn, int value)
Write "speed_pid/Kp" attribute of several tachos.
Definition: ev3_tacho.c:408
uint8_t ev3_tacho_desc_extport(uint8_t sn)
Get extended port from the tacho descriptor.
Definition: ev3_tacho.c:558
size_t get_tacho_full_travel_count(uint8_t sn, int *buf)
Read "full_travel_count" attribute of the tacho.
Definition: ev3_tacho.c:99
Definition: ev3_tacho.h:130
bool ev3_search_tacho(INX_T type_inx, uint8_t *sn, uint8_t from)
Search of a sequence number of the specified tacho type.
Definition: ev3_tacho.c:568
Definition: ev3_tacho.h:116
size_t set_tacho_time_sp(uint8_t sn, int value)
Write "time_sp" attribute of the tacho.
Definition: ev3_tacho.c:485
size_t get_tacho_speed_sp(uint8_t sn, int *buf)
Read "speed_sp" attribute of the tacho.
Definition: ev3_tacho.c:415
size_t get_tacho_hold_pid_Kd(uint8_t sn, int *buf)
Read "hold_pid/Kd" attribute of the tacho.
Definition: ev3_tacho.c:146
size_t multi_set_tacho_speed_pid_Kd(uint8_t *sn, int value)
Write "speed_pid/Kd" attribute of several tachos.
Definition: ev3_tacho.c:362
size_t set_tacho_position_sp(uint8_t sn, int value)
Write "position_sp" attribute of the tacho.
Definition: ev3_tacho.c:277
size_t set_tacho_command(uint8_t sn, char *value)
Write "command" attribute of the tacho.
Definition: ev3_tacho.c:60
INX_T get_tacho_polarity_inx(uint8_t sn)
Read "polarity" attribute of the tacho and get the index.
Definition: ev3_tacho.c:649
size_t get_tacho_position_sp(uint8_t sn, int *buf)
Read "position_sp" attribute of the tacho.
Definition: ev3_tacho.c:269
size_t set_tacho_speed_pid_Ki(uint8_t sn, int value)
Write "speed_pid/Ki" attribute of the tacho.
Definition: ev3_tacho.c:377
size_t multi_set_tacho_stop_action_inx(uint8_t *sn, INX_T stop_action_inx)
Write "stop_action" attribute of several tachos by the index.
Definition: ev3_tacho.c:703
INX_T type_inx
Definition: ev3_tacho.h:60
size_t set_tacho_hold_pid_Kp(uint8_t sn, int value)
Write "hold_pid/Kp" attribute of the tacho.
Definition: ev3_tacho.c:200
size_t get_tacho_count_per_rot(uint8_t sn, int *buf)
Read "count_per_rot" attribute of the tacho.
Definition: ev3_tacho.c:83
size_t multi_set_tacho_time_sp(uint8_t *sn, int value)
Write "time_sp" attribute of several tachos.
Definition: ev3_tacho.c:493
size_t set_tacho_speed_pid_Kd(uint8_t sn, int value)
Write "speed_pid/Kd" attribute of the tacho.
Definition: ev3_tacho.c:354
size_t multi_set_tacho_hold_pid_Kp(uint8_t *sn, int value)
Write "hold_pid/Kp" attribute of several tachos.
Definition: ev3_tacho.c:208
size_t get_tacho_state(uint8_t sn, char *buf, size_t sz)
Read "state" attribute of the tacho.
Definition: ev3_tacho.c:438
size_t set_tacho_hold_pid_Ki(uint8_t sn, int value)
Write "hold_pid/Ki" attribute of the tacho.
Definition: ev3_tacho.c:177
size_t get_tacho_ramp_down_sp(uint8_t sn, int *buf)
Read "ramp_down_sp" attribute of the tacho.
Definition: ev3_tacho.c:292
Definition: ev3_tacho.h:85
const char * ev3_tacho_polarity(INX_T polarity_inx)
Get name of the specified tacho polarity.
Definition: ev3_tacho.c:637
size_t multi_set_tacho_hold_pid_Ki(uint8_t *sn, int value)
Write "hold_pid/Ki" attribute of several tachos.
Definition: ev3_tacho.c:185
size_t get_tacho_stop_actions(uint8_t sn, char *buf, size_t sz)
Read "stop_actions" attribute of the tacho.
Definition: ev3_tacho.c:469
size_t get_tacho_count_per_m(uint8_t sn, int *buf)
Read "count_per_m" attribute of the tacho.
Definition: ev3_tacho.c:91
size_t get_tacho_speed(uint8_t sn, int *buf)
Read "speed" attribute of the tacho.
Definition: ev3_tacho.c:338
Structure of a tacho descriptor.
Definition: ev3_tacho.h:59
size_t set_tacho_polarity(uint8_t sn, char *value)
Write "polarity" attribute of the tacho.
Definition: ev3_tacho.c:231
size_t set_tacho_stop_action_inx(uint8_t sn, INX_T stop_action_inx)
Write "stop_action" attribute of the tacho by the index.
Definition: ev3_tacho.c:698
uint8_t ev3_tacho_desc_port(uint8_t sn)
Get EV3 port from the tacho descriptor.
Definition: ev3_tacho.c:553
size_t set_tacho_duty_cycle_sp(uint8_t sn, int value)
Write "duty_cycle_sp" attribute of the tacho.
Definition: ev3_tacho.c:131
INX_T ev3_tacho_desc_type_inx(uint8_t sn)
Get type from the tacho descriptor.
Definition: ev3_tacho.c:548
const char * ev3_tacho_type(INX_T type_inx)
Get name of the specified tacho type.
Definition: ev3_tacho.c:500
size_t get_tacho_position(uint8_t sn, int *buf)
Read "position" attribute of the tacho.
Definition: ev3_tacho.c:246
size_t get_tacho_hold_pid_Kp(uint8_t sn, int *buf)
Read "hold_pid/Kp" attribute of the tacho.
Definition: ev3_tacho.c:192
size_t get_tacho_speed_pid_Ki(uint8_t sn, int *buf)
Read "speed_pid/Ki" attribute of the tacho.
Definition: ev3_tacho.c:369
size_t multi_set_tacho_ramp_up_sp(uint8_t *sn, int value)
Write "ramp_up_sp" attribute of several tachos.
Definition: ev3_tacho.c:331
const char * ev3_tacho_command(INX_T command_inx)
Get name of the specified tacho command.
Definition: ev3_tacho.c:605
char * ev3_tacho_port_name(uint8_t sn, char *buf)
Assemble EV3 port name from the tacho descriptor.
Definition: ev3_tacho.c:563
size_t multi_set_tacho_speed_sp(uint8_t *sn, int value)
Write "speed_sp" attribute of several tachos.
Definition: ev3_tacho.c:431
size_t set_tacho_position(uint8_t sn, int value)
Write "position" attribute of the tacho.
Definition: ev3_tacho.c:254
INX_T get_tacho_type_inx(uint8_t sn)
Read "driver_name" attribute and get index of the tacho type.
Definition: ev3_tacho.c:514
const char * ev3_tacho_stop_action(INX_T stop_action_inx)
Get name of the specified tacho stop_action.
Definition: ev3_tacho.c:671
size_t set_tacho_speed_pid_Kp(uint8_t sn, int value)
Write "speed_pid/Kp" attribute of the tacho.
Definition: ev3_tacho.c:400
size_t multi_set_tacho_position_sp(uint8_t *sn, int value)
Write "position_sp" attribute of several tachos.
Definition: ev3_tacho.c:285
size_t get_tacho_hold_pid_Ki(uint8_t sn, int *buf)
Read "hold_pid/Ki" attribute of the tacho.
Definition: ev3_tacho.c:169
size_t get_tacho_time_sp(uint8_t sn, int *buf)
Read "time_sp" attribute of the tacho.
Definition: ev3_tacho.c:477
size_t set_tacho_command_inx(uint8_t sn, INX_T command_inx)
Write "command" attribute of the tacho by the index.
Definition: ev3_tacho.c:627
int ev3_tacho_init(void)
Detect connected tachos.
Definition: ev3_tacho.c:728
size_t multi_set_tacho_duty_cycle_sp(uint8_t *sn, int value)
Write "duty_cycle_sp" attribute of several tachos.
Definition: ev3_tacho.c:139
uint8_t port
Definition: ev3_tacho.h:61
size_t set_tacho_stop_action(uint8_t sn, char *value)
Write "stop_action" attribute of the tacho.
Definition: ev3_tacho.c:454
size_t get_tacho_ramp_up_sp(uint8_t sn, int *buf)
Read "ramp_up_sp" attribute of the tacho.
Definition: ev3_tacho.c:315
Definition: ev3_tacho.h:103
size_t multi_set_tacho_stop_action(uint8_t *sn, char *value)
Write "stop_action" attribute of several tachos.
Definition: ev3_tacho.c:462
size_t get_tacho_duty_cycle(uint8_t sn, int *buf)
Read "duty_cycle" attribute of the tacho.
Definition: ev3_tacho.c:115
bool ev3_search_tacho_plugged_in(uint8_t port, uint8_t extport, uint8_t *sn, uint8_t from)
Search of a sequence number the tacho by plug-in attributes.
Definition: ev3_tacho.c:583
size_t multi_set_tacho_command(uint8_t *sn, char *value)
Write "command" attribute of several tachos.
Definition: ev3_tacho.c:68
size_t get_tacho_stop_action(uint8_t sn, char *buf, size_t sz)
Read "stop_action" attribute of the tacho.
Definition: ev3_tacho.c:446
size_t multi_set_tacho_polarity_inx(uint8_t *sn, INX_T polarity_inx)
Write "polarity" attribute of several tachos by the index.
Definition: ev3_tacho.c:666
size_t get_tacho_address(uint8_t sn, char *buf, size_t sz)
Read "address" attribute of the tacho.
Definition: ev3_tacho.c:52