diff --git a/src/odrive_can_node.cpp b/src/odrive_can_node.cpp index 6c54065..b67b2bb 100644 --- a/src/odrive_can_node.cpp +++ b/src/odrive_can_node.cpp @@ -78,7 +78,7 @@ void ODriveCanNode::recv_callback(const can_frame& frame) { switch(frame.can_id & 0x1F) { case CmdId::kHeartbeat: { - if (!verify_length("kHeartbeat", 8, frame.len)) break; + if (!verify_length("kHeartbeat", 8, frame.can_dlc)) break; std::lock_guard guard(ctrl_stat_mutex_); ctrl_stat_.active_errors = read_le(frame.data + 0); ctrl_stat_.axis_state = read_le(frame.data + 4); @@ -89,7 +89,7 @@ void ODriveCanNode::recv_callback(const can_frame& frame) { break; } case CmdId::kGetError: { - if (!verify_length("kGetError", 8, frame.len)) break; + if (!verify_length("kGetError", 8, frame.can_dlc)) break; std::lock_guard guard(odrv_stat_mutex_); odrv_stat_.active_errors = read_le(frame.data + 0); odrv_stat_.disarm_reason = read_le(frame.data + 4); @@ -97,7 +97,7 @@ void ODriveCanNode::recv_callback(const can_frame& frame) { break; } case CmdId::kGetEncoderEstimates: { - if (!verify_length("kGetEncoderEstimates", 8, frame.len)) break; + if (!verify_length("kGetEncoderEstimates", 8, frame.can_dlc)) break; std::lock_guard guard(ctrl_stat_mutex_); ctrl_stat_.pos_estimate = read_le(frame.data + 0); ctrl_stat_.vel_estimate = read_le(frame.data + 4); @@ -105,7 +105,7 @@ void ODriveCanNode::recv_callback(const can_frame& frame) { break; } case CmdId::kGetIq: { - if (!verify_length("kGetIq", 8, frame.len)) break; + if (!verify_length("kGetIq", 8, frame.can_dlc)) break; std::lock_guard guard(ctrl_stat_mutex_); ctrl_stat_.iq_setpoint = read_le(frame.data + 0); ctrl_stat_.iq_measured = read_le(frame.data + 4); @@ -113,7 +113,7 @@ void ODriveCanNode::recv_callback(const can_frame& frame) { break; } case CmdId::kGetTemp: { - if (!verify_length("kGetTemp", 8, frame.len)) break; + if (!verify_length("kGetTemp", 8, frame.can_dlc)) break; std::lock_guard guard(odrv_stat_mutex_); odrv_stat_.fet_temperature = read_le(frame.data + 0); odrv_stat_.motor_temperature = read_le(frame.data + 4); @@ -121,7 +121,7 @@ void ODriveCanNode::recv_callback(const can_frame& frame) { break; } case CmdId::kGetBusVoltageCurrent: { - if (!verify_length("kGetBusVoltageCurrent", 8, frame.len)) break; + if (!verify_length("kGetBusVoltageCurrent", 8, frame.can_dlc)) break; std::lock_guard guard(odrv_stat_mutex_); odrv_stat_.bus_voltage = read_le(frame.data + 0); odrv_stat_.bus_current = read_le(frame.data + 4); @@ -129,7 +129,7 @@ void ODriveCanNode::recv_callback(const can_frame& frame) { break; } case CmdId::kGetTorques: { - if (!verify_length("kGetTorques", 8, frame.len)) break; + if (!verify_length("kGetTorques", 8, frame.can_dlc)) break; std::lock_guard guard(ctrl_stat_mutex_); ctrl_stat_.torque_target = read_le(frame.data + 0); ctrl_stat_.torque_estimate = read_le(frame.data + 4); @@ -187,7 +187,7 @@ void ODriveCanNode::request_state_callback() { std::unique_lock guard(axis_state_mutex_); write_le(axis_state_, frame.data); } - frame.len = 4; + frame.can_dlc = 4; can_intf_.send_can_frame(frame); } @@ -202,7 +202,7 @@ void ODriveCanNode::ctrl_msg_callback() { write_le(ctrl_msg_.input_mode, frame.data + 4); control_mode = ctrl_msg_.control_mode; } - frame.len = 8; + frame.can_dlc = 8; can_intf_.send_can_frame(frame); frame = can_frame{}; @@ -216,7 +216,7 @@ void ODriveCanNode::ctrl_msg_callback() { frame.can_id = node_id_ << 5 | kSetInputTorque; std::lock_guard guard(ctrl_msg_mutex_); write_le(ctrl_msg_.input_torque, frame.data); - frame.len = 4; + frame.can_dlc = 4; break; } case ControlMode::kVelocityControl: { @@ -225,7 +225,7 @@ void ODriveCanNode::ctrl_msg_callback() { std::lock_guard guard(ctrl_msg_mutex_); write_le(ctrl_msg_.input_vel, frame.data); write_le(ctrl_msg_.input_torque, frame.data + 4); - frame.len = 8; + frame.can_dlc = 8; break; } case ControlMode::kPositionControl: { @@ -235,7 +235,7 @@ void ODriveCanNode::ctrl_msg_callback() { write_le(ctrl_msg_.input_pos, frame.data); write_le(((int8_t)((ctrl_msg_.input_vel) * 1000)), frame.data + 4); write_le(((int8_t)((ctrl_msg_.input_torque) * 1000)), frame.data + 6); - frame.len = 8; + frame.can_dlc = 8; break; } default: