diff --git a/communication/decoder.cpp b/communication/decoder.cpp index 6d9cbbb..d8c0a96 100644 --- a/communication/decoder.cpp +++ b/communication/decoder.cpp @@ -59,7 +59,7 @@ uint64_t Decoder::GetUInt64FromLEBytes(const uint8_t* bytes) { bool Decoder::decode(std::shared_ptr& result, const std::shared_ptr& packet) { switch(packet->network.getType()) { case Network::Type::Ethernet: { - result = HardwareEthernetPacket::DecodeToMessage(packet->data, report); + result = HardwareEthernetPacket::DecodeToMessage(packet->data); if(!result) { report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::Error); return false; // A nullptr was returned, the packet was not long enough to decode diff --git a/communication/packet/ethernetpacket.cpp b/communication/packet/ethernetpacket.cpp index 7c438ff..adf02ca 100644 --- a/communication/packet/ethernetpacket.cpp +++ b/communication/packet/ethernetpacket.cpp @@ -4,7 +4,7 @@ using namespace icsneo; -std::shared_ptr HardwareEthernetPacket::DecodeToMessage(const std::vector& bytestream, const device_eventhandler_t& report) { +std::shared_ptr HardwareEthernetPacket::DecodeToMessage(const std::vector& bytestream) { const HardwareEthernetPacket* packet = (const HardwareEthernetPacket*)((const void*)bytestream.data()); const uint16_t* rawWords = (const uint16_t*)bytestream.data(); // Make sure we have enough to read the packet length first @@ -18,9 +18,6 @@ std::shared_ptr HardwareEthernetPacket::DecodeToMessage(const s const size_t bytestreamActualSize = bytestream.size(); if(bytestreamActualSize < bytestreamExpectedSize) return nullptr; - // Check for oversized packets, noting that some devices will send an extra byte to have an even number of bytes - if(bytestreamActualSize > bytestreamExpectedSize + 1) - report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::EventWarning); auto messagePtr = std::make_shared(); EthernetMessage& message = *messagePtr; message.transmitted = packet->eid.TXMSG; diff --git a/disk/vsa/vsa.cpp b/disk/vsa/vsa.cpp index ca22333..77552f2 100644 --- a/disk/vsa/vsa.cpp +++ b/disk/vsa/vsa.cpp @@ -25,19 +25,4 @@ void VSAExtendedMessage::appendPacket(std::shared_ptr packet) const if(packet->network.getNetID() == Network::NetID::Invalid) { packet->network = network; } -} - -void VSAExtendedMessage::truncatePacket(std::shared_ptr packet) -{ - static constexpr auto EthernetLengthOffset = 26u; - switch(packet->network.getType()) { - case Network::Type::Ethernet: - { - const auto& packetLength = *reinterpret_cast(packet->data.data() + EthernetLengthOffset); - const size_t ethernetFrameSize = packetLength - (sizeof(uint16_t) * 2); - const size_t bytestreamExpectedSize = sizeof(HardwareEthernetPacket) + ethernetFrameSize; - packet->data.resize(bytestreamExpectedSize); - } - break; - } } \ No newline at end of file diff --git a/disk/vsa/vsaparser.cpp b/disk/vsa/vsaparser.cpp index 008dff0..afb6d2d 100644 --- a/disk/vsa/vsaparser.cpp +++ b/disk/vsa/vsaparser.cpp @@ -430,7 +430,6 @@ bool VSAParser::extractMessagePackets(std::vector>& pack extendedMessageRecord->appendPacket(packet); if(extendedMessageRecord->getRecordCount() == static_cast(extendedMessageRecord->getIndex() + 1)) { // Last record in sequence if(!settings.messageFilter || extendedMessageRecord->filter(settings.messageFilter)) { - VSAExtendedMessage::truncatePacket(packet); packets.push_back(packet); } activeExtendedMessage = false; diff --git a/examples/cpp/vsa/src/VSAExample.cpp b/examples/cpp/vsa/src/VSAExample.cpp index 26e648e..7a39bdb 100644 --- a/examples/cpp/vsa/src/VSAExample.cpp +++ b/examples/cpp/vsa/src/VSAExample.cpp @@ -239,6 +239,9 @@ int main(int argc, char* argv[]) { return -1; } + std::cout << "Waiting for 5 seconds..." << std::endl; + std::this_thread::sleep_for(std::chrono::seconds(5)); + std::cout << "info: " << currentMessage << " transmitted frames found" << std::endl; resetScriptStatus(rxDevice, txDevice, rxInitialCoreminiStatus, txInitialCoreminiStatus); diff --git a/include/icsneo/communication/packet/ethernetpacket.h b/include/icsneo/communication/packet/ethernetpacket.h index 0f4e000..2cbd75d 100644 --- a/include/icsneo/communication/packet/ethernetpacket.h +++ b/include/icsneo/communication/packet/ethernetpacket.h @@ -18,7 +18,7 @@ namespace icsneo { typedef uint16_t icscm_bitfield; struct HardwareEthernetPacket { - static std::shared_ptr DecodeToMessage(const std::vector& bytestream, const device_eventhandler_t& report); + static std::shared_ptr DecodeToMessage(const std::vector& bytestream); static bool EncodeFromMessage(const EthernetMessage& message, std::vector& bytestream, const device_eventhandler_t& report); // Word 0 - Header flags (offset 0) @@ -57,8 +57,9 @@ struct HardwareEthernetPacket { struct { icscm_bitfield T1S_BURST_COUNT : 8; icscm_bitfield T1S_NODE_ID : 8; - uint8_t RESERVED[6]; } t1s_node; + + uint8_t RESERVED[6]; // Words 4-7 - Reserved/Padding uint16_t stats; diff --git a/include/icsneo/disk/vsa/vsa.h b/include/icsneo/disk/vsa/vsa.h index 585aa4b..cd1719d 100644 --- a/include/icsneo/disk/vsa/vsa.h +++ b/include/icsneo/disk/vsa/vsa.h @@ -238,8 +238,6 @@ protected: */ class VSAExtendedMessage : public VSAMessage { public: - static void truncatePacket(std::shared_ptr packet); - /** * Appends the payload for this message to the given packet. * Also sets the network of the packet if unset (used primarily for AA0F records which do not contain the network in the first extended message record).