extface 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b4af1253c55c88d821b794698c562d77438ea05
4
- data.tar.gz: 65742b57205bea9b06f7ab0d3ad0143412437880
3
+ metadata.gz: 072e5c6b5a572bdd5923665bc0c2b8ffdbfdf1b7
4
+ data.tar.gz: debb2db3bbf533b53ad877885c8700a234e3dba8
5
5
  SHA512:
6
- metadata.gz: 8facf9db5877c6102d22da94fe1fb4631af1835558fd0f573c1df81fd329fe52e12c5b4368191fad8e6e59e4f65f3369372a64069bd8048f0afb6806c7a63d7e
7
- data.tar.gz: 078de35e90e207440b1ece29bf390848663f8078d3180f1f19bb75e00e948d2d9e50567c423c3e708c0088b543520be52900160a1971da667d2231ef33a57bbc
6
+ metadata.gz: 9d14136598dab6955c64c02db5a84ac152ab278d7b648f3a64a9d9e5a2732c4e84f19150c17ae03e1e8d93e9ff163dca101f92d0720066362acfd2d53c452e13
7
+ data.tar.gz: 23d3e25b9594ceeec6984f1072bd1adc86602bea2c401e7b3254786d1f980d5c7b363e21ed9e4b6f464774a7acf8c6ca517eeb4dfcfe3f5fa2945e6eb1a4b5c3
@@ -19,7 +19,7 @@ module Extface
19
19
 
20
20
  RESPONSE_TIMEOUT = 3 #seconds
21
21
  INVALID_FRAME_RETRIES = 6 #count
22
- BUSY_WAIT_CYCLES = 12 #count
22
+ BUSY_MAX_WAIT_CYCLES = 60 #count
23
23
 
24
24
  FLAG_TRUE = "\xff\xff"
25
25
  FLAG_FALSE = "\x00\x00"
@@ -189,14 +189,26 @@ module Extface
189
189
  end
190
190
 
191
191
  def fsend(cmd, data = "") #return data or nil
192
- packet_data = build_packet(cmd, data)
193
192
  result = false
194
- BUSY_WAIT_CYCLES.times do |retries|
193
+ status_invalid_responses = 0
194
+ BUSY_MAX_WAIT_CYCLES.times do |retries|
195
+ errors.clear
195
196
  push build_packet(Info::GET_STATUS)
196
- if status = frecv(RESPONSE_TIMEOUT)
197
- break if status.ready?
197
+ if stat_frame = frecv(RESPONSE_TIMEOUT)
198
+ if stat_frame.valid?
199
+ break if stat_frame.ready?
200
+ else
201
+ status_invalid_responses -= 1
202
+ unless status_invalid_responses < INVALID_FRAME_RETRIES
203
+ errors.add :base, "#{INVALID_FRAME_RETRIES} Broken Packets Received. Abort!"
204
+ end
205
+ end
198
206
  end
207
+ errors.add :base, "#{BUSY_MAX_WAIT_CYCLES} Busy Packets Received. Abort!"
199
208
  end
209
+ return(result) if errors.any?
210
+
211
+ packet_data = build_packet(cmd, data)
200
212
  INVALID_FRAME_RETRIES.times do |retries|
201
213
  errors.clear
202
214
  push packet_data
@@ -278,6 +290,7 @@ module Extface
278
290
  end
279
291
 
280
292
  def response_code_validation
293
+ p "############################### #{cmd.ord.to_s(16)}"
281
294
  case cmd.ord
282
295
  when 0x2c then
283
296
  case data[0] # printer error code
@@ -1,3 +1,3 @@
1
1
  module Extface
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  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.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Vangelov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-29 00:00:00.000000000 Z
11
+ date: 2014-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails