File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed
lib/pbio/drv/ev3dev_stretch Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -18,15 +18,14 @@ typedef struct _motor_file_t {
1818 pbio_iodev_type_id_t id ;
1919 bool coasting ;
2020 int dir_number ;
21- bool files_open ;
2221 FILE * f_encoder_count ;
2322 FILE * f_encoder_rate ;
2423 FILE * f_duty ;
2524} motor_file_t ;
2625
2726motor_file_t motor_files [] = {
2827 [PORT_TO_IDX (PBDRV_CONFIG_FIRST_MOTOR_PORT ) ... PORT_TO_IDX (PBDRV_CONFIG_LAST_MOTOR_PORT )]{
29- .files_open = false
28+ .dir_number = -1
3029 }
3130};
3231
@@ -49,11 +48,11 @@ pbio_error_t sysfs_motor_command(pbio_port_t port, const char* command) {
4948// Close files if they are open
5049void close_files (pbio_port_t port ){
5150 int port_index = PORT_TO_IDX (port );
52- if (motor_files [port_index ].files_open ) {
51+ if (motor_files [port_index ].dir_number >= 0 ) {
5352 fclose (motor_files [port_index ].f_encoder_count );
5453 fclose (motor_files [port_index ].f_encoder_rate );
5554 fclose (motor_files [port_index ].f_duty );
56- motor_files [port_index ].files_open = false ;
55+ motor_files [port_index ].dir_number = -1 ;
5756 }
5857}
5958
@@ -119,8 +118,6 @@ pbio_error_t sysfs_motor_init(pbio_port_t port){
119118 motor_files [port_index ].f_duty = fopen (filepath , "w" );
120119 // Close tacho-motor directory when done
121120 closedir (dp );
122- // Files are opened
123- motor_files [port_index ].files_open = true;
124121 // Return success
125122 return PBIO_SUCCESS ;
126123 }
You can’t perform that action at this time.
0 commit comments