Method: Cosmos::BurstProtocol#write_data

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

#write_data(data) ⇒ String

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



101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/cosmos/interfaces/protocols/burst_protocol.rb', line 101

def write_data(data)
  # 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
  super(data)
end