check for table type before checking length, added power conversion/formatting helpers

This commit is contained in:
Mikayla Fischler
2022-09-22 21:31:07 -04:00
parent 50be7f9ca2
commit 4f7775ccb6
8 changed files with 43 additions and 34 deletions

View File

@@ -143,8 +143,12 @@ function comms.scada_packet()
if #self.raw >= 3 then
self.seq_num = self.raw[1]
self.protocol = self.raw[2]
self.length = #self.raw[3]
self.payload = self.raw[3]
-- element 3 must be a table
if type(self.raw[3]) == "table" then
self.length = #self.raw[3]
self.payload = self.raw[3]
end
end
self.valid = type(self.seq_num) == "number" and