Skip to content

Commit

Permalink
updated message naming
Browse files Browse the repository at this point in the history
  • Loading branch information
pmoegenburg committed Dec 18, 2023
1 parent c7af96e commit 19ace41
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 30 deletions.
3 changes: 2 additions & 1 deletion gripper/simulator/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ static brushed_motor_handler::BrushedMotorInterruptHandler
static brushed_motor_interrupt_driver::BrushedMotorInterruptDriver G(
brushed_motor_queue, brushed_motor_interrupt, brushed_motor_hardware_iface);

void z_motor_iface::initialize() {
void z_motor_iface::initialize(diag0_handler *call_diag0_handler) {
static_cast<void>(call_diag0_handler);
motor_interface.provide_mech_config(z_motor_sys_config);
};

Expand Down
6 changes: 4 additions & 2 deletions gripper/simulator/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

namespace po = boost::program_options;

static z_motor_iface::diag0_handler call_diag0_handler = nullptr;

void signal_handler(int signum) {
LOG("Interrupt signal (%d) received.", signum);
exit(signum);
Expand Down Expand Up @@ -111,9 +113,9 @@ int main(int argc, char** argv) {
auto i2c3 = std::make_shared<i2c::hardware::SimI2C>(i2c_device_map);
static auto canbus =
can::sim::bus::SimCANBus(can::sim::transport::create(options));
z_motor_iface::initialize();
z_motor_iface::initialize(&call_diag0_handler);
grip_motor_iface::initialize();
gripper_tasks::start_tasks(
call_diag0_handler = gripper_tasks::start_tasks(
canbus, z_motor_iface::get_z_motor(),
grip_motor_iface::get_grip_motor(), z_motor_iface::get_spi(),
z_motor_iface::get_tmc2130_driver_configs(), i2c2, *i2c3,
Expand Down
2 changes: 1 addition & 1 deletion head/core/can_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using MotorDispatchTarget = can::dispatch::DispatchParseTarget<
can::messages::ReadMotorDriverRegister,
can::messages::WriteMotorDriverRegister,
can::messages::WriteMotorCurrentRequest,
can::messages::ReadMotorDriverErrorStatus>;
can::messages::ReadMotorDriverErrorStatusRequest>;
using MoveGroupDispatchTarget = can::dispatch::DispatchParseTarget<
can::message_handlers::move_group::MoveGroupHandler<
head_tasks::MotorQueueClient>,
Expand Down
4 changes: 2 additions & 2 deletions include/can/core/ids.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ enum class MessageId {
write_motor_current_request = 0x33,
read_motor_current_request = 0x34,
read_motor_current_response = 0x35,
read_motor_driver_error_status = 0x36,
read_motor_driver_error_register_response = 0x37,
read_motor_driver_error_status_request = 0x36,
read_motor_driver_error_status_response = 0x37,
motor_driver_in_error_state = 0x38,
set_brushed_motor_vref_request = 0x40,
set_brushed_motor_pwm_request = 0x41,
Expand Down
18 changes: 9 additions & 9 deletions include/can/core/messages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,24 +618,24 @@ struct ReadMotorDriverRegisterResponse
-> bool = default;
};

struct ReadMotorDriverErrorStatus
: BaseMessage<MessageId::read_motor_driver_error_status> {
struct ReadMotorDriverErrorStatusRequest
: BaseMessage<MessageId::read_motor_driver_error_status_request> {
uint32_t message_index;

template <bit_utils::ByteIterator Input, typename Limit>
static auto parse(Input body, Limit limit) -> ReadMotorDriverErrorStatus {
static auto parse(Input body, Limit limit) -> ReadMotorDriverErrorStatusRequest {
uint32_t msg_ind = 0;

body = bit_utils::bytes_to_int(body, limit, msg_ind);
return ReadMotorDriverErrorStatus{.message_index = msg_ind};
return ReadMotorDriverErrorStatusRequest{.message_index = msg_ind};
}

auto operator==(const ReadMotorDriverErrorStatus& other) const
auto operator==(const ReadMotorDriverErrorStatusRequest& other) const
-> bool = default;
};

struct ReadMotorDriverErrorRegisterResponse
: BaseMessage<MessageId::read_motor_driver_error_register_response> {
struct ReadMotorDriverErrorStatusResponse
: BaseMessage<MessageId::read_motor_driver_error_status_response> {
uint32_t message_index;
uint8_t reg_address;
uint32_t data;
Expand All @@ -648,7 +648,7 @@ struct ReadMotorDriverErrorRegisterResponse
return iter - body;
}

auto operator==(const ReadMotorDriverErrorRegisterResponse& other) const
auto operator==(const ReadMotorDriverErrorStatusResponse& other) const
-> bool = default;
};

Expand Down Expand Up @@ -1573,7 +1573,7 @@ using ResponseMessageType = std::variant<
PeripheralStatusResponse, BrushedMotorConfResponse,
UpdateMotorPositionEstimationResponse, BaselineSensorResponse,
PushTipPresenceNotification, GetMotorUsageResponse,
ReadMotorDriverErrorRegisterResponse, GripperJawStateResponse,
ReadMotorDriverErrorStatusResponse, GripperJawStateResponse,
MotorDriverInErrorState>;

} // namespace can::messages
2 changes: 1 addition & 1 deletion include/gantry/core/can_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ using MotorDispatchTarget = can::dispatch::DispatchParseTarget<
can::messages::ReadMotorDriverRegister,
can::messages::WriteMotorDriverRegister,
can::messages::WriteMotorCurrentRequest,
can::messages::ReadMotorDriverErrorStatus>;
can::messages::ReadMotorDriverErrorStatusRequest>;
using MoveGroupDispatchTarget = can::dispatch::DispatchParseTarget<
can::message_handlers::move_group::MoveGroupHandler<
gantry::queues::QueueClient>,
Expand Down
2 changes: 1 addition & 1 deletion include/gripper/core/can_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ using MotorDispatchTarget = can::dispatch::DispatchParseTarget<
can::messages::ReadMotorDriverRegister,
can::messages::WriteMotorDriverRegister,
can::messages::WriteMotorCurrentRequest,
can::messages::ReadMotorDriverErrorStatus>;
can::messages::ReadMotorDriverErrorStatusRequest>;
using MoveGroupDispatchTarget = can::dispatch::DispatchParseTarget<
can::message_handlers::move_group::MoveGroupHandler<z_tasks::QueueClient>,
can::messages::AddLinearMoveRequest,
Expand Down
2 changes: 2 additions & 0 deletions include/gripper/simulation/sim_interfaces.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace z_motor_iface {

extern "C" using diag0_handler = void(*)();

auto get_z_motor_interface()
-> sim_motor_hardware_iface::SimMotorHardwareIface&;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ class MotorInterruptHandler {
.error_code = err_code});
if (err_code == can::ids::ErrorCode::motor_driver_error_detected) {
driver_client.send_motor_driver_queue(
can::messages::ReadMotorDriverErrorStatus{.message_index =
can::messages::ReadMotorDriverErrorStatusRequest{.message_index =
message_index});
}
if (err_code == can::ids::ErrorCode::collision_detected) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class MotorDriverMessageHandler {
}
}

void handle(const can::messages::ReadMotorDriverErrorStatus& m) {
void handle(const can::messages::ReadMotorDriverErrorStatusRequest& m) {
LOG("Received read motor driver error register request");
uint32_t data = 0;
std::array tags{spi::utils::ResponseTag::IS_ERROR_RESPONSE};
Expand Down
2 changes: 1 addition & 1 deletion include/motor-control/core/tasks/messages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ using MotorDriverTaskMessage =
std::variant<std::monostate, can::messages::ReadMotorDriverRegister,
can::messages::WriteMotorDriverRegister,
can::messages::WriteMotorCurrentRequest,
can::messages::ReadMotorDriverErrorStatus>;
can::messages::ReadMotorDriverErrorStatusRequest>;

using MoveGroupTaskMessage =
std::variant<std::monostate, can::messages::AddLinearMoveRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class MotionControllerMessageHandler {
.error_code =
can::ids::ErrorCode::motor_driver_error_detected});
driver_client.send_motor_driver_queue(
can::messages::ReadMotorDriverErrorStatus{
can::messages::ReadMotorDriverErrorStatusRequest{
.message_index = m.message_index});
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class MotorDriverMessageHandler {
m.rxBuffer);
if (spi::utils::tag_in_token(
m.id.token, spi::utils::ResponseTag::IS_ERROR_RESPONSE)) {
can::messages::ReadMotorDriverErrorRegisterResponse
can::messages::ReadMotorDriverErrorStatusResponse
response_msg{
.message_index = m.id.message_index,
.reg_address = static_cast<uint8_t>(m.id.token),
Expand Down Expand Up @@ -99,7 +99,7 @@ class MotorDriverMessageHandler {
}
}

void handle(const can::messages::ReadMotorDriverErrorStatus& m) {
void handle(const can::messages::ReadMotorDriverErrorStatusRequest& m) {
LOG("Received read motor driver error register request");
uint32_t data = 0;
std::array tags{spi::utils::ResponseTag::IS_ERROR_RESPONSE};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class MotorDriverMessageHandler {
m.rxBuffer);
if (spi::utils::tag_in_token(
m.id.token, spi::utils::ResponseTag::IS_ERROR_RESPONSE)) {
can::messages::ReadMotorDriverErrorRegisterResponse
can::messages::ReadMotorDriverErrorStatusResponse
response_msg{
.message_index = m.id.message_index,
.reg_address = static_cast<uint8_t>(m.id.token),
Expand Down Expand Up @@ -99,7 +99,7 @@ class MotorDriverMessageHandler {
}
}

void handle(const can::messages::ReadMotorDriverErrorStatus& m) {
void handle(const can::messages::ReadMotorDriverErrorStatusRequest& m) {
LOG("Received read motor driver error register request");
uint32_t data = 0;
std::array tags{spi::utils::ResponseTag::IS_ERROR_RESPONSE};
Expand Down
4 changes: 2 additions & 2 deletions include/motor-control/core/tasks/tmc_motor_driver_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ using SpiResponseMessage = std::tuple<spi::messages::TransactResponse>;
using CanMessageTuple = std::tuple<can::messages::ReadMotorDriverRegister,
can::messages::WriteMotorDriverRegister,
can::messages::WriteMotorCurrentRequest,
can::messages::ReadMotorDriverErrorStatus>;
can::messages::ReadMotorDriverErrorStatusRequest>;
using GearCanMessageTuple =
std::tuple<can::messages::GearReadMotorDriverRegister,
can::messages::ReadMotorDriverErrorStatus,
can::messages::ReadMotorDriverErrorStatusRequest,
can::messages::GearWriteMotorDriverRegister,
can::messages::GearWriteMotorCurrentRequest>;
using CanMessage =
Expand Down
6 changes: 3 additions & 3 deletions include/pipettes/core/dispatch_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ using TMC2130MotorDispatchTarget = can::dispatch::DispatchParseTarget<
can::messages::ReadMotorDriverRegister,
can::messages::WriteMotorDriverRegister,
can::messages::WriteMotorCurrentRequest,
can::messages::ReadMotorDriverErrorStatus>;
can::messages::ReadMotorDriverErrorStatusRequest>;

using TMC2160MotorDispatchTarget = can::dispatch::DispatchParseTarget<
can::message_handlers::motor::MotorHandler<
linear_motor_tasks::tmc2160_driver::QueueClient>,
can::messages::ReadMotorDriverRegister,
can::messages::WriteMotorDriverRegister,
can::messages::WriteMotorCurrentRequest,
can::messages::ReadMotorDriverErrorStatus>;
can::messages::ReadMotorDriverErrorStatusRequest>;

using GearMotorDispatchTarget = can::dispatch::DispatchParseTarget<
can::message_handlers::motor::GearMotorHandler<
gear_motor_tasks::QueueClient>,
can::messages::GearReadMotorDriverRegister,
can::messages::ReadMotorDriverErrorStatus,
can::messages::ReadMotorDriverErrorStatusRequest,
can::messages::GearWriteMotorDriverRegister,
can::messages::GearWriteMotorCurrentRequest>;

Expand Down

0 comments on commit 19ace41

Please sign in to comment.