Class: TxFrame

Inherits:
Frame show all
Defined in:
lib/hamnet.rb

Overview

This defines a frame to be transmitted using fldigi. You need to supply the originating call sign (from), the destination call sign (to), the type of frame (see constants above), and the actual data to be transmitted.

Instance Attribute Summary collapse

Attributes inherited from Frame

#valid

Instance Method Summary collapse

Methods inherited from Frame

#to_s

Constructor Details

#initialize(from, to, type, userdata) ⇒ TxFrame

Returns a new instance of TxFrame.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/hamnet.rb', line 63

def initialize(from, to, type, userdata)
  # Create the object.
  super(from, to, type)
  @userdata=userdata

  # Do the needful with the payload.
  case @type
  when FRAME_SIMPLE
    message=@from+@to+@type.to_s+@userdata
    @crc=Zlib::crc32(message).to_s(16).downcase
  when FRAME_BASE64
    message=@from+@to+@type.to_s+Base64::strict_encode64(@userdata)
    @crc=Zlib::crc32(message).to_s(16).downcase
  when FRAME_COMPRESSED_BASE64
    message=@from+@to+@type.to_s+Base64::strict_encode64(Zlib::Deflate.deflate(@userdata,Zlib::BEST_COMPRESSION))
    @crc=Zlib::crc32(message).to_s(16).downcase
  else
    return false
  end

  # Set the rest of the fields, and done.
  @wiredata="<<<#{message}#{@crc}>>>"
  @valid=true
end

Instance Attribute Details

#fromObject

Returns the value of attribute from.



61
62
63
# File 'lib/hamnet.rb', line 61

def from
  @from
end

#toObject

Returns the value of attribute to.



61
62
63
# File 'lib/hamnet.rb', line 61

def to
  @to
end

#typeObject

Returns the value of attribute type.



61
62
63
# File 'lib/hamnet.rb', line 61

def type
  @type
end

#userdataObject

Returns the value of attribute userdata.



61
62
63
# File 'lib/hamnet.rb', line 61

def userdata
  @userdata
end

#wiredataObject

Returns the value of attribute wiredata.



61
62
63
# File 'lib/hamnet.rb', line 61

def wiredata
  @wiredata
end