Class: Crubyflie::RadioAck
- Inherits:
-
Object
- Object
- Crubyflie::RadioAck
- Defined in:
- lib/crubyflie/crazyradio/radio_ack.rb
Overview
An acknowlegdement packet from the Crazyflie
Instance Attribute Summary collapse
-
#ack ⇒ Object
Returns the value of attribute ack.
-
#data ⇒ Object
Returns the value of attribute data.
-
#powerDet ⇒ Object
Returns the value of attribute powerDet.
-
#retry_count ⇒ Object
Returns the value of attribute retry_count.
Class Method Summary collapse
-
.from_raw(data, arc = 0) ⇒ RadioAck
Create from raw usb response.
Instance Method Summary collapse
-
#initialize(ack = nil, powerDet = nil, retry_count = 0, data = []) ⇒ RadioAck
constructor
Initialize a Radio Ack.
Constructor Details
#initialize(ack = nil, powerDet = nil, retry_count = 0, data = []) ⇒ RadioAck
Initialize a Radio Ack
29 30 31 32 33 34 |
# File 'lib/crubyflie/crazyradio/radio_ack.rb', line 29 def initialize(ack=nil, powerDet=nil, retry_count=0, data=[]) @ack = ack @powerDet = powerDet @retry_count = retry_count @data = data end |
Instance Attribute Details
#ack ⇒ Object
Returns the value of attribute ack.
22 23 24 |
# File 'lib/crubyflie/crazyradio/radio_ack.rb', line 22 def ack @ack end |
#data ⇒ Object
Returns the value of attribute data.
22 23 24 |
# File 'lib/crubyflie/crazyradio/radio_ack.rb', line 22 def data @data end |
#powerDet ⇒ Object
Returns the value of attribute powerDet.
22 23 24 |
# File 'lib/crubyflie/crazyradio/radio_ack.rb', line 22 def powerDet @powerDet end |
#retry_count ⇒ Object
Returns the value of attribute retry_count.
22 23 24 |
# File 'lib/crubyflie/crazyradio/radio_ack.rb', line 22 def retry_count @retry_count end |
Class Method Details
.from_raw(data, arc = 0) ⇒ RadioAck
Create from raw usb response
39 40 41 42 43 44 45 46 |
# File 'lib/crubyflie/crazyradio/radio_ack.rb', line 39 def self.from_raw(data, arc=0) response = data.unpack('C*') header = response.shift() ack = (header & 0x01) != 0 powerDet = (header & 0x02) != 0 retry_count = header != 0 ? header >> 4 : arc return RadioAck.new(ack, powerDet, retry_count, response) end |