-- -- ~~~ helper utils -- -- string -> hex function string.tohex(str) return (str:gsub(".", function (c) return string.format("%02X", string.byte(c)) end)) end -- hex -> string function string.fromhex(str) return (str:gsub("..", function (cc) return string.char(tonumber(cc, 16)) end)) end -- table[start, end] -> hex function table.extracthex(response, start, last) local result = {} table.move(response, start, last, 1, result) result = string.tohex(table.concat(result)) return result end -- table -> pretty print function table.dump(response) if type(response) == "table" then local start = "{ " for key, value in pairs(response) do if type(key) ~= "number" then key = '"' .. key .. '"' end start = start .. "[" .. key .. "] = " .. table.dump(value) .. "," end return start .. "} " else return tostring(response) end end