Class: XBee::Frame::Base
- Inherits:
-
Object
- Object
- XBee::Frame::Base
- Defined in:
- lib/apimode/frame/frame.rb
Direct Known Subclasses
ATCommand, ExplicitAddressingCommand, ReceivedFrame, TransmitRequest
Instance Attribute Summary collapse
-
#api_identifier ⇒ Object
Returns the value of attribute api_identifier.
-
#cmd_data ⇒ Object
Returns the value of attribute cmd_data.
-
#frame_id ⇒ Object
Returns the value of attribute frame_id.
Instance Method Summary collapse
Instance Attribute Details
#api_identifier ⇒ Object
Returns the value of attribute api_identifier.
113 114 115 |
# File 'lib/apimode/frame/frame.rb', line 113 def api_identifier @api_identifier end |
#cmd_data ⇒ Object
Returns the value of attribute cmd_data.
113 114 115 |
# File 'lib/apimode/frame/frame.rb', line 113 def cmd_data @cmd_data end |
#frame_id ⇒ Object
Returns the value of attribute frame_id.
113 114 115 |
# File 'lib/apimode/frame/frame.rb', line 113 def frame_id @frame_id end |
Instance Method Details
#_dump(api_mode = :API1) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/apimode/frame/frame.rb', line 125 def _dump(api_mode = :API1) unless api_mode == :API1 or api_mode == :API2 raise "XBee api_mode must be either :API1 (non-escaped) or :API2 (escaped, default)" end raise "Too much data (#{self.length} bytes) to fit into one frame!" if (self.length > 0xFFFF) if (api_mode == :API1) "~" + [length].pack("n") + data + [Frame.checksum(data)].pack("C") elsif (api_mode == :API2) "~" + [length].pack("n").xb_escape + data.xb_escape + [Frame.checksum(data)].pack("C") end end |
#data ⇒ Object
121 122 123 |
# File 'lib/apimode/frame/frame.rb', line 121 def data Array(api_identifier).pack("C") + cmd_data end |
#length ⇒ Object
119 |
# File 'lib/apimode/frame/frame.rb', line 119 def length ; data.length ; end |