Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ETYPE_RNET=0
- if not fs.exists("disk/cid") then
- error("please start the isr-unit first")
- end
- local f=fs.open("disk/cid","r")
- local cId=tonumber(f.readAll())
- f.close()
- fs.delete("disk/isrLock")
- function getCId()
- return cId
- end
- function getEvents()
- if fs.exists("disk/isr") then
- fs.open("disk/isrLock", "w").close()
- while fs.exists("disk/isrLock2") do
- sleep(0.01)
- end
- local data = {}
- local handle = fs.open("disk/isr", "r")
- for line in handle.readLine do
- if line ~= "" then
- if string.sub(line, 1, 5) == "rnet:" then
- line = string.sub(line, 6)
- local ind = string.find(line, ",")
- table.insert(data,{type=ETYPE_RNET,id=tonumber(string.sub(line,1,ind-1)),msg=string.sub(line,ind+1)})
- else print("unknown event: " .. line)
- end
- end
- end
- handle.close()
- fs.open("disk/isr","w").close()
- fs.delete("disk/isrLock")
- return data
- end
- return {}
- end
- getEvents()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement