Skip to content

Commit

Permalink
removed txid guard to allow for unknown txid's
Browse files Browse the repository at this point in the history
  • Loading branch information
kkonteh97 committed May 2, 2024
1 parent 2ea4d4c commit f611447
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Sources/SwiftOBD2/parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -147,19 +147,18 @@ 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
}

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 {
Expand Down

0 comments on commit f611447

Please sign in to comment.