add ascii q command

This commit is contained in:
Oskar Weigl
2019-01-03 18:15:09 -08:00
parent 6e34beba9f
commit 68372a901e
2 changed files with 16 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ Please add a note of your changes below this heading if you make a Pull Request.
### Added
* `dump_errors()` utility function in odrivetool to dump, decode and optionally clear errors.
* `q` command to ascii protocol. It is like the old `p` command, but velocity and current mean limits, not feed-forward.
# Releases
## [0.4.7] - 2018-11-28

View File

@@ -102,6 +102,21 @@ void ASCII_protocol_process_line(const uint8_t* buffer, size_t len, StreamSink&
axes[motor_number]->controller_.set_pos_setpoint(pos_setpoint, vel_feed_forward, current_feed_forward);
}
} else if (cmd[0] == 'q') { // position control with limits
unsigned motor_number;
float pos_setpoint, vel_limit, current_lim;
int numscan = sscanf(cmd, "q %u %f %f %f", &motor_number, &pos_setpoint, &vel_limit, &current_lim);
if (numscan < 4) {
respond(response_channel, use_checksum, "invalid command format");
} else if (motor_number >= AXIS_COUNT) {
respond(response_channel, use_checksum, "invalid motor %u", motor_number);
} else {
Axis* axis = axes[motor_number];
axis->controller_.pos_setpoint_ = pos_setpoint;
axis->controller_.config_.vel_limit = vel_limit;
axis->motor_.config_.current_lim = current_lim;
}
} else if (cmd[0] == 'v') { // velocity control
unsigned motor_number;
float vel_setpoint, current_feed_forward;