Skip to content

Commit

Permalink
Handle packets
Browse files Browse the repository at this point in the history
  • Loading branch information
ps2 committed May 14, 2020
1 parent 5f34cdd commit 439a61a
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions OmniKitPacketParser/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,20 @@ class LoopIssueReportParser {
let message = try Message(encodedData: data)
print("\(date) \(direction) \(message)")
} catch let error as MessageError {
switch error {
case .notEnoughData:
if data.count == 4 {
// This is from a packet, not a message, and we don't have the full packet info here
print("\(date) \(direction) ack \(components[7])")
} else {
print("Could not parse \(line)")
if let packet = try? Packet(encodedData: data) {
print("\(date) \(direction) packet \(packet)")
} else {
switch error {
case .notEnoughData:
if data.count == 4 {
// This is from a packet, not a message, and we don't have the full packet info here
print("\(date) \(direction) ack \(components[7])")
} else {
print("Could not parse \(line)")
}
default:
print("Could not parse \(line): \(error.localizedDescription)")
}
default:
print("Could not parse \(line): \(error.localizedDescription)")
}
} catch let error {
print("Could not parse \(line): \(error)")
Expand Down

0 comments on commit 439a61a

Please sign in to comment.