Method: OpenC3::PreidentifiedProtocol#write_data

Defined in:
lib/openc3/interfaces/protocols/preidentified_protocol.rb

#write_data(data) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/openc3/interfaces/protocols/preidentified_protocol.rb', line 75

def write_data(data)
  data_length = [data.length].pack('N') # UINT32
  data_to_send = ''
  data_to_send << @sync_pattern if @sync_pattern
  if @mode == 4 # COSMOS4.3+ Protocol
    data_to_send << @write_flags
    if @write_extra
      data_to_send << [@write_extra.length].pack('N')
      data_to_send << @write_extra
    end
  end
  data_to_send << @write_time_seconds
  data_to_send << @write_time_microseconds
  data_to_send << @write_target_name.length
  data_to_send << @write_target_name
  data_to_send << @write_packet_name.length
  data_to_send << @write_packet_name
  data_to_send << data_length
  data_to_send << data
  return data_to_send
end