-
Notifications
You must be signed in to change notification settings - Fork 0
/
RFID_show.lua
43 lines (37 loc) · 881 Bytes
/
RFID_show.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
--shows RFID card data
--[[
local shell = require("shell")
shell.setWorkingDirectory("/mnt/335/");
shell.execute("crd")
]]--
local event = require("event")
local term = require("term")
local unicode = require("unicode")
local rfidreader = require("component").os_rfidreader
require("component").gpu.setResolution(48,12)
function split(data, pat)
local ret = {}
for i in unicode.gmatch(data,pat) do
table.insert(ret,i)
end
return ret
end
function pt(ndict) for k,v in pairs(ndict) do print(k) end end
function scanRfid(ndist)
rfidreader.scan(ndist)
local _,_,nick,dist,data,id = event.pull(0.2, "rfidData")
term.clear()
if(data ~= nil) then
-- ,"\n",
pt(split(data,"/+"))
-- type/nick/data
-- print(nick)
-- print(data)
end
return nick, data
end
term.clear()
-- while true do
scanRfid(4)
-- require("os").sleep(0.5)
-- end