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

#frompad, #topad, #valid

Instance Method Summary collapse

Methods inherited from Frame

#to_s

Constructor Details

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

Returns a new instance of TxFrame.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/hamnet.rb', line 77

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

  sendtype=type
  if @done or @type==HAMNET_FRAME_ACK or @type==HAMNET_FRAME_PING or @type==HAMNET_FRAME_PING_REPLY
    sendtype=(sendtype|128)
  end

  # Do the needful with the payload.
  case @type
  when HAMNET_FRAME_PING
    message=@frompad+@topad+sprintf("%02x",sendtype).downcase+sprintf("%02x",@sequence).downcase
  when HAMNET_FRAME_PING_REPLY
    message=@frompad+@topad+sprintf("%02x",sendtype).downcase+sprintf("%02x",@sequence).downcase+@userdata
  when HAMNET_FRAME_ACK
    message=@frompad+@topad+sprintf("%02x",sendtype).downcase+sprintf("%02x",@sequence).downcase
  when HAMNET_FRAME_SIMPLE
    message=@frompad+@topad+sprintf("%02x",sendtype).downcase+sprintf("%02x",@sequence).downcase+@userdata
  when HAMNET_FRAME_BASE64
    message=@frompad+@topad+sprintf("%02x",sendtype).downcase+sprintf("%02x",@sequence).downcase+Base64::strict_encode64(@userdata)
  when HAMNET_FRAME_COMPRESSED_BASE64
    message=@frompad+@topad+sprintf("%02x",sendtype).downcase+sprintf("%02x",@sequence).downcase+Base64::strict_encode64(Zlib::Deflate.deflate(@userdata,Zlib::BEST_COMPRESSION))
  else
    return false
  end

  # Calculate the CRC.
  @crc=sprintf("%08x",Zlib::crc32(message)).downcase

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

Instance Attribute Details

#doneObject

Returns the value of attribute done.



75
76
77
# File 'lib/hamnet.rb', line 75

def done
  @done
end

#fromObject

Returns the value of attribute from.



75
76
77
# File 'lib/hamnet.rb', line 75

def from
  @from
end

#sequenceObject

Returns the value of attribute sequence.



75
76
77
# File 'lib/hamnet.rb', line 75

def sequence
  @sequence
end

#toObject

Returns the value of attribute to.



75
76
77
# File 'lib/hamnet.rb', line 75

def to
  @to
end

#typeObject

Returns the value of attribute type.



75
76
77
# File 'lib/hamnet.rb', line 75

def type
  @type
end

#userdataObject

Returns the value of attribute userdata.



75
76
77
# File 'lib/hamnet.rb', line 75

def userdata
  @userdata
end

#wiredataObject

Returns the value of attribute wiredata.



75
76
77
# File 'lib/hamnet.rb', line 75

def wiredata
  @wiredata
end