extface 0.5.9 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,6 +17,12 @@ datecs_fp550:
17
17
  name: Datect FP550
18
18
  extfaceable: one(Shop)
19
19
  driver: datecs_fp550
20
+
21
+ datecs_dp25:
22
+ uuid: datecs_dp25
23
+ name: Datect DP25
24
+ extfaceable: one(Shop)
25
+ driver: datecs_dp25
20
26
 
21
27
  daisy_fx1200:
22
28
  uuid: daisy_fx1200
@@ -12,6 +12,9 @@ star_scp700:
12
12
  datecs_fp550:
13
13
  type: Extface::Driver::Datecs::Fp550
14
14
 
15
+ datecs_dp25:
16
+ type: Extface::Driver::Datecs::Dp25
17
+
15
18
  daisy_fx1200:
16
19
  type: Extface::Driver::DaisyFx1200
17
20
 
@@ -0,0 +1,63 @@
1
+ require 'test_helper'
2
+
3
+ module Extface
4
+ class Driver::Datecs::Dp25Test < ActiveSupport::TestCase
5
+ setup do
6
+ @driver = extface_drivers(:datecs_dp25)
7
+ @driver.flush # clear receive buffer
8
+ end
9
+
10
+ test "handle" do
11
+ assert_equal nil, @driver.handle('bad packet')
12
+ assert_equal 6, @driver.handle("\x01data\x03data"), "Frame not match"
13
+ assert_equal 9, @driver.handle("pre\x01data\x03data"), "Frame with preamble not match"
14
+ assert_equal 8, @driver.handle("\x16\x16\x01data\x03data"), "Frame with ACK preamble not match"
15
+ assert_equal 4, @driver.handle("pre\x15"), "NAK not match"
16
+ end
17
+
18
+ test "build packet" do
19
+ assert_equal "\x01\x24\x20\x4a\x05\x30\x30\x39\x33\x03".b, @driver.build_packet(0x4a), "packet without data"
20
+ assert_equal "\x01\x25\x21\x4a\x58\x05\x30\x30\x3e\x3d\x03".b, @driver.build_packet(0x4a, 'X'), "packet with data"
21
+ end
22
+
23
+ test "response frame" do
24
+ frame_class = @driver.class::Frame
25
+ assert frame_class.new("\x15").nak?, "NAK message failed"
26
+ assert frame_class.new("\x16\x16").ack?, "ACK message failed"
27
+ assert_nothing_raised do
28
+ assert_equal false, frame_class.new("bad data\x01\x25\x21\x4asome broken packet\x58\x05\x30\x30\x3e\x3d\x03".b).valid?
29
+ end
30
+ frame = frame_class.new("\x16\x01\x2C\x2F\x2D\x50\x04\x88\x80\xC0\x80\x80\xB0\x05\x30\x34\x35\x39\x03".b)
31
+ assert frame.valid?, "Vailid frame not recognized"
32
+ assert_equal "\x01\x2C\x2F\x2D\x50\x04\x88\x80\xC0\x80\x80\xB0\x05\x30\x34\x35\x39\x03".b, frame.frame
33
+ assert_equal "\x2c".b, frame.len
34
+ assert_equal "\x2f".b, frame.seq
35
+ assert_equal "\x2d".b, frame.cmd
36
+ assert_equal "\x50".b, frame.data
37
+ assert_equal "\x88\x80\xC0\x80\x80\xB0".b, frame.status
38
+ assert_equal "\x30\x34\x35\x39".b, frame.bcc
39
+ #bad check sum
40
+ frame = frame_class.new("\x01\x2C\x2F\x2D\x50\x04\x88\x80\xC0\x80\x80\xB0\x05\x30\x34\x35\x38\x03".b)
41
+ assert_equal false, frame.valid?
42
+ assert frame.errors.messages[:bcc]
43
+ #bad length
44
+ frame = frame_class.new("\x01\x2b\x2F\x2D\x50\x04\x88\x80\xC0\x80\x80\xB0\x05\x30\x34\x35\x38\x03".b)
45
+ assert_equal false, frame.valid?
46
+ assert frame.errors.messages[:len]
47
+ end
48
+
49
+ test "fsend" do
50
+ job = extface_jobs(:one)
51
+ job_thread = Thread.new do
52
+ @driver.set_job(job)
53
+ result = @driver.fsend(0x2C) # paper move command
54
+ end
55
+ simulate_device_pull(job)
56
+ @driver.handle("\x01\x31\x20\x4A\x88\x80\xC0\x80\x80\xB8\x04\x88\x80\xC0\x80\x80\xB8\x05\x30\x37\x3A\x34\x03".b)
57
+ simulate_device_pull(job)
58
+ @driver.handle("\x01\x38\x21\x30\x30\x30\x30\x30\x35\x30\x2C\x30\x30\x30\x30\x34\x39\x04\x80\x80\x88\x80\x80\xB8\x05\x30\x36\x35\x30\x03".b)
59
+ job_thread.join
60
+ assert @driver.errors.empty?
61
+ end
62
+ end
63
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extface
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.9
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Vangelov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-01 00:00:00.000000000 Z
11
+ date: 2017-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -104,6 +104,7 @@ files:
104
104
  - app/models/extface/driver/daisy/commands_fx1200.rb
