| 178 | ******************************************************************************/ |
| 179 | |
| 180 | static unsigned int stepper_command(struct context *cnt, unsigned int motor |
| 181 | , unsigned int command, unsigned int data) |
| 182 | { |
| 183 | char buffer[3]; |
| 184 | time_t timeout = time(NULL); |
| 185 | |
| 186 | buffer[0] = motor; |
| 187 | buffer[1] = command; |
| 188 | buffer[2] = data; |
| 189 | |
| 190 | if (write(cnt->track.dev, buffer, 3) != 3) { |
| 191 | MOTION_LOG(NTC, TYPE_TRACK, SHOW_ERRNO |
| 192 | ,_("port %s dev fd %i, motor %hu command %hu data %hu") |
| 193 | ,cnt->track.port, cnt->track.dev, motor, command, data); |
| 194 | return 0; |
| 195 | } |
| 196 | |
| 197 | while (read(cnt->track.dev, buffer, 1) != 1 && time(NULL) < timeout + 1) { |
| 198 | continue; |
| 199 | } |
| 200 | |
| 201 | if (time(NULL) >= timeout + 2) { |
| 202 | MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO,_("Status byte timeout!")); |
| 203 | return 0; |
| 204 | } |
| 205 | |
| 206 | return buffer[0]; |
| 207 | } |
| 208 | |
| 209 | |
| 210 | static unsigned int stepper_status(struct context *cnt, unsigned int motor) |
no outgoing calls
no test coverage detected