require "log" require "sys" require "utils" require "patch" siganl = require 'posix.signal' syswait = require 'posix.sys.wait' unistd = require 'posix.unistd' mqtt=require "mosquitto" base64=require("base64") dyutils=require("dyutils") require("lua_pack") require "internal_api" gw_sn = nil g_nodes = {} local function FormatLenght(format) local len if string.upper(format) == "C" then len = 1 elseif string.upper(string.sub(format,2,2)) == "S" then len = 2 elseif string.upper(string.sub(format,2,2)) == "I" then len = 4 elseif string.upper(string.sub(format,1,1)) == "A" then len = tonumber(string.sub(format,2)) else log.warn("port2pp", "format not support",format) return 0 end return len end global_point_table = { { ----! regs.reginfo 寄存器名称(或名称的数组),寄存器地址,寄存器格式化符号,数值缩放比例 reginfo = {"Status",6,"C"}, }, { reginfo = {"TempOfOut",298," 0 then local period={ identifier = service.identifier, sn = node.sn, intv_sample = service.sample_interval, -- 直接使用上报周期做采样 intv_report = service.report_interval, -- 直接使用上报周期做采样 last_sample = 0, last_report = 0 } table.insert(period_list,period) end end end end local function handler() local pid, status, code = syswait.wait(-1, syswait.WNOHANG) log.error('system exit', pid, status, code) --打印不出来 os.exit(0) end function main(nodes_cfg,sn) log.info("main_loop", "=============== fuelEnergy RUN 3.0 ============") gw_sn = sn if not gw_sn then -- gw_sn = io.getGatewayID() gw_sn = "21012C00FFFF" end log.info("main_loop", string.format("Try Run At Shell\nsn='%s'\nnodes='%s'\nmain_loop(nodes,sn)",gw_sn or "NOT SN",nodes_cfg or "")) siganl.signal(siganl.SIGKILL,handler) siganl.signal(siganl.SIGHUP,handler) local devs_sn = {} g_nodes = cjson.decode(nodes_cfg or "{}") for _,node in ipairs(g_nodes) do table.insert(devs_sn,node.sn) end log.info(nil,cjson.encode(devs_sn)) internal_api.local_mqtt_session(devs_sn,"PP",nil,port2pp) --启动系统框架 sys.init(0, 0) sys.run() end -- python /root/packet_cap.py tcp and ip[2:2] = 446 and src host 192.168.11.2 and src port 5000& main(arg[1],arg[2])