app/models/extface/driver/datecs/fp550.rb in extface-0.5.0 vs app/models/extface/driver/datecs/fp550.rb in extface-0.5.1

- old
+ new

@@ -5,10 +5,11 @@ RESPONSE_TIMEOUT = 3 #seconds INVALID_FRAME_RETRIES = 6 #count (bad length, bad checksum) ACKS_MAX_WAIT = 60 #count / nothing is forever NAKS_MAX_COUNT = 3 #count BAD_SEQ_MAX_COUNT = 3 + NO_RESP_MAX_COUNT = 3 TAX_GROUPS_MAP = { 1 => "\xc0", 2 => "\xc1", 3 => "\xc2", @@ -171,10 +172,12 @@ def fsend(cmd, data = "") #return data or nil packet_data = build_packet(cmd, data) #store packet to be able to re-transmit it with the same sequence number result = false invalid_frames = 0 #counter for bad responses nak_messages = 0 #counter for rejected packets (should re-transmit the packet) + no_resp = 0 + flush #prevent double packet response issue like daisy driver push packet_data #send packet ACKS_MAX_WAIT.times do |retries| errors.clear if resp = frecv(RESPONSE_TIMEOUT) if resp.valid? @@ -198,9 +201,16 @@ errors.add :base, "#{INVALID_FRAME_RETRIES} Broken Packets Received. Abort!" break end end push packet_data unless resp.ack? + end + else + no_resp += 1 + if no_resp > NO_RESP_MAX_COUNT + p "No reply in #{NO_RESP_MAX_COUNT * RESPONSE_TIMEOUT} seconds. Abort!" + errors.add :base, "No reply in #{NO_RESP_MAX_COUNT * RESPONSE_TIMEOUT} seconds. Abort!" + return result end end errors.add :base, "#{ACKS_MAX_WAIT} ACKs Received. Abort!" end return result \ No newline at end of file