use the MessageData creator to instantiate the correct specialized type

This commit is contained in:
Kevin Matz 2023-04-09 20:06:43 -04:00
parent d7d64fa13c
commit 4c0bf5ded8

View File

@ -63,6 +63,17 @@ void DmxWidget::close()
*/
void DmxWidget::parseMessageBuffer()
{
OperatingMode other_side = USBunknown;
switch (usb_mode) {
case ENTTEC::Widget::USBdevice:
other_side = USBhost;
break;
case ENTTEC::Widget::USBhost:
other_side = USBdevice;
break;
default:
break;
}
uint16_t length;
const int fixed_length = 5; // start + label + 2xlength + end
auto fast_forward = [this](int offset = 0) {
@ -90,7 +101,7 @@ void DmxWidget::parseMessageBuffer()
continue;
}
// make a new message data
auto msg = std::make_shared<ENTTEC::Pro::MessageData>((uint8_t)message_rx_buffer_[1]);
auto msg = MessageDataFactory((MESSAGE_LABEL)message_rx_buffer_[1], other_side);
// fill it with data
std::shared_ptr<bufferstream> stream(new bufferstream(
reinterpret_cast<uint8_t*>(message_rx_buffer_.data())+fixed_length-1,