somfy_sdn 1.0.9 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b76beaca35ebf0ae0847fc75bf0fcd12c45e395768cca0c711557b167488e3e
4
- data.tar.gz: 64dfc392ef651d1afc6e6a94c8c586e1e95e575c0ff9ba12c74f472cbfe88874
3
+ metadata.gz: 57ade06be997d5f36fa76aa13c87aa00e26b1bfe07de7a7fd29b9015f249a1a3
4
+ data.tar.gz: '03462586cabf999666ac43e83036811b8a10df15515ea17d7bfd7b4d2e421e3a'
5
5
  SHA512:
6
- metadata.gz: 87a1138187217fb8bf7fe62e00f69e20b742d2527d4f0059b9a2d4ba42012c887947608fdbfad4123400a0968d99d9c257cb361025ecef668786d34b708a0512
7
- data.tar.gz: e6ddbe689d8d60d252c24a1291893b05040a638ba3b86ac3a7bc1c28479a9ccdf0485e5914035818c50e1005b076d148263916ae1e7a66e05efdb075786d1d95
6
+ metadata.gz: '00080b23f47bd5c11c13406d818feec587c744b132cb1b1f4cbd57f3a64cd002c0747e4bccb575315e996b7ec7b92d736a5892116c31b277f85fcbf83fd36c6f'
7
+ data.tar.gz: '01700481ff1ed2966a00287c5c9f1193b600b56518ce36da8a06dae4768daa51fac0da4635993b9eb3daf6ea8a0f068f3e8fd7aee5bd9977e3350eb46aa58d6a'
@@ -270,6 +270,7 @@ module SDN
270
270
  @mutex.synchronize do
271
271
  # got woken up early by another command getting queued; spin
272
272
  if @response_pending
273
+ puts "another message queued, but we're still waiting"
273
274
  while @response_pending
274
275
  remaining_wait = @response_pending - Time.now.to_f
275
276
  if remaining_wait < 0
@@ -282,17 +283,20 @@ module SDN
282
283
  @prior_message = nil
283
284
  end
284
285
  else
286
+ puts "waiting #{remaining_wait} more..."
285
287
  @cond.wait(@mutex, remaining_wait)
286
288
  end
287
289
  end
288
290
  else
289
291
  # minimum time between messages
292
+ puts "waiting between messages"
290
293
  sleep 0.1
291
294
  end
292
295
 
296
+ puts "looking for next message to write"
293
297
  @queues.find { |q| message_and_retries = q.shift }
294
298
  if message_and_retries
295
- if message_and_retries.message.ack_requested || message_and_retries.class.name =~ /^SDN::Message::Get/
299
+ if message_and_retries.message.ack_requested || message_and_retries.message.class.name =~ /^SDN::Message::Get/
296
300
  @response_pending = Time.now.to_f + WAIT_TIME
297
301
  if message_and_retries.message.dest == BROADCAST_ADDRESS || SDN::Message::is_group_address?(message_and_retries.message.src) && message_and_retries.message.is_a?(SDN::Message::GetNodeAddr)
298
302
  @broadcast_pending = Time.now.to_f + BROADCAST_WAIT
@@ -301,22 +305,24 @@ module SDN
301
305
  end
302
306
 
303
307
  # wait until there is a message
304
- @cond.wait(@mutex) unless message_and_retries
308
+ if @response_pending
309
+ message_and_retries.remaining_retries -= 1
310
+ @prior_message = message_and_retries
311
+ elsif message_and_retries
312
+ @prior_message = nil
313
+ else
314
+ @cond.wait(@mutex)
315
+ end
305
316
  end
306
317
  next unless message_and_retries
307
318
 
308
319
  message = message_and_retries.message
309
320
  puts "writing #{message.inspect}"
321
+ puts "(and waiting for response)" if @response_pending
310
322
  serialized = message.serialize
311
323
  @sdn.write(serialized)
312
324
  @sdn.flush
313
325
  puts "wrote #{serialized.unpack("C*").map { |b| '%02x' % b }.join(' ')}"
314
- if @response_pending
315
- message_and_retries.remaining_retries -= 1
316
- @prior_message = message_and_retries
317
- else
318
- @prior_message = nil
319
- end
320
326
  end
321
327
  rescue => e
322
328
  puts "failure writing: #{e}"
@@ -416,9 +422,9 @@ module SDN
416
422
  nil
417
423
  end
418
424
  if message
419
- message.ack_requested = true if motor && message.class.name !~ /^SDN::Message::Get/
425
+ message.ack_requested = true if message.class.name !~ /^SDN::Message::Get/
420
426
  @mutex.synchronize do
421
- @queues[0].push(MessageAndRetries.new(message, message.ack_requested ? 5 : 1, 0))
427
+ @queues[0].push(MessageAndRetries.new(message, 5, 0))
422
428
  @queues[1].push(MessageAndRetries.new(follow_up, 5, 1)) unless @queues[1].any? { |mr| mr.message == follow_up }
423
429
  @cond.signal
424
430
  end
@@ -1,3 +1,3 @@
1
1
  module SDN
2
- VERSION = '1.0.9'
2
+ VERSION = '1.0.10'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: somfy_sdn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer