Communication uses instantiated Packetizers and Decoders now

This commit is contained in:
Paul Hollinsky
2018-09-25 17:47:27 -04:00
parent 585abe7cbb
commit aa25ba1728
17 changed files with 161 additions and 107 deletions
+3 -5
View File
@@ -32,8 +32,6 @@ void MultiChannelCommunication::readTask() {
std::deque<uint8_t> usbReadFifo;
std::vector<uint8_t> readBytes;
std::vector<uint8_t> payloadBytes;
Packetizer packetizer;
MessageDecoder decoder;
while(!closing) {
if(readMore) {
@@ -108,9 +106,9 @@ void MultiChannelCommunication::readTask() {
usbReadFifo.pop_front();
}
if(packetizer.input(payloadBytes)) {
for(auto& packet : packetizer.output()) {
auto msg = decoder.decodePacket(packet);
if(packetizer->input(payloadBytes)) {
for(auto& packet : packetizer->output()) {
auto msg = decoder->decodePacket(packet);
for(auto& cb : messageCallbacks) { // We might have closed while reading or processing
if(!closing) {
cb.second.callIfMatch(msg);