local eptimer = require("eptimer") local fs = require("fs") local math = require("math") local ls = require "lsocket" unix={} unix.MSG_UART_RXDATA="receive" unix.MSG_UART_TX_DONE="sent" unix.INF_TIMEOUT="int_timeout" unix.MSG_TIMER="timeout" unix.MSG_PDP_DEACT_IND="pdp_deact" unix.POWERON_CHARGER="power_charger" unix.MSG_INT="pin_int" unix.MSG_SOCK_RECV_IND="sock_recv_ind" unix.MSG_SOCK_CLOSE_CNF="sock_close_cnf" unix.MSG_SOCK_CONN_CNF="sock_conn_cnf" unix.MSG_SOCK_SEND_CNF="sock_send_cnf" unix.MSG_SOCK_CLOSE_IND="sock_close_ind" local function callback(timer) local id = timer.param end function unix.restart(...) log.debug("============== 系统马上关闭 ============",...) os.exit(0,...) end unix.init = eptimer.init unix.timer_start = eptimer.start unix.timer_stop = eptimer.stop unix.msleep = eptimer.msleep unix.sleep = eptimer.sleep function unix.get_fs_free_size(...) return 1000 end function unix.make_dir(...) return fs.mkdir(...) end function unix.set_trace_port(port) log.debug("os-unix",string.format("trace port[%d] ",port)) end function unix.poweron_reason() return unix.POWERON_CHARGER end function unix.receive(msg_id) if msg_id == unix.INF_TIMEOUT then while true do local ret,timer = eptimer.epoll() if ret and ret == true then local msg = nil msg = unix.MSG_TIMER return msg, timer end if sys.poll_socket then if type(sys.poll_socket) == "function" then msg = sys.poll_socket() elseif type(sys.poll_socket) == "table" then local func = sys.poll_socket[sys.poll_socket_index] if func then msg = func() if sys.poll_socket_index >= #sys.poll_socket then sys.poll_socket_index = 1 else sys.poll_socket_index = sys.poll_socket_index + 1 end else return nil end end return msg end end end return nil end function unix.get_version() return "virtual luat" end return unix