extface 0.4.3g → 0.4.4a
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/extface/driver/datecs/commands_v1.rb +2 -1
- data/app/models/extface/driver/datecs/fp550.rb +43 -3
- data/lib/extface/version.rb +1 -1
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/extface/229906743/fp550.log +12 -0
- data/test/dummy/log/extface/229906743/fp550.log.20150519 +35 -0
- data/test/dummy/log/test.log +2031 -0
- data/test/fixtures/extface/devices.yml +1 -1
- data/test/models/extface/driver/datecs/fp550_test.rb +9 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43caaf09fdef3c71d0adcab6345f04686fbe9797
|
4
|
+
data.tar.gz: f2dec73772e0a27eba21492b16ff303d6e2dce3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba2a0b28a2d63bc5779663a6887719230ef3c68ad9f413e73f8f8a065640bc01369ec7b3b4ffb7bf96c3d98c5f6d9b2eecd3ef63ac5faa75f06f67a7374ac9c6
|
7
|
+
data.tar.gz: 20783a589d47e8823e2c32b3881b7c9c162deee756a1c58e8dec3c449f1d01c3bd4298089a01c6d778826c9d8726199e5f285505f7d5aede1c35f97d25f323dd
|
@@ -1,6 +1,11 @@
|
|
1
1
|
module Extface
|
2
2
|
class Driver::Datecs::Fp550 < Extface::Driver::Base::Fiscal
|
3
3
|
NAME = 'Datecs FP550 (Serial)'.freeze
|
4
|
+
|
5
|
+
RESPONSE_TIMEOUT = 3 #seconds
|
6
|
+
INVALID_FRAME_RETRIES = 6 #count (bad length, bad checksum)
|
7
|
+
ACKS_MAX_WAIT = 60 #count / nothing is forever
|
8
|
+
NAKS_MAX_COUNT = 3 #count
|
4
9
|
|
5
10
|
include Extface::Driver::Datecs::CommandsV1
|
6
11
|
|
@@ -19,14 +24,49 @@ module Extface
|
|
19
24
|
|
20
25
|
def fsend(cmd, data = "") #return data or nil
|
21
26
|
packet_data = build_packet(cmd, data) #store packet to be able to re-transmit it with the same sequence number
|
27
|
+
p packet_data
|
22
28
|
invalid_frames = 0 #counter for bad responses
|
23
29
|
nak_messages = 0 #counter for rejected packets (should re-transmit the packet)
|
24
30
|
push packet_data #send packet
|
25
|
-
|
26
|
-
errors.clear
|
31
|
+
ACKS_MAX_WAIT.times do |retries|
|
32
|
+
errors.clear
|
27
33
|
if resp = frecv(RESPONSE_TIMEOUT)
|
28
|
-
|
34
|
+
if resp.valid?
|
35
|
+
human_status_errors(resp.status)
|
36
|
+
if errors.empty?
|
37
|
+
result = resp.data
|
38
|
+
break
|
39
|
+
else
|
40
|
+
raise errors.full_messages.join(',')
|
41
|
+
end
|
42
|
+
else #ack, nak or bad
|
43
|
+
if resp.nak?
|
44
|
+
nak_messages += 1
|
45
|
+
if nak_messages > NAKS_MAX_COUNT
|
46
|
+
errors.add :base, "#{NAKS_MAX_COUNT} NAKs Received. Abort!"
|
47
|
+
break
|
48
|
+
end
|
49
|
+
elsif !resp.ack?
|
50
|
+
invalid_frames += 1
|
51
|
+
if nak_messages > INVALID_FRAME_RETRIES
|
52
|
+
errors.add :base, "#{INVALID_FRAME_RETRIES} Broken Packets Received. Abort!"
|
53
|
+
break
|
54
|
+
end
|
55
|
+
end
|
56
|
+
push packet_data unless resp.ack?
|
57
|
+
end
|
29
58
|
end
|
59
|
+
errors.add :base, "#{ACKS_MAX_WAIT} ACKs Received. Abort!"
|
60
|
+
end
|
61
|
+
return result
|
62
|
+
end
|
63
|
+
|
64
|
+
def frecv(timeout) # return RespFrame or nil
|
65
|
+
if frame_bytes = pull(timeout)
|
66
|
+
return Frame.new(frame_bytes.b)
|
67
|
+
else
|
68
|
+
errors.add :base, "No data received from device"
|
69
|
+
return nil
|
30
70
|
end
|
31
71
|
end
|
32
72
|
|
data/lib/extface/version.rb
CHANGED
Binary file
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Logfile created on 2015-05-20 00:00:00 -0400 by logger.rb/44203
|
2
|
+
D, [2015-05-20T00:00:00.879764 #12792] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
3
|
+
D, [2015-05-20T00:00:01.864476 #12792] DEBUG -- : <-- 01 2C 2F 2D 50 04 88 80 C0 80 80 B0 05 30 34 35 39 03
|
4
|
+
D, [2015-05-20T00:00:10.882294 #12792] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
5
|
+
D, [2015-05-20T00:02:23.587163 #13078] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
6
|
+
D, [2015-05-20T00:02:33.590490 #13078] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
7
|
+
D, [2015-05-20T00:05:57.424966 #13165] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
8
|
+
D, [2015-05-20T00:06:07.427669 #13165] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
9
|
+
D, [2015-05-20T00:11:16.034082 #13292] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
10
|
+
D, [2015-05-20T00:11:26.037421 #13292] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
11
|
+
D, [2015-05-20T00:12:25.752623 #13380] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
12
|
+
D, [2015-05-20T00:12:35.754555 #13380] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Logfile created on 2015-05-19 22:59:30 -0400 by logger.rb/44203
|
2
|
+
D, [2015-05-19T22:59:30.658269 #10838] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
3
|
+
D, [2015-05-19T22:59:55.365866 #10885] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
4
|
+
D, [2015-05-19T23:00:20.737954 #10907] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
5
|
+
D, [2015-05-19T23:01:26.204288 #11164] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
6
|
+
D, [2015-05-19T23:02:17.076246 #11214] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
7
|
+
D, [2015-05-19T23:06:50.204981 #11281] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
8
|
+
D, [2015-05-19T23:07:00.208062 #11281] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
9
|
+
D, [2015-05-19T23:07:44.339216 #11342] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
10
|
+
D, [2015-05-19T23:07:54.339477 #11342] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
11
|
+
D, [2015-05-19T23:12:02.585579 #11504] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
12
|
+
D, [2015-05-19T23:12:12.588779 #11504] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
13
|
+
D, [2015-05-19T23:15:46.061884 #11666] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
14
|
+
D, [2015-05-19T23:15:56.065033 #11666] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
15
|
+
D, [2015-05-19T23:41:07.590433 #11886] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
16
|
+
D, [2015-05-19T23:41:17.593311 #11886] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
17
|
+
D, [2015-05-19T23:42:31.054832 #11946] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
18
|
+
D, [2015-05-19T23:42:41.057203 #11946] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
19
|
+
D, [2015-05-19T23:42:56.689245 #12020] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
20
|
+
D, [2015-05-19T23:43:06.693098 #12020] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
21
|
+
D, [2015-05-19T23:43:26.845881 #12084] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
22
|
+
D, [2015-05-19T23:43:36.849264 #12084] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
23
|
+
D, [2015-05-19T23:44:09.732492 #12252] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
24
|
+
D, [2015-05-19T23:44:19.737048 #12252] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
25
|
+
D, [2015-05-19T23:45:43.240522 #12319] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
26
|
+
D, [2015-05-19T23:45:53.244373 #12319] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
27
|
+
D, [2015-05-19T23:49:43.189449 #12417] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
28
|
+
D, [2015-05-19T23:49:53.191849 #12417] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
29
|
+
D, [2015-05-19T23:52:59.669476 #12496] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
30
|
+
D, [2015-05-19T23:53:09.672390 #12496] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
31
|
+
D, [2015-05-19T23:58:14.389146 #12604] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
32
|
+
D, [2015-05-19T23:58:58.939983 #12673] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
33
|
+
D, [2015-05-19T23:59:21.566720 #12709] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
34
|
+
D, [2015-05-19T23:59:41.826274 #12745] DEBUG -- : --> 01 25 20 4A 58 05 30 30 3E 3C 03
|
35
|
+
D, [2015-05-19T23:59:42.807515 #12745] DEBUG -- : <-- 01 2C 2F 2D 50 04 88 80 C0 80 80 B0 05 30 34 35 39 03
|