-
Notifications
You must be signed in to change notification settings - Fork 0
/
crd
57 lines (51 loc) · 1.14 KB
/
crd
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
--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 splitBySymbol(nstr, nchar)
local res={}
local t="_"
local cnt=1
while (true) do
t=""
for i = 1, unicode.len(nstr) do
if(unicode.sub(nstr, i,i)==nchar) then
t = unicode.sub(nstr, 1,i-1)
nstr = unicode.sub(nstr, i+1)
break
end
end
if(t=="")then
break
end
res[cnt]=t
cnt = cnt+1
end
res[cnt]=nstr
return res
end
function pt(ndict) for k,v in pairs(ndict) do print(k) end end
function scanRfid(ndist)
term.clear()
rfidreader.scan(ndist)
local _, _, nick0,dist,data,id = event.pull(0.2, "rfidData")
local nick
local other
if(data ~= nil) then
print(data)
_, nick, other = table.unpack(splitBySymbol(data,'/'))
end
return nick, other
end
term.clear()
-- while true do
print(scanRfid(4))
-- require("os").sleep(0.5)
-- end