From cd259b50336c5ef096c3f5e294dc3e293fc7e199 Mon Sep 17 00:00:00 2001 From: Ben Hall Date: Sun, 20 Oct 2024 15:19:03 -0400 Subject: [PATCH] fixing removal of eth interface comms --- src/main.cpp | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 99ac145e..4e7090c6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -344,7 +344,7 @@ void tick_all_systems(const SysTick_s ¤t_system_tick); /* Reset inverters */ void drivetrain_reset(); -// void handle_ethernet_interface_comms(const SysTick_s &systick, const hytech_msgs_MCUOutputData &out_msg); +void handle_ethernet_interface_comms(const SysTick_s &systick, const hytech_msgs_MCUOutputData &out_msg); /* SETUP @@ -439,6 +439,10 @@ void loop() db_eth_interface.get_latest_data(), torque_controller_mux.get_tc_mux_status()); + hytech_msgs_MCUOutputData out_eth_msg = db_eth_interface.make_db_msg(car_state_inst); + + handle_ethernet_interface_comms(curr_tick, out_eth_msg); + tick_all_systems(curr_tick); // logger.log_out(static_cast(torque_controller_mux.get_tc_mux_status().current_controller_mode_), curr_tick.millis, 100); @@ -652,19 +656,19 @@ void tick_all_systems(const SysTick_s ¤t_system_tick) vn_interface.get_vn_struct().vn_status); } -// void handle_ethernet_interface_comms(const SysTick_s &systick, const hytech_msgs_MCUOutputData &out_msg) -// { -// // function that will handle receiving and distributing of all messages to all ethernet interfaces -// // via the union message. this is a little bit cursed ngl. -// // TODO un fuck this and make it more sane -// // Serial.println("bruh"); -// // handle_ethernet_socket_receive(&protobuf_recv_socket, &recv_pb_stream_union_msg, ethernet_interfaces); - -// std::function recv_boi = &recv_pb_stream_msg; -// handle_ethernet_socket_receive<1024, hytech_msgs_MCUCommandData>(systick, &protobuf_recv_socket, recv_boi, db_eth_interface, hytech_msgs_MCUCommandData_fields); - -// if (systick.triggers.trigger1000) -// { -// handle_ethernet_socket_send_pb(EthParams::default_TCU_ip, EthParams::default_protobuf_send_port, &protobuf_send_socket, out_msg, hytech_msgs_MCUOutputData_fields); -// } -// } \ No newline at end of file +void handle_ethernet_interface_comms(const SysTick_s &systick, const hytech_msgs_MCUOutputData &out_msg) +{ + // function that will handle receiving and distributing of all messages to all ethernet interfaces + // via the union message. this is a little bit cursed ngl. + // TODO un fuck this and make it more sane + // Serial.println("bruh"); + // handle_ethernet_socket_receive(&protobuf_recv_socket, &recv_pb_stream_union_msg, ethernet_interfaces); + + std::function recv_boi = &recv_pb_stream_msg; + handle_ethernet_socket_receive<1024, hytech_msgs_MCUCommandData>(systick, &protobuf_recv_socket, recv_boi, db_eth_interface, hytech_msgs_MCUCommandData_fields); + + if (systick.triggers.trigger1000) + { + handle_ethernet_socket_send_pb(EthParams::default_TCU_ip, EthParams::default_protobuf_send_port, &protobuf_send_socket, out_msg, hytech_msgs_MCUOutputData_fields); + } +} \ No newline at end of file