MCPcopy Create free account
hub / github.com/Motion-Project/motion / stepper_command

Function stepper_command

src/track.c:180–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178******************************************************************************/
179
180static 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
210static unsigned int stepper_status(struct context *cnt, unsigned int motor)

Callers 3

stepper_statusFunction · 0.85
stepper_centerFunction · 0.85
stepper_moveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected