phidget_rfid 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +3 -3
- data/lib/phidget_rfid/commands.rb +18 -9
- data/lib/phidget_rfid/rfid_handler.rb +34 -23
- data/lib/phidget_rfid/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f540fa42d23fb177b3bae2479ac9f6db647d572
|
4
|
+
data.tar.gz: 9d7565c710aa1af6e6158e61057ce9a6f3c77566
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fabdf786486dc5fcf1df49407946a520c01c4b1db00c2d11e707af712569b032e1bfb98fef2be438b8caed70ff8d2822882287287ee08b4aac1bdab4237b889
|
7
|
+
data.tar.gz: c4c8b6ea576635b6493231ce0f8e149220695449b96ccde98f338cf67c8924b037634aee4db36de66aff87480b3dc319538d2bf416240af6a6811f52b17274ff
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -4,12 +4,12 @@ This is a simple ruby program to work with the Phidget RFID in the console
|
|
4
4
|
|
5
5
|
## Installation:
|
6
6
|
|
7
|
-
gem install
|
7
|
+
gem install phidget_rfid
|
8
8
|
|
9
9
|
|
10
10
|
## Usage:
|
11
11
|
```
|
12
|
-
|
12
|
+
phidget_rfid
|
13
13
|
```
|
14
14
|
|
15
15
|
And then you can use the help command
|
@@ -27,4 +27,4 @@ RFID> help
|
|
27
27
|
exit - Exit from program
|
28
28
|
You can type "help <command>" for more info
|
29
29
|
------------------------------
|
30
|
-
```
|
30
|
+
```
|
@@ -7,12 +7,12 @@ module PhidgetRfid
|
|
7
7
|
private
|
8
8
|
extend CLI::Task
|
9
9
|
|
10
|
-
|
10
|
+
|
11
11
|
|
12
12
|
public
|
13
13
|
|
14
|
-
def initialize (
|
15
|
-
@
|
14
|
+
def initialize (r)
|
15
|
+
@rfid_handler = r
|
16
16
|
end
|
17
17
|
|
18
18
|
|
@@ -20,16 +20,25 @@ module PhidgetRfid
|
|
20
20
|
desc 'Reads the value from the connected RFID tag'
|
21
21
|
|
22
22
|
def read(params)
|
23
|
-
puts @
|
23
|
+
puts @rfid_handler.read
|
24
24
|
end
|
25
25
|
|
26
26
|
|
27
27
|
|
28
28
|
usage 'Usage: write "string to write" <protocol> <lock>'
|
29
|
-
desc 'Writes the provided text into the RFID tag. Protocols: EM4100, ISO11785_FDX_B, PhidgetTAG, 1'
|
29
|
+
desc 'Writes the provided text into the RFID tag. Protocols: EM4100, ISO11785_FDX_B, PhidgetTAG, 1.\nHave in mind that if the TAG is blank you need to write it for the first time with the PhidgetTAG protocol'
|
30
|
+
|
30
31
|
|
31
32
|
def write(params)
|
32
|
-
|
33
|
+
|
34
|
+
if params.size == 1
|
35
|
+
puts @rfid_handler.write params[0]
|
36
|
+
elsif params.size == 2
|
37
|
+
puts @rfid_handler.write params[0], params[1]
|
38
|
+
elsif params.size == 3
|
39
|
+
|
40
|
+
puts @rfid_handler.write params[0], params[2], params[3]
|
41
|
+
end
|
33
42
|
end
|
34
43
|
|
35
44
|
|
@@ -38,7 +47,7 @@ module PhidgetRfid
|
|
38
47
|
desc 'Displays the current tag protocol'
|
39
48
|
|
40
49
|
def protocol(params)
|
41
|
-
puts @
|
50
|
+
puts @rfid_handler.protocol
|
42
51
|
end
|
43
52
|
|
44
53
|
|
@@ -54,14 +63,14 @@ module PhidgetRfid
|
|
54
63
|
desc 'Displays: reader id, serial number and state, Antenna and Led state. Library API version'
|
55
64
|
|
56
65
|
def device(params)
|
57
|
-
puts @
|
66
|
+
puts @rfid_handler.device
|
58
67
|
end
|
59
68
|
|
60
69
|
usage 'Usage: log'
|
61
70
|
desc 'Shows the event log'
|
62
71
|
|
63
72
|
def log(params)
|
64
|
-
puts @
|
73
|
+
puts @rfid_handler.log
|
65
74
|
end
|
66
75
|
|
67
76
|
|
@@ -1,36 +1,36 @@
|
|
1
1
|
module PhidgetRfid
|
2
2
|
class RfidHandler
|
3
|
-
@
|
3
|
+
@phidget
|
4
4
|
@prompt
|
5
5
|
@time
|
6
6
|
attr_accessor :log
|
7
7
|
|
8
8
|
def initialize()
|
9
|
-
@
|
9
|
+
@phidget = Phidgets::RFID.new
|
10
10
|
@time = Time.new
|
11
11
|
@prompt = "at #{@time.strftime("%Y-%m-%d %H:%M:%S")} \033[0m"
|
12
12
|
@log = ""
|
13
13
|
|
14
|
-
@
|
14
|
+
@phidget.on_detach do |device, obj|
|
15
15
|
@log.append "\n#{device.attributes.inspect} removed"
|
16
16
|
end
|
17
17
|
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
18
|
+
@phidget.on_attach do |device, obj|
|
19
|
+
@phidget.antenna = true
|
20
|
+
@phidget.led = false
|
21
21
|
end
|
22
22
|
|
23
|
-
@
|
23
|
+
@phidget.on_error do |device, obj, code, description|
|
24
24
|
@log << "\033[31m\nError #{code}: #{description} #{@prompt}"
|
25
25
|
end
|
26
26
|
|
27
|
-
@
|
28
|
-
@
|
27
|
+
@phidget.on_tag do |device, tag, obj|
|
28
|
+
@phidget.led = true
|
29
29
|
@log << "\n\033[32m[+] #{protocol} tag detected #{@prompt}"
|
30
30
|
end
|
31
31
|
|
32
|
-
@
|
33
|
-
@
|
32
|
+
@phidget.on_tag_lost do |device, tag, obj|
|
33
|
+
@phidget.led = false
|
34
34
|
@log << "\n\033[33m[-] #{protocol} tag removed #{@prompt}"
|
35
35
|
end
|
36
36
|
|
@@ -38,19 +38,28 @@ module PhidgetRfid
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def protocol
|
41
|
-
if(@
|
42
|
-
@
|
41
|
+
if(@phidget.attached?)
|
42
|
+
@phidget.last_tag_protocol
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
def read
|
47
|
-
if(@
|
48
|
-
@
|
47
|
+
if(@phidget.attached?)
|
48
|
+
@phidget.last_tag
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
def write(value, protocol =
|
53
|
-
if(
|
52
|
+
def write(value, protocol = nil, lock = false)
|
53
|
+
if (protocol == nil)
|
54
|
+
protocol =
|
55
|
+
if @phidget.tag_present
|
56
|
+
@phidget.last_tag_protocol
|
57
|
+
else
|
58
|
+
"EM4100"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
if(@phidget.attached?)
|
54
63
|
p = protocol.to_sym
|
55
64
|
|
56
65
|
if lock
|
@@ -58,19 +67,21 @@ module PhidgetRfid
|
|
58
67
|
puts "Protocol: #{p}"
|
59
68
|
puts "Are you sure you want to lock the RFID Tag? This will make it read-only (y/N)"
|
60
69
|
r = gets.chomp
|
61
|
-
@
|
62
|
-
|
70
|
+
@phidget.write(value, p, true) if r == "y"
|
71
|
+
else
|
72
|
+
@phidget.write(value, p)
|
63
73
|
end
|
64
74
|
|
75
|
+
|
65
76
|
end
|
66
77
|
end
|
67
78
|
|
68
79
|
def device
|
69
80
|
puts "Library Version: #{Phidgets::FFI.library_version}"
|
70
|
-
puts "Class: #{
|
71
|
-
puts "Id: #{
|
72
|
-
puts "Serial number: #{
|
73
|
-
puts "
|
81
|
+
puts "Class: #{@phidget.device_class}"
|
82
|
+
puts "Id: #{@phidget.id}"
|
83
|
+
puts "Serial number: #{@phidget.serial_number}"
|
84
|
+
puts "Digital Outputs: #{@phidget.outputs.size}"
|
74
85
|
end
|
75
86
|
|
76
87
|
|
data/lib/phidget_rfid/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phidget_rfid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luis Fontes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|