@@ -34,30 +34,30 @@ int limsw_max( axis_e axis)
34
34
{
35
35
int active_state = !config_max_limit_switch_is_active_low ( axis );
36
36
switch (axis ) {
37
- case x_axis : return (x_max_state == active_state );
38
- case y_axis : return (y_max_state == active_state );
39
- case z_axis : return (z_max_state == active_state );
40
- default : return 0 ;
37
+ case x_axis : return (x_max_state == active_state );
38
+ case y_axis : return (y_max_state == active_state );
39
+ case z_axis : return (z_max_state == active_state );
40
+ default : return 0 ;
41
41
}
42
42
}
43
43
44
44
int limsw_min ( axis_e axis )
45
45
{
46
46
int active_state = !config_min_limit_switch_is_active_low ( axis );
47
47
switch (axis ) {
48
- case x_axis : return (x_min_state == active_state );
49
- case y_axis : return (y_min_state == active_state );
50
- case z_axis : return (z_min_state == active_state );
51
- default : return 0 ;
48
+ case x_axis : return (x_min_state == active_state );
49
+ case y_axis : return (y_min_state == active_state );
50
+ case z_axis : return (z_min_state == active_state );
51
+ default : return 0 ;
52
52
}
53
53
}
54
54
55
55
typedef struct {
56
- int gpio_pin_nr ;
57
- int active_low ;
58
- int in_use ;
59
- void (* alarm_call_back )( int state );
60
- int fd ;
56
+ int gpio_pin_nr ;
57
+ int active_low ;
58
+ int in_use ;
59
+ void (* alarm_call_back )( int state );
60
+ int fd ;
61
61
} limit_switch_struct ;
62
62
63
63
/****************************************************************
@@ -112,7 +112,7 @@ static void* limsw_watcher( void* arg)
112
112
}
113
113
114
114
while (1 ) {
115
- const int timeout = -1 ; /* no timeout */
115
+ const int timeout = -1 ; /* no timeout */
116
116
117
117
int rc = poll ( * fdset , nr_limits , timeout );
118
118
if (rc < 0 ) {
@@ -129,26 +129,26 @@ static void* limsw_watcher( void* arg)
129
129
}
130
130
for (i = 0 ; i < nr_limits ; ++ i ) {
131
131
if ((* fdset )[ i ].revents & POLLPRI ) {
132
- int state ;
133
- len = read ( (* fdset )[ i ].fd , buf , sizeof ( buf ));
134
- if (len == 2 && (buf [ 0 ] == '0' || buf [ 0 ] == '1' )) {
135
- // Get initial state info
136
- state = buf [ 0 ] - '0' ;
132
+ int state = 0 ;
133
+ len = read ( (* fdset )[ i ].fd , buf , sizeof ( buf ));
134
+ if (len == 2 && (buf [ 0 ] == '0' || buf [ 0 ] == '1' )) {
135
+ // Get initial state info
136
+ state = buf [ 0 ] - '0' ;
137
137
if (debug_flags & DEBUG_LIMSW ) {
138
138
printf ( "*** GPIO %2d event, state %d ***\n" , gpio [ i ], state );
139
139
}
140
- } else {
141
- fprintf ( stderr , "\n*** GPIO %2d unexpected event, BUG??? ***\n" , gpio [ i ]);
142
- }
143
- switch (gpio [ i ]) {
144
- case XMIN_GPIO : x_min_state = state ; break ;
145
- case XMAX_GPIO : x_max_state = state ; break ;
146
- case YMIN_GPIO : y_min_state = state ; break ;
147
- case YMAX_GPIO : y_max_state = state ; break ;
148
- case ZMIN_GPIO : z_min_state = state ; break ;
149
- case ZMAX_GPIO : z_max_state = state ; break ;
150
- }
151
- lseek ( (* fdset )[ i ].fd , 0 , SEEK_SET );
140
+ } else {
141
+ fprintf ( stderr , "\n*** GPIO %2d unexpected event, BUG??? ***\n" , gpio [ i ]);
142
+ }
143
+ switch (gpio [ i ]) {
144
+ case XMIN_GPIO : x_min_state = state ; break ;
145
+ case XMAX_GPIO : x_max_state = state ; break ;
146
+ case YMIN_GPIO : y_min_state = state ; break ;
147
+ case YMAX_GPIO : y_max_state = state ; break ;
148
+ case ZMIN_GPIO : z_min_state = state ; break ;
149
+ case ZMAX_GPIO : z_max_state = state ; break ;
150
+ }
151
+ lseek ( (* fdset )[ i ].fd , 0 , SEEK_SET );
152
152
}
153
153
}
154
154
}
0 commit comments