Method: OpenC3::BurstProtocol#write_data

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

#write_data(data, extra = nil) ⇒ String

Called to perform modifications on write data before sending it to the interface

Parameters:

  • data (String)

    Raw packet data

Returns:

  • (String)

    Potentially modified packet data



119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/openc3/interfaces/protocols/burst_protocol.rb', line 119

def write_data(data, extra = nil)
  # If we're filling the sync pattern and discarding the leading bytes
  # during a read then we need to put them back during a write.
  # If we're discarding the bytes then by definition they can't be part
  # of the packet so we just modify the data.
  if @fill_fields && @discard_leading_bytes > 0
    data = ("\x00" * @discard_leading_bytes) << data
    if @sync_pattern
      BinaryAccessor.write(@sync_pattern, 0, @sync_pattern.length * 8, :BLOCK,
                           data, :BIG_ENDIAN, :ERROR)
    end
  end
  return super(data, extra)
end