Class: RxFrame
Overview
This defines a frame received using fldigi. You supply it with the frame (delimited with “<<<” and “>>>”, and it validates the frame, then creates and populates an object with the fields of that frame.
Instance Attribute Summary collapse
-
#from ⇒ Object
Returns the value of attribute from.
-
#to ⇒ Object
Returns the value of attribute to.
-
#type ⇒ Object
Returns the value of attribute type.
-
#userdata ⇒ Object
Returns the value of attribute userdata.
-
#wiredata ⇒ Object
Returns the value of attribute wiredata.
Attributes inherited from Frame
Instance Method Summary collapse
-
#initialize(wiredata) ⇒ RxFrame
constructor
A new instance of RxFrame.
Methods inherited from Frame
Constructor Details
#initialize(wiredata) ⇒ RxFrame
Returns a new instance of RxFrame.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/hamnet.rb', line 95 def initialize(wiredata) # First, make sure it's properly delimited. if wiredata=~/^<<<.*>>>$/ and wiredata.length>=31 # Remove the "<<<" and ">>>" tmp=wiredata[3,wiredata.length-6] # Extract the crc field. crc=tmp[tmp.length-8,8] tmp=tmp[0,tmp.length-8] # Save this for checking CRC later. crcstring=tmp # Extract and clean the from field. from=tmp[0,8].gsub(":","") tmp=tmp[8,tmp.length-8] # Extract and clean the to field. to=tmp[0,8].gsub(":","") tmp=tmp[8,tmp.length-8] # Extract the frame type. type=tmp[0,1].to_i tmp=tmp[1,tmp.length-1] # Create and populate the object. super(from, to, type) @wiredata=wiredata # Decode the payload. case @type when FRAME_SIMPLE @userdata=tmp when FRAME_BASE64 @userdata=Base64::strict_decode64(tmp) when FRAME_COMPRESSED_BASE64 @userdata=Zlib::Inflate.inflate(Base64::strict_decode64(tmp)) end # Calculate the check the CRC. @crc=Zlib::crc32(crcstring).to_s(16).downcase if crc==@crc @valid=true end else return false end end |
Instance Attribute Details
#from ⇒ Object
Returns the value of attribute from.
93 94 95 |
# File 'lib/hamnet.rb', line 93 def from @from end |
#to ⇒ Object
Returns the value of attribute to.
93 94 95 |
# File 'lib/hamnet.rb', line 93 def to @to end |
#type ⇒ Object
Returns the value of attribute type.
93 94 95 |
# File 'lib/hamnet.rb', line 93 def type @type end |
#userdata ⇒ Object
Returns the value of attribute userdata.
93 94 95 |
# File 'lib/hamnet.rb', line 93 def userdata @userdata end |
#wiredata ⇒ Object
Returns the value of attribute wiredata.
93 94 95 |
# File 'lib/hamnet.rb', line 93 def wiredata @wiredata end |