Skip to content

Commit f9ecefe

Browse files
committed
Land rapid7#8031, nil fixes for HWBridge
2 parents aa1e76f + d4e5cb7 commit f9ecefe

File tree

3 files changed

+54
-5
lines changed

3 files changed

+54
-5
lines changed

lib/rex/post/hwbridge/extensions/automotive/uds_errors.rb

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module Automotive
88

99
module UDSErrors
1010

11+
# Negative Response Codes (NDC)
1112
ERR_MNEMONIC = {
1213
0x10 => "GR",
1314
0x11 => "SNS",
@@ -54,7 +55,25 @@ module UDSErrors
5455
0x73 => "WBSC",
5556
0x78 => "RCRRP",
5657
0x7E => "SFNSIAS",
57-
0x7F => "SNSIAS"
58+
0x7F => "SNSIAS",
59+
0x81 => "RTH",
60+
0x82 => "RTL",
61+
0x83 => "EIR",
62+
0x84 => "EINR",
63+
0x85 => "ERTTL",
64+
0x86 => "TTH",
65+
0x87 => "TTL",
66+
0x88 => "VSTH",
67+
0x89 => "VSTL",
68+
0x8A => "TPTH",
69+
0x8B => "TPTL",
70+
0x8C => "TRNIN",
71+
0x8D => "TRNIG",
72+
0x8F => "BSNC",
73+
0x90 => "SLNIP",
74+
0x91 => "TCCL",
75+
0x92 => "VTH",
76+
0x93 => "VTL"
5877
}
5978

6079
ERR_DESC = {
@@ -80,7 +99,25 @@ module UDSErrors
8099
"WBSC" => "Wrong Block Sequence Counter",
81100
"RCRRP" => "Request Correctly Received, but Response is Pending",
82101
"SFNSIAS" => "Sub-Function Not Supoorted In Active Session",
83-
"SNSIAS" => "Service Not Supported In Active Session"
102+
"SNSIAS" => "Service Not Supported In Active Session",
103+
"RTH" => "RPM Too High",
104+
"RTL" => "RPM Too Low".
105+
"EIR" => "Engine is Running",
106+
"EINR" => "Engine is not Running",
107+
"ERTTL" => "Engine Run Time Too Low",
108+
"TTH" => "Temperature Too High",
109+
"TTL" => "Temperature Too Low",
110+
"VSTH" => "Vehicle Speed Too High",
111+
"VSTL" => "Vehicle Speed Too Low",
112+
"TPTH" => "Throttle Pedal Too High",
113+
"TPTL" => "Throttle Pedal Too Low",
114+
"TRNIN" => "Transmission Range Not in Neutral",
115+
"TRNIG" => "Transmission Range Not in Gear",
116+
"BSNC" => "Brake Switch Not Closed",
117+
"SLNIP" => "Shifter Lever Not In Park",
118+
"TCCL" => "Torque Converter Clutch Locked",
119+
"VTH" => "Voltage Too High",
120+
"VTL" => "Voltage Too Low"
84121
}
85122

86123
end

modules/post/hardware/automotive/getvinfo.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ def initialize(info={})
3333

3434
def run
3535
pids = get_current_data_pids(datastore["CANBUS"], datastore["SRCID"], datastore["DSTID"])
36-
print_status("Available PIDS for pulling realtime data: #{pids.size} pids")
37-
print_status(" #{pids.inspect}")
36+
if pids.size == 0
37+
print_status("No reported PIDs. You may not be properly connected")
38+
else
39+
print_status("Available PIDS for pulling realtime data: #{pids.size} pids")
40+
print_status(" #{pids.inspect}")
41+
end
3842
if pids.include? 1
3943
data = get_monitor_status(datastore["CANBUS"], datastore["SRCID"], datastore["DSTID"])
4044
print_status(" MIL (Engine Light) : #{data["MIL"] ? "ON" : "OFF"}") if data.has_key? "MIL"
@@ -58,7 +62,7 @@ def run
5862
dtcs = get_dtcs(datastore["CANBUS"], datastore["SRCID"], datastore["DSTID"])
5963
print_status("DTCs: #{ dtcs.join(",") }") if dtcs.size > 0
6064
pids = get_vinfo_supported_pids(datastore["CANBUS"], datastore["SRCID"], datastore["DSTID"])
61-
print_status("Mode $09 Vehicle Info Supported PIDS: #{pids.inspect}")
65+
print_status("Mode $09 Vehicle Info Supported PIDS: #{pids.inspect}") if pids.size > 0
6266
pids.each do |pid|
6367
# Handle known pids
6468
if pid == 2

tools/hardware/elm327_relay.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ def cansend(id, data)
249249
send_cmd(data)
250250
@packets_sent += 1
251251
@last_sent = Time.now()
252+
if resp == "CAN ERROR"
253+
result["success"] = false
254+
return result
255+
end
252256
result["success"] = true
253257
result
254258
end
@@ -273,6 +277,10 @@ def isotpsend_and_wait(srcid, dstid, data, timeout, maxpkts)
273277
resp = send_cmd(data)
274278
@packets_sent += 1
275279
@last_sent = Time.now()
280+
if resp == "CAN ERROR"
281+
result["success"] = false
282+
return result
283+
end
276284
result["Packets"] = []
277285
resp.split(/\r/).each do |line|
278286
pkt = {}

0 commit comments

Comments
 (0)