int acmp_controller_state_machine::tx_cmd(void *notification_id, uint32_t notification_flag, struct jdksavdecc_frame *cmd_frame, bool resend) { int send_frame_returned; if(!resend) { uint16_t this_seq_id = acmp_seq_id; uint32_t msg_type = jdksavdecc_common_control_header_get_control_data(cmd_frame->payload, ETHER_HDR_SIZE); uint32_t timeout_ms = utility->acmp_cmd_to_timeout(msg_type); // ACMP command timeout lookup jdksavdecc_acmpdu_set_sequence_id(acmp_seq_id++, cmd_frame->payload, ETHER_HDR_SIZE); inflight in_flight = inflight(cmd_frame, this_seq_id, notification_id, notification_flag, timeout_ms); in_flight.start_timer(); inflight_cmds.push_back(in_flight); } else { uint16_t resend_with_seq_id = jdksavdecc_acmpdu_get_sequence_id(cmd_frame->payload, ETHER_HDR_SIZE); std::vector<inflight>::iterator j = std::find_if(inflight_cmds.begin(), inflight_cmds.end(), SeqIdComp(resend_with_seq_id)); if(j != inflight_cmds.end()) // found? { (*j).start_timer(); } } send_frame_returned = net_interface_ref->send_frame(cmd_frame->payload, cmd_frame->length); if(send_frame_returned < 0) { log_imp_ref->post_log_msg(LOGGING_LEVEL_ERROR, "netif_send_frame error"); assert(send_frame_returned >= 0); } callback(notification_id, notification_flag, cmd_frame->payload); return 0; }
int aecp_controller_state_machine::tx_cmd(void *notification_id, uint32_t notification_flag, struct jdksavdecc_frame *cmd_frame, bool resend) { int send_frame_returned; if (!resend) { uint16_t current_seq_id = aecp_seq_id; jdksavdecc_aecpdu_common_set_sequence_id(aecp_seq_id++, cmd_frame->payload, ETHER_HDR_SIZE); inflight in_flight = inflight(cmd_frame, current_seq_id, notification_id, notification_flag, AVDECC_MSG_TIMEOUT_MS); in_flight.start_timer(); inflight_cmds.push_back(in_flight); } else { uint16_t resend_with_seq_id = jdksavdecc_aecpdu_common_get_sequence_id(cmd_frame->payload, ETHER_HDR_SIZE); std::vector<inflight>::iterator j = std::find_if(inflight_cmds.begin(), inflight_cmds.end(), SeqIdComp(resend_with_seq_id)); if(j != inflight_cmds.end()) // found? { j->start_timer(); } } send_frame_returned = net_interface_ref->send_frame(cmd_frame->payload, cmd_frame->length); if(send_frame_returned < 0) { log_imp_ref->post_log_msg(LOGGING_LEVEL_ERROR, "netif_send_frame error"); assert(send_frame_returned >= 0); } callback(notification_id, notification_flag, cmd_frame->payload); return 0; }