From f6114478b94092d1dd43dd7238a168d24bc008a8 Mon Sep 17 00:00:00 2001 From: kkonteh97 <55326260+kkonteh97@users.noreply.github.com> Date: Thu, 2 May 2024 12:18:15 -0700 Subject: [PATCH] removed txid guard to allow for unknown txid's --- Sources/SwiftOBD2/parser.swift | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Sources/SwiftOBD2/parser.swift b/Sources/SwiftOBD2/parser.swift index 9f14e37..1fb85a7 100644 --- a/Sources/SwiftOBD2/parser.swift +++ b/Sources/SwiftOBD2/parser.swift @@ -75,7 +75,7 @@ public struct Message { } private func parseSingleFrameMessage(_ frames: [Frame]) -> Data? { - + guard let frame = frames.first, frame.type == .singleFrame, let dataLen = frame.dataLen, dataLen > 0, frame.data.count >= dataLen + 1 @@ -147,11 +147,10 @@ struct Frame { // return nil // } - guard let txID = ECUID(rawValue: dataBytes[3] & 0x07), - let dataType = data.first, + guard let dataType = data.first, let type = FrameType(rawValue: dataType & 0xF0) else { - print(dataBytes.compactMap { String(format: "%02X", $0) }.joined(separator: " ")) + print(dataBytes.compactMap { String(format: "%02X", $0) }) print("invalid frame type") return nil } @@ -159,7 +158,7 @@ struct Frame { priority = dataBytes[2] & 0x0F addrMode = dataBytes[3] & 0xF0 rxID = dataBytes[2] - self.txID = txID + self.txID = ECUID(rawValue: dataBytes[3] & 0x07) ?? .unknown self.type = type switch type {