/** * @ingroup rdm * * The function is registered in the poll table \file main.c */ void rdm_data_received(void) { uint8_t *rdm_data = (uint8_t *) rdm_get_available(); if (rdm_data == NULL) { return; } if (rdm_data[0] == 0xFE) { return; } if (rdm_data[0] == E120_SC_RDM) { const struct _rdm_command *rdm_cmd = (struct _rdm_command *) rdm_data; const uint8_t command_class = rdm_cmd->command_class; switch (command_class) { case E120_DISCOVERY_COMMAND: case E120_GET_COMMAND: case E120_SET_COMMAND: rdm_handle_data(rdm_data); break; default: break; } } }
/** * * This function is called from the poll table in \ref main.c * * Received RMX Packet (Label=5 \ref RECEIVED_DMX_PACKET) * * The Widget sends this message to the PC unsolicited, whenever the Widget receives a DMX or RDM packet from the DMX port, * and the Receive DMX on Change mode (\ref receive_dmx_on_change) is 'Send always' (\ref SEND_ALWAYS). */ void widget_received_rdm_packet(void) { if ((widget_mode == MODE_DMX) || (widget_mode == MODE_RDM_SNIFFER) || (receive_dmx_on_change == SEND_ON_DATA_CHANGE_ONLY)) { return; } const uint8_t *rdm_data = rdm_get_available(); if (rdm_data == NULL) { return; } uint8_t message_length = 0; if (rdm_data[0] == E120_SC_RDM) { struct _rdm_command *p = (struct _rdm_command *) (rdm_data); const uint8_t command_class = p->command_class; message_length = p->message_length + 2; monitor_line(MONITOR_LINE_INFO, "Send RDM data to HOST, l:%d", message_length); monitor_line(MONITOR_LINE_STATUS, "RECEIVED_RDM_PACKET SC:0xCC"); widget_usb_send_header(RECEIVED_DMX_PACKET, 1 + message_length); usb_send_byte(0); // RDM Receive status widget_usb_send_data(rdm_data, message_length); widget_usb_send_footer(); const uint16_t param_id = (p->param_id[0] << 8) + p->param_id[1]; if ((command_class == E120_DISCOVERY_COMMAND_RESPONSE) && (param_id != E120_DISC_MUTE)) { rdm_time_out_message(); } else { widget_send_rdm_packet_start = 0; } } else if (rdm_data[0] == 0xFE) { message_length = 24; monitor_line(MONITOR_LINE_INFO, "Send RDM data to HOST, l:%d", message_length); monitor_line(MONITOR_LINE_STATUS, "RECEIVED_RDM_PACKET SC:0xFE"); widget_usb_send_header(RECEIVED_DMX_PACKET, 1 + message_length); usb_send_byte(0); // RDM Receive status widget_usb_send_data(rdm_data, message_length); widget_usb_send_footer(); rdm_time_out_message(); } monitor_rdm_data(MONITOR_LINE_RDM_DATA, message_length, rdm_data, false); }