rfid-usb-gom-sensor 0.1.4 → 0.1.5

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
@@ -156,10 +156,19 @@ module RfidUsbGomSensor
156
156
  # 11 BCC XOR[1..10]
157
157
  # 12 ETX 0x03
158
158
  #
159
- def decode blk, hex_id = false
159
+ # :legacy => true -> makes this compatible to the tag id readout code
160
+ # in: rfid-readers/app/models/rfid_reader.rb
161
+ #
162
+ def decode blk, opts = { }
163
+ opts = ({:hex_id => false, :legacy => false }.merge opts)
160
164
  #validate
161
165
  rec = (blk.unpack 'c2Qc*')
162
- if hex_id
166
+
167
+ if opts[:legacy]
168
+ id = rec[2]
169
+ rec[2] = Integer("0x#{(([id].pack 'q').unpack 'H*').first}")
170
+ end
171
+ if opts[:hex_id]
163
172
  id = rec[2]
164
173
  rec[2] = "0x#{([id].pack 'Q').unpack 'H*'}"
165
174
  end
@@ -7,12 +7,28 @@ describe RfidUsbGomSensor::Node do
7
7
  Node.should_not == nil
8
8
  end
9
9
 
10
- it "should fail on a wronk checksum" do
10
+ it "should fail on a wrong checksum" do
11
11
  ref_rec = [2, 1, 12616128551217792992, 0, 77, 3]
12
12
  blk = ref_rec.pack "ccQccc"
13
13
  lambda { rec = (Node.decode blk) }.should raise_error
14
14
  end
15
15
 
16
+ it "should decode tag id into hex string" do
17
+ ref_rec = [2, 1, 12616128551217792992, 0, 49, 3]
18
+ blk = ref_rec.pack "ccQccc"
19
+ rec = (Node.decode blk, :hex_id => true)
20
+ ref_rec[2] = "0xe0070000137e15af"
21
+ rec.should == ref_rec
22
+ end
23
+
24
+ it "should decode a record with legacy mode" do
25
+ ref_rec = [2, 1, 12616128551217792992, 0, 49, 3]
26
+ blk = ref_rec.pack "ccQccc"
27
+ rec = (Node.decode blk, :legacy => true)
28
+ ref_rec[2] = 16142871389659862447
29
+ rec.should == ref_rec
30
+ end
31
+
16
32
  it "should decode a record" do
17
33
  ref_rec = [2, 1, 12616128551217792992, 0, 49, 3]
18
34
  blk = ref_rec.pack "ccQccc"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rfid-usb-gom-sensor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - art+com/dirk luesebrink
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-11 00:00:00 +01:00
12
+ date: 2010-01-12 00:00:00 +01:00
13
13
  default_executable: rfid-usb-gom-sensor
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency