-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1454 from OpenC3/item_offset
Fix offset when appending items
- Loading branch information
Showing
18 changed files
with
382 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# encoding: ascii-8bit | ||
|
||
# Copyright 2024 OpenC3, Inc. | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can modify and/or redistribute it | ||
# under the terms of the GNU Affero General Public License | ||
# as published by the Free Software Foundation; version 3 with | ||
# attribution addendums as found in the LICENSE.txt | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# This file may also be used under the terms of a commercial license | ||
# if purchased from OpenC3, Inc. | ||
|
||
require 'openc3/conversions/conversion' | ||
|
||
module OpenC3 | ||
class BitReverseConversion < Conversion | ||
def initialize(converted_type, converted_bit_size) | ||
@converted_type = converted_type.to_s.upcase.intern | ||
@converted_bit_size = converted_bit_size.to_i | ||
@converted_array_size = nil | ||
if @converted_data_type == :FLOAT | ||
raise "Float Bit Reverse Not Yet Supported" | ||
end | ||
end | ||
|
||
# Perform the conversion on the value. | ||
# | ||
# @param value [Object] The value to convert | ||
# @param packet [Packet] The packet which contains the value. This can | ||
# be useful to reach into the packet and use other values in the | ||
# conversion. | ||
# @param buffer [String] The packet buffer | ||
# @return The converted value | ||
def call(value, _packet, _buffer) | ||
reversed = 0 | ||
@converted_bit_size.times do | ||
reversed = (reversed << 1) | (value & 1) | ||
value >>= 1 | ||
end | ||
return reversed & ((2 ** @converted_bit_size) - 1) | ||
end | ||
|
||
# @return [String] The conversion class | ||
def to_s | ||
"#{self.class.to_s.split('::')[-1]}.new(#{@converted_type}, #{@converted_bit_size})" | ||
end | ||
|
||
# @param read_or_write [String] Either 'READ' or 'WRITE' | ||
# @return [String] Config fragment for this conversion | ||
def to_config(read_or_write) | ||
" #{read_or_write}_CONVERSION #{self.class.name.class_name_to_filename} #{@converted_type} #{@converted_bit_size}\n" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# encoding: ascii-8bit | ||
|
||
# Copyright 2024 OpenC3, Inc. | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can modify and/or redistribute it | ||
# under the terms of the GNU Affero General Public License | ||
# as published by the Free Software Foundation; version 3 with | ||
# attribution addendums as found in the LICENSE.txt | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# This file may also be used under the terms of a commercial license | ||
# if purchased from OpenC3, Inc. | ||
|
||
require 'openc3/conversions/conversion' | ||
|
||
module OpenC3 | ||
class IpReadConversion < Conversion | ||
def initialize | ||
@converted_type = :STRING | ||
@converted_bit_size = 120 | ||
@converted_array_size = nil | ||
end | ||
|
||
# Perform the conversion on the value. | ||
# | ||
# @param value [Object] The value to convert | ||
# @param packet [Packet] The packet which contains the value. This can | ||
# be useful to reach into the packet and use other values in the | ||
# conversion. | ||
# @param buffer [String] The packet buffer | ||
# @return The converted value | ||
def call(value, _packet, _buffer) | ||
byte4 = (value & 0xFF) | ||
value = value >> 8 | ||
byte3 = (value & 0xFF) | ||
value = value >> 8 | ||
byte2 = (value & 0xFF) | ||
value = value >> 8 | ||
byte1 = (value & 0xFF) | ||
return "#{byte1}.#{byte2}.#{byte3}.#{byte4}" | ||
end | ||
|
||
# @return [String] The conversion class | ||
def to_s | ||
"#{self.class.to_s.split('::')[-1]}.new" | ||
end | ||
|
||
# @param read_or_write [String] Either 'READ' or 'WRITE' | ||
# @return [String] Config fragment for this conversion | ||
def to_config(read_or_write) | ||
" #{read_or_write}_CONVERSION #{self.class.name.class_name_to_filename}\n" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# encoding: ascii-8bit | ||
|
||
# Copyright 2024 OpenC3, Inc. | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can modify and/or redistribute it | ||
# under the terms of the GNU Affero General Public License | ||
# as published by the Free Software Foundation; version 3 with | ||
# attribution addendums as found in the LICENSE.txt | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# This file may also be used under the terms of a commercial license | ||
# if purchased from OpenC3, Inc. | ||
|
||
require 'openc3/conversions/conversion' | ||
|
||
module OpenC3 | ||
class IpWriteConversion < Conversion | ||
def initialize | ||
@converted_type = :UINT | ||
@converted_bit_size = 32 | ||
@converted_array_size = nil | ||
end | ||
|
||
# Perform the conversion on the value. | ||
# | ||
# @param value [Object] The value to convert | ||
# @param packet [Packet] The packet which contains the value. This can | ||
# be useful to reach into the packet and use other values in the | ||
# conversion. | ||
# @param buffer [String] The packet buffer | ||
# @return The converted value | ||
def call(value, _packet, _buffer) | ||
bytes = value.split('.') | ||
result = 0 | ||
result += Integer(bytes[0]) | ||
result = result << 8 | ||
result += Integer(bytes[1]) | ||
result = result << 8 | ||
result += Integer(bytes[2]) | ||
result = result << 8 | ||
result += Integer(bytes[3]) | ||
return result | ||
end | ||
|
||
# @return [String] The conversion class | ||
def to_s | ||
"#{self.class.to_s.split('::')[-1]}.new" | ||
end | ||
|
||
# @param read_or_write [String] Either 'READ' or 'WRITE' | ||
# @return [String] Config fragment for this conversion | ||
def to_config(read_or_write) | ||
" #{read_or_write}_CONVERSION #{self.class.name.class_name_to_filename}\n" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.