105
105
  - app/models/extface/driver/daisy_fx1200.rb
106
106
  - app/models/extface/driver/datecs/commands_v1.rb
107
+ - app/models/extface/driver/datecs/dp25.rb
107
108
  - app/models/extface/driver/datecs/fp550.rb
108
109
  - app/models/extface/driver/eltrade/commands_fp4.rb
109
110
  - app/models/extface/driver/eltrade_tm_u220.rb
@@ -126,6 +127,8 @@ files:
126
127
  - app/views/extface/driver/_control_raw.html.erb
127
128
  - app/views/extface/driver/_control_report.html.erb
128
129
  - app/views/extface/driver/daisy_fx1200/_settings.html.erb
130
+ - app/views/extface/driver/datecs/dp25/_control.html.erb
131
+ - app/views/extface/driver/datecs/dp25/_settings.html.erb
129
132
  - app/views/extface/driver/datecs/fp550/_control.html.erb
130
133
  - app/views/extface/driver/datecs/fp550/_settings.html.erb
131
134
  - app/views/extface/driver/eltrade_tm_u220/_control_.html.erb
@@ -201,14 +204,17 @@ files:
201
204
  - test/dummy/db/test.sqlite3
202
205
  - test/dummy/log/development.log
203
206
  - test/dummy/log/extface/1033518405/aura80.log
207
+ - test/dummy/log/extface/1033518405/aura80.log.20170327
204
208
  - test/dummy/log/extface/229906743/fp550.log
205
209
  - test/dummy/log/extface/229906743/fp550.log.20150519
206
210
  - test/dummy/log/extface/229906743/fp550.log.20150819
207
211
  - test/dummy/log/extface/229906743/fp550.log.20151218
208
212
  - test/dummy/log/extface/229906743/fp550.log.20160829
213
+ - test/dummy/log/extface/229906743/fp550.log.20170327
209
214
  - test/dummy/log/extface/40760454/daisy_fx1200.log
210
215
  - test/dummy/log/extface/40760454/daisy_fx1200.log.20151219
211
216
  - test/dummy/log/extface/40760454/daisy_fx1200.log.20160829
217
+ - test/dummy/log/extface/40760454/daisy_fx1200.log.20170327
212
218
  - test/dummy/log/test.log
213
219
  - test/dummy/public/404.html
214
220
  - test/dummy/public/422.html
@@ -245,6 +251,7 @@ files:
245
251
  - test/lib/generators/extface/driver_generator_test.rb
246
252
  - test/models/extface/device_test.rb
247
253
  - test/models/extface/driver/daisy_fx1200_test.rb
254
+ - test/models/extface/driver/datecs/dp25_test.rb
248
255
  - test/models/extface/driver/datecs/fp550_test.rb
249
256
  - test/models/extface/driver/generic_pos_test.rb
250
257
  - test/models/extface/driver/posiflex/aura80_test.rb
@@ -309,12 +316,15 @@ test_files:
309
316
  - test/dummy/log/extface/40760454/daisy_fx1200.log
310
317
  - test/dummy/log/extface/40760454/daisy_fx1200.log.20151219
311
318
  - test/dummy/log/extface/40760454/daisy_fx1200.log.20160829
319
+ - test/dummy/log/extface/40760454/daisy_fx1200.log.20170327
312
320
  - test/dummy/log/extface/1033518405/aura80.log
321
+ - test/dummy/log/extface/1033518405/aura80.log.20170327
313
322
  - test/dummy/log/extface/229906743/fp550.log.20150819
314
323
  - test/dummy/log/extface/229906743/fp550.log.20150519
315
324
  - test/dummy/log/extface/229906743/fp550.log
316
325
  - test/dummy/log/extface/229906743/fp550.log.20151218
317
326
  - test/dummy/log/extface/229906743/fp550.log.20160829
327
+ - test/dummy/log/extface/229906743/fp550.log.20170327
318
328
  - test/dummy/log/development.log
319
329
  - test/dummy/log/test.log
320
330
  - test/dummy/db/development.sqlite3
@@ -364,6 +374,7 @@ test_files:
364
374
  - test/models/extface/driver/daisy_fx1200_test.rb
365
375
  - test/models/extface/driver/star_tsp200_test.rb
366
376
  - test/models/extface/driver/datecs/fp550_test.rb
377
+ - test/models/extface/driver/datecs/dp25_test.rb
367
378
  - test/models/extface/serial_config_test.rb
368
379
  - test/models/extface/device_test.rb
369
380
  - test/models/extface/driver_test.rb