diff --git a/docs.openc3.com/docs/configuration/_command.md b/docs.openc3.com/docs/configuration/_command.md
index 422a347b26..6cc67ead1e 100644
--- a/docs.openc3.com/docs/configuration/_command.md
+++ b/docs.openc3.com/docs/configuration/_command.md
@@ -18,7 +18,7 @@ The COSMOS front end provides multiple ways to send commands. They can come from
Command definition files define the command packets that can be sent to COSMOS targets. One large file can be used to define the command packets, or multiple files can be used at the user's discretion. Command definition files are placed in the target's cmd_tlm directory and are processed alphabetically. Therefore if you have some command files that depend on others, e.g. they override or extend existing commands, they must be named last. The easiest way to do this is to add an extension to an existing file name. For example, if you already have cmd.txt you can create cmd_override.txt for commands that depends on the definitions in cmd.txt. Also note that due to the way the [ASCII Table](http://www.asciitable.com/) is structured, files beginning with capital letters are processed before lower case letters.
-When defining command parameters you can choose from the following data types: INT, UINT, FLOAT, STRING, BLOCK. These correspond to integers, unsigned integers, floating point numbers, strings and binary blocks of data. The only difference between a STRING and BLOCK is when COSMOS reads the binary command log it stops reading a STRING type when it encounters a null byte (0). This shows up in the text log produced by Data Extractor. Note that this does NOT affect the data COSMOS writes as it's still legal to pass null bytes (0) in STRING parameters.
+When defining command parameters you can choose from the following data types: INT, UINT, FLOAT, STRING, BLOCK. These correspond to integers, unsigned integers, floating point numbers, strings and binary blocks of data. The only difference between a STRING and BLOCK is when COSMOS reads the binary command log it stops reading a STRING type when it encounters a null byte (0). This shows up in the text log produced by Data Extractor. Note that this does NOT affect the data COSMOS writes as it's still legal to pass null bytes (0) in STRING parameters. Additional data types of BOOL, ARRAY, OBJECT, and ANY are also available if you are using an Accessor that supports them. These are Booleans (true/false), arrays of unknown data type, objects with unknown contents, and a completely unknown data type with ANY.
diff --git a/docs.openc3.com/docs/configuration/_conversions.md b/docs.openc3.com/docs/configuration/_conversions.md
index 995d38c946..6af25122ae 100644
--- a/docs.openc3.com/docs/configuration/_conversions.md
+++ b/docs.openc3.com/docs/configuration/_conversions.md
@@ -37,7 +37,7 @@ from openc3.conversions.conversion import Conversion
class DoubleConversion(Conversion):
def __init__(self):
super().__init__()
- # Should be one of 'INT', 'UINT', 'FLOAT', 'STRING', 'BLOCK'
+ # Should be one of 'INT', 'UINT', 'FLOAT', 'STRING', 'BLOCK', 'BOOL', 'ARRAY', 'OBJECT', 'ANY', 'TIME'
self.converted_type = 'STRING'
# Size of the converted type in bits
# Use 0 for 'STRING' or 'BLOCK' where the size can be variable
@@ -116,7 +116,7 @@ The generic conversion is meant to be a quick and easy way to apply a conversion
| Parameter | Description | Required |
| --------- | ---------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
-| Type | Data type after the conversion is applied
Valid Values: INT, UINT, FLOAT, STRING, BLOCK, TIME | False (warning will be generated) |
+| Type | Data type after the conversion is applied
Valid Values: INT, UINT, FLOAT, STRING, BLOCK, BOOL, ARRAY, OBJECT, ANY, TIME | False (warning will be generated) |
| Size | Data size in bits after the conversion is applied | False (warning will be generated) |
diff --git a/docs.openc3.com/docs/configuration/_table.md b/docs.openc3.com/docs/configuration/_table.md
index 517cdf47eb..42b11b998d 100644
--- a/docs.openc3.com/docs/configuration/_table.md
+++ b/docs.openc3.com/docs/configuration/_table.md
@@ -13,7 +13,7 @@ sidebar_custom_props:
Table definition files define the binary tables that can be displayed in COSMOS [Table Manager](../tools/table-manager.md)
. Table definitions are defined in the target's tables/config directory and are typically named after the table such as `PPSSelectionTable_def.txt`. The `_def.txt` extension helps to identify the file as a table definition. Table definitions can be combined using the `TABLEFILE` keyword. This allows you to build individual table components into a larger binary.
-The Table definition files share a lot of similarity with the [Command Configuration](command.md). You have the same data types: INT, UINT, FLOAT, STRING, BLOCK. These correspond to integers, unsigned integers, floating point numbers, strings and binary blocks of data.
+The Table definition files share a lot of similarity with the [Command Configuration](command.md). You have the same data types: INT, UINT, FLOAT, STRING, BLOCK. These correspond to integers, unsigned integers, floating point numbers, strings and binary blocks of data. Additional data types of BOOL, ARRAY, OBJECT, and ANY are also available if you are using an Accessor that supports them. These are Booleans (true/false), arrays of unknown data type, objects with unknown contents, and a completely unknown data type with ANY.
diff --git a/docs.openc3.com/docs/configuration/_telemetry.md b/docs.openc3.com/docs/configuration/_telemetry.md
index b10fe6851b..97bd46107a 100644
--- a/docs.openc3.com/docs/configuration/_telemetry.md
+++ b/docs.openc3.com/docs/configuration/_telemetry.md
@@ -18,7 +18,7 @@ When COSMOS receives a telemetry packet from a target, the system will log the r
Telemetry definition files define the telemetry packets that can be received and processed from COSMOS targets. One large file can be used to define the telemetry packets, or multiple files can be used at the user's discretion. Telemetry definition files are placed in the target's cmd_tlm directory and are processed alphabetically. Therefore if you have some telemetry files that depend on others, e.g. they override or extend existing telemetry, they must be named last. The easiest way to do this is to add an extension to an existing file name. For example, if you already have tlm.txt you can create tlm_override.txt for telemetry that depends on the definitions in tlm.txt. Note that due to the way the [ASCII Table](http://www.asciitable.com/) is structured, files beginning with capital letters are processed before lower case letters.
-When defining telemetry items you can choose from the following data types: INT, UINT, FLOAT, STRING, BLOCK. These correspond to integers, unsigned integers, floating point numbers, strings and binary blocks of data. Within COSMOS, the only difference between a STRING and BLOCK is when COSMOS reads a STRING type it stops reading when it encounters a null byte (0). This shows up when displaying the value in Packet Viewer or Tlm Viewer and in the output of Data Extractor. You should strive to store non-ASCII data inside BLOCK items and ASCII strings in STRING items.
+When defining telemetry items you can choose from the following data types: INT, UINT, FLOAT, STRING, BLOCK. These correspond to integers, unsigned integers, floating point numbers, strings and binary blocks of data. Within COSMOS, the only difference between a STRING and BLOCK is when COSMOS reads a STRING type it stops reading when it encounters a null byte (0). This shows up when displaying the value in Packet Viewer or Tlm Viewer and in the output of Data Extractor. You should strive to store non-ASCII data inside BLOCK items and ASCII strings in STRING items. Additional data types of BOOL, ARRAY, OBJECT, and ANY are also available if you are using an Accessor that supports them. These are Booleans (true/false), arrays of unknown data type, objects with unknown contents, and a completely unknown data type with ANY.
:::info Printing Data
diff --git a/examples/openc3-cosmos-accessor-test/.gitignore b/examples/openc3-cosmos-accessor-test/.gitignore
deleted file mode 100644
index 3699924f91..0000000000
--- a/examples/openc3-cosmos-accessor-test/.gitignore
+++ /dev/null
@@ -1,21 +0,0 @@
-tools/*
-.DS_Store
-node_modules
-/dist
-
-# local env files
-.env.local
-.env.*.local
-
-# Log files
-npm-debug.log*
-pnpm-debug.log*
-
-# Editor directories and files
-.idea
-.vscode
-*.suo
-*.ntvs*
-*.njsproj
-*.sln
-*.sw?
diff --git a/examples/openc3-cosmos-accessor-test/LICENSE.txt b/examples/openc3-cosmos-accessor-test/LICENSE.txt
deleted file mode 100644
index c1370810ae..0000000000
--- a/examples/openc3-cosmos-accessor-test/LICENSE.txt
+++ /dev/null
@@ -1,729 +0,0 @@
-The OpenC3 COSMOS software program is a derived work based on the
-Ball Aerospace COSMOS software licensed under the
-GNU Affero General Public License, version 3 with the Addendums listed below.
-
-Commercial licensing is also available for purchase from OpenC3, Inc.
-
-Please note that the verbiage of the AGPL below are copyrighted
-by the Free Software Foundation, but the instance of code to which the
-licenses refer (the OpenC3 COSMOS software) is copyrighted by
-OpenC3 Inc. and/or Ball Aerospace and Technologies Corp as marked in each file.
-
-Also please note that the only valid versions of the AGPL
-that pertain to OpenC3 COSMOS are the particular versions of
-the license reproduced below (i.e., versions 3, rather than any other
-versions of the AGPL), unless explicitly otherwise stated.
-
- OpenC3 AGPL, version 3 LICENSE ADDENDUMS
- OpenC3 COSMOS Version 5, 16 July 2022
-
-The following addendums are made under section 7 of the GNU Affero General
-Public License, version 3.
-
-1. The OpenC3, Inc. copyright and legal notices
- on all user interfaces and source files must be preserved or
- duplicated on any derivative works.
-2. Modified applications and source files must be clearly marked as
- "modified" with the modification author and company indicated
- immediately following the copyright and legal notices.
-3. OpenC3, and OpenC3 COSMOS are trademarks of OpenC3, Inc. and may be used for publicity purposes
- only in a manner that constitutes "fair use" under applicable trademark
- law, except with the express, written permission of OpenC3 Inc.
-
------------------------------------------------------------------------------
-
-Original Ball Aerospace COSMOS 5 License Text:
-
-The Ball Aerospace COSMOS software program is licensed under the
-GNU Affero General Public License, version 3 with the Addendums listed below.
-
-Please note that the verbiage of the AGPL below are copyrighted
-by the Free Software Foundation, but the instance of code to which the
-licenses refer (the Ball Aerospace COSMOS software) is copyrighted by
-Ball Aerospace & Technologies Corp.
-
-Also please note that the only valid versions of the AGPL
-that pertain to Ball Aerospace COSMOS are the particular versions of
-the license reproduced below (i.e., versions 3, rather than any other
-versions of the AGPL), unless explicitly otherwise stated.
-
- BALL AGPL, version 3 LICENSE ADDENDUMS
- Ball Aerospace COSMOS Version 5, 8 January 2020
-
-The following addendums are made under section 7 of the GNU Affero General
-Public License, version 3.
-
-1. The Ball Aerospace & Technologies Corp. copyright and legal notices
- on all user interfaces and source files must be preserved or
- duplicated on any derivative works.
-2. Modified applications and source files must be clearly marked as
- "modified" with the modification author and company indicated
- immediately following the copyright and legal notices.
-3. Ball Aerospace COSMOS, Ball, and Ball Aerospace are trademarks of
- Ball Corporation and may be used for publicity purposes only in a
- manner that constitutes "fair use" under applicable trademark law,
- except with the express, written permission of Ball Corporation.
-
-The AGPL license text follows:
-
- GNU AFFERO GENERAL PUBLIC LICENSE
- Version 3, 19 November 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU Affero General Public License is a free, copyleft license for
-software and other kinds of works, specifically designed to ensure
-cooperation with the community in the case of network server software.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-our General Public Licenses are intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- Developers that use our General Public Licenses protect your rights
-with two steps: (1) assert copyright on the software, and (2) offer
-you this License which gives you legal permission to copy, distribute
-and/or modify the software.
-
- A secondary benefit of defending all users' freedom is that
-improvements made in alternate versions of the program, if they
-receive widespread use, become available for other developers to
-incorporate. Many developers of free software are heartened and
-encouraged by the resulting cooperation. However, in the case of
-software used on network servers, this result may fail to come about.
-The GNU General Public License permits making a modified version and
-letting the public access it on a server without ever releasing its
-source code to the public.
-
- The GNU Affero General Public License is designed specifically to
-ensure that, in such cases, the modified source code becomes available
-to the community. It requires the operator of a network server to
-provide the source code of the modified version running there to the
-users of that server. Therefore, public use of a modified version, on
-a publicly accessible server, gives the public access to the source
-code of the modified version.
-
- An older license, called the Affero General Public License and
-published by Affero, was designed to accomplish similar goals. This is
-a different license, not a version of the Affero GPL, but Affero has
-released a new version of the Affero GPL which permits relicensing under
-this license.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU Affero General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Remote Network Interaction; Use with the GNU General Public License.
-
- Notwithstanding any other provision of this License, if you modify the
-Program, your modified version must prominently offer all users
-interacting with it remotely through a computer network (if your version
-supports such interaction) an opportunity to receive the Corresponding
-Source of your version by providing access to the Corresponding Source
-from a network server at no charge, through some standard or customary
-means of facilitating copying of software. This Corresponding Source
-shall include the Corresponding Source for any work covered by version 3
-of the GNU General Public License that is incorporated pursuant to the
-following paragraph.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the work with which it is combined will remain governed by version
-3 of the GNU General Public License.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU Affero General Public License from time to time. Such new versions
-will be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU Affero General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU Affero General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU Affero General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
-How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- 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.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If your software can interact with users remotely through a computer
-network, you should also make sure that it provides a way for users to
-get its source. For example, if your program is a web application, its
-interface could display a "Source" link that leads users to an archive
-of the code. There are many ways you could offer source, and different
-solutions will be better for different programs; see section 13 for the
-specific requirements.
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU AGPL, see
-.
\ No newline at end of file
diff --git a/examples/openc3-cosmos-accessor-test/README.md b/examples/openc3-cosmos-accessor-test/README.md
deleted file mode 100644
index 677d8a9a92..0000000000
--- a/examples/openc3-cosmos-accessor-test/README.md
+++ /dev/null
@@ -1,28 +0,0 @@
-## OpenC3 COSMOS Accessor Test Plugin
-
-[Documentation](https://openc3.com)
-
-This plugin is used to provide examples of using different accessors
-
-## Getting Started
-
-1. At the OpenC3 COSMOS Admin - Plugins, upload the openc3-cosmos-accessor-test.gem file
-
-## Contributing
-
-We encourage you to contribute to OpenC3 COSMOS!
-
-Contributing is easy.
-
-1. Fork the project
-2. Create a feature branch
-3. Make your changes
-4. Submit a pull request
-
-Before any contributions can be incorporated we do require all contributors to agree to a Contributor License Agreement
-
-This protects both you and us and you retain full rights to any code you write.
-
-## License
-
-This OpenC3 COSMOS plugin is released under the AGPLv3.0 with a few addendums. See [LICENSE.txt](LICENSE.txt)
diff --git a/examples/openc3-cosmos-accessor-test/Rakefile b/examples/openc3-cosmos-accessor-test/Rakefile
deleted file mode 100644
index f3c980ed72..0000000000
--- a/examples/openc3-cosmos-accessor-test/Rakefile
+++ /dev/null
@@ -1,39 +0,0 @@
-# encoding: ascii-8bit
-
-# Copyright 2022 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.
-
-PLUGIN_NAME = Dir['*.gemspec'][0].split('.')[0..-2].join('.')
-
-task :require_version do
- if ENV['VERSION']
- if ENV['VERSION'] =~ /-/
- # Add Timestamp to prerelease versions
- ENV['VERSION'] = ENV['VERSION'] + "." + Time.now.utc.strftime("%Y%m%d%H%M%S")
- end
- else
- puts "VERSION is required: rake VERSION=X.X.X"
- exit 1
- end
-end
-
-task :build => [:require_version] do
- _, platform, *_ = RUBY_PLATFORM.split("-")
- if platform == 'mswin32' or platform == 'mingw32'
- puts "Warning: Building gem on Windows will lose file permissions"
- end
- system("gem build #{PLUGIN_NAME}")
-end
diff --git a/examples/openc3-cosmos-accessor-test/openc3-cosmos-accessor-test.gemspec b/examples/openc3-cosmos-accessor-test/openc3-cosmos-accessor-test.gemspec
deleted file mode 100644
index 9c5d19b85b..0000000000
--- a/examples/openc3-cosmos-accessor-test/openc3-cosmos-accessor-test.gemspec
+++ /dev/null
@@ -1,41 +0,0 @@
-# encoding: ascii-8bit
-
-# Copyright 2025 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.
-
-spec = Gem::Specification.new do |s|
- s.name = 'openc3-cosmos-accessor-test'
- s.summary = 'OpenC3 COSMOS Accessor Example Plugin'
- s.description = <<-EOF
- This plugin is used to provide examples of using different accessors
- EOF
- s.authors = ['Ryan Melton', 'Jason Thomas']
- s.email = ['ryan@openc3.com', 'jason@openc3.com']
- s.homepage = 'https://github.com/OpenC3/cosmos'
-
- s.platform = Gem::Platform::RUBY
- s.required_ruby_version = '>= 3.0'
-
- if ENV['VERSION']
- s.version = ENV['VERSION'].dup
- else
- time = Time.now.strftime("%Y%m%d%H%M%S")
- s.version = '0.0.0' + ".#{time}"
- end
- s.licenses = ['AGPL-3.0-only', 'Nonstandard']
-
- s.files = Dir.glob("{targets,lib,tools,microservices}/**/*") + %w(Rakefile LICENSE.txt README.md plugin.txt)
-end
diff --git a/examples/openc3-cosmos-accessor-test/plugin.txt b/examples/openc3-cosmos-accessor-test/plugin.txt
deleted file mode 100644
index 71471c4a3f..0000000000
--- a/examples/openc3-cosmos-accessor-test/plugin.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-VARIABLE access_target_name ACCESS
-VARIABLE log_retain_time 172800
-VARIABLE reduced_log_retain_time 2592000
-
-TARGET ACCESS <%= access_target_name %>
- LOG_RETAIN_TIME <%= log_retain_time %>
- REDUCED_LOG_RETAIN_TIME <%= reduced_log_retain_time %>
-
-# Change to test Python vs Ruby (remember to change language in target.txt and rebuild gem)
-# INTERFACE <%= access_target_name %> openc3/interfaces/simulated_target_interface.py sim_access.py
-INTERFACE <%= access_target_name %> simulated_target_interface.rb sim_access.rb
- MAP_TARGET <%= access_target_name %>
diff --git a/examples/openc3-cosmos-accessor-test/targets/ACCESS/cmd_tlm/_cbor_template.bin b/examples/openc3-cosmos-accessor-test/targets/ACCESS/cmd_tlm/_cbor_template.bin
deleted file mode 100644
index 2ff3cd7e10..0000000000
--- a/examples/openc3-cosmos-accessor-test/targets/ACCESS/cmd_tlm/_cbor_template.bin
+++ /dev/null
@@ -1 +0,0 @@
-�gid_itemeitem1edmore�eitem2eitem3�@ �Q�eitem4gExampleeitem5�
\ No newline at end of file
diff --git a/examples/openc3-cosmos-accessor-test/targets/ACCESS/cmd_tlm/_make_cbor.rb b/examples/openc3-cosmos-accessor-test/targets/ACCESS/cmd_tlm/_make_cbor.rb
deleted file mode 100644
index e048abd6d3..0000000000
--- a/examples/openc3-cosmos-accessor-test/targets/ACCESS/cmd_tlm/_make_cbor.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-require 'cbor'
-data = {"id_item":2, "item1":101, "more": { "item2":12, "item3":3.14, "item4":"Example", "item5":[4, 3, 2, 1] } }
-File.open("_cbor_template.bin", 'wb') do |file|
- file.write(data.to_cbor)
-end
diff --git a/examples/openc3-cosmos-accessor-test/targets/ACCESS/cmd_tlm/access_cmds.txt b/examples/openc3-cosmos-accessor-test/targets/ACCESS/cmd_tlm/access_cmds.txt
deleted file mode 100644
index 6174b10136..0000000000
--- a/examples/openc3-cosmos-accessor-test/targets/ACCESS/cmd_tlm/access_cmds.txt
+++ /dev/null
@@ -1,67 +0,0 @@
-COMMAND <%= target_name %> JSONCMD BIG_ENDIAN "JSON Accessor Command"
- ACCESSOR JsonAccessor
- TEMPLATE '{"id_item":1, "item1":101, "more": { "item2":12, "item3":3.14, "item4":"Example", "item5":[4, 3, 2, 1] } }'
- APPEND_ID_PARAMETER ID_ITEM 32 INT 1 1 1 "Int Item"
- KEY $.id_item
- APPEND_PARAMETER ITEM1 16 UINT MIN MAX 101 "Int Item 2"
- KEY $.item1
- UNITS CELSIUS C
- APPEND_PARAMETER ITEM2 16 UINT MIN MAX 12 "Int Item 3"
- KEY $.more.item2
- FORMAT_STRING "0x%X"
- APPEND_PARAMETER ITEM3 64 FLOAT MIN MAX 3.14 "Float Item"
- KEY $.more.item3
- APPEND_PARAMETER ITEM4 128 STRING "Example" "String Item"
- KEY $.more.item4
- APPEND_ARRAY_PARAMETER ITEM5 8 UINT 0 "Array Item"
- KEY $.more.item5
-
-COMMAND <%= target_name %> CBORCMD BIG_ENDIAN "CBOR Accessor Command"
- ACCESSOR CborAccessor
- TEMPLATE_FILE _cbor_template.bin
- APPEND_ID_PARAMETER ID_ITEM 32 INT 2 2 2 "Int Item"
- KEY $.id_item
- APPEND_PARAMETER ITEM1 16 UINT MIN MAX 101 "Int Item 2"
- KEY $.item1
- UNITS CELSIUS C
- APPEND_PARAMETER ITEM2 16 UINT MIN MAX 12 "Int Item 3"
- KEY $.more.item2
- FORMAT_STRING "0x%X"
- APPEND_PARAMETER ITEM3 64 FLOAT MIN MAX 3.14 "Float Item"
- KEY $.more.item3
- APPEND_PARAMETER ITEM4 128 STRING "Example" "String Item"
- KEY $.more.item4
- APPEND_ARRAY_PARAMETER ITEM5 8 UINT 0 "Array Item"
- KEY $.more.item5
-
-COMMAND <%= target_name %> XMLCMD BIG_ENDIAN "XML Accessor Command"
- ACCESSOR XmlAccessor
- TEMPLATE '
3.14
Example
'
- APPEND_ID_PARAMETER ID_ITEM 32 INT 3 3 3 "Int Item"
- KEY "/html/head/script/@src"
- APPEND_PARAMETER ITEM1 16 UINT MIN MAX 101 "Int Item 2"
- KEY "/html/head/noscript/text()"
- UNITS CELSIUS C
- APPEND_PARAMETER ITEM2 16 UINT MIN MAX 12 "Int Item 3"
- KEY "/html/body/img/@src"
- FORMAT_STRING "0x%X"
- APPEND_PARAMETER ITEM3 64 FLOAT MIN MAX 3.14 "Float Item"
- KEY "/html/body/div/ul/li[1]/text()"
- APPEND_PARAMETER ITEM4 128 STRING "Example" "String Item"
- KEY "/html/body/div/ul/li[2]/text()"
-
-COMMAND <%= target_name %> HTMLCMD BIG_ENDIAN "HTML Accessor Command"
- ACCESSOR HtmlAccessor
- TEMPLATE '4
Example
1
3.14
'
- APPEND_ID_PARAMETER ID_ITEM 32 INT 4 4 4 "Int Item"
- KEY "/html/head/title/text()"
- APPEND_PARAMETER ITEM1 16 UINT MIN MAX 101 "Int Item 2"
- KEY "/html/head/script/@src"
- UNITS CELSIUS C
- APPEND_PARAMETER ITEM2 16 UINT MIN MAX 12 "Int Item 3"
- KEY "/html/body/noscript/text()"
- FORMAT_STRING "0x%X"
- APPEND_PARAMETER ITEM3 64 FLOAT MIN MAX 3.14 "Float Item"
- KEY "/html/body/img/@src"
- APPEND_PARAMETER ITEM4 128 STRING "Example" "String Item"
- KEY "/html/body/p/text()"
diff --git a/examples/openc3-cosmos-accessor-test/targets/ACCESS/cmd_tlm/access_tlm.txt b/examples/openc3-cosmos-accessor-test/targets/ACCESS/cmd_tlm/access_tlm.txt
deleted file mode 100644
index 43ecf4ba1c..0000000000
--- a/examples/openc3-cosmos-accessor-test/targets/ACCESS/cmd_tlm/access_tlm.txt
+++ /dev/null
@@ -1,83 +0,0 @@
-TELEMETRY <%= target_name %> JSONTLM BIG_ENDIAN "JSON Accessor Telemetry"
- ACCESSOR JsonAccessor
- # Template is not required for telemetry, but is useful for simulation
- TEMPLATE '{"id_item":1, "item1":101, "more": { "item2":12, "item3":3.14, "item4":"Example", "item5":[4, 3, 2, 1] } }'
- APPEND_ID_ITEM ID_ITEM 32 INT 1 "Int Item"
- KEY $.id_item
- APPEND_ITEM ITEM1 16 UINT "Int Item 2"
- KEY $.item1
- GENERIC_READ_CONVERSION_START UINT 16
- value * 2
- GENERIC_READ_CONVERSION_END
- UNITS CELSIUS C
- APPEND_ITEM ITEM2 16 UINT "Int Item 3"
- KEY $.more.item2
- FORMAT_STRING "0x%X"
- APPEND_ITEM ITEM3 64 FLOAT "Float Item"
- KEY $.more.item3
- APPEND_ITEM ITEM4 128 STRING "String Item"
- KEY $.more.item4
- APPEND_ARRAY_ITEM ITEM5 8 UINT 0 "Array Item"
- KEY $.more.item5
-
-TELEMETRY <%= target_name %> CBORTLM BIG_ENDIAN "CBOR Accessor Telemetry"
- ACCESSOR CborAccessor
- # Template is not required for telemetry, but is useful for simulation
- TEMPLATE_FILE _cbor_template.bin
- APPEND_ID_ITEM ID_ITEM 32 INT 2 "Int Item"
- KEY $.id_item
- APPEND_ITEM ITEM1 16 UINT "Int Item 2"
- KEY $.item1
- GENERIC_READ_CONVERSION_START UINT 16
- value * 2
- GENERIC_READ_CONVERSION_END
- UNITS CELSIUS C
- APPEND_ITEM ITEM2 16 UINT "Int Item 3"
- KEY $.more.item2
- FORMAT_STRING "0x%X"
- APPEND_ITEM ITEM3 64 FLOAT "Float Item"
- KEY $.more.item3
- APPEND_ITEM ITEM4 128 STRING "String Item"
- KEY $.more.item4
- APPEND_ARRAY_ITEM ITEM5 8 UINT 0 "Array Item"
- KEY $.more.item5
-
-TELEMETRY <%= target_name %> XMLTLM BIG_ENDIAN "XML Accessor Telemetry"
- ACCESSOR XmlAccessor
- # Template is not required for telemetry, but is useful for simulation
- TEMPLATE '
3.14
Example
'
- APPEND_ID_ITEM ID_ITEM 32 INT 3 "Int Item"
- KEY "/html/head/script/@src"
- APPEND_ITEM ITEM1 16 UINT "Int Item 2"
- KEY "/html/head/noscript/text()"
- GENERIC_READ_CONVERSION_START UINT 16
- value * 2
- GENERIC_READ_CONVERSION_END
- UNITS CELSIUS C
- APPEND_ITEM ITEM2 16 UINT "Int Item 3"
- KEY "/html/body/img/@src"
- FORMAT_STRING "0x%X"
- APPEND_ITEM ITEM3 64 FLOAT "Float Item"
- KEY "/html/body/div/ul/li[1]/text()"
- APPEND_ITEM ITEM4 128 STRING "String Item"
- KEY "/html/body/div/ul/li[2]/text()"
-
-TELEMETRY <%= target_name %> HTMLTLM BIG_ENDIAN "HTML Accessor Telemetry"
- ACCESSOR HtmlAccessor
- # Template is not required for telemetry, but is useful for simulation
- TEMPLATE '4
Example
1
3.14
'
- APPEND_ID_ITEM ID_ITEM 32 INT 4 "Int Item"
- KEY "/html/head/title/text()"
- APPEND_ITEM ITEM1 16 UINT "Int Item 2"
- KEY "/html/head/script/@src"
- GENERIC_READ_CONVERSION_START UINT 16
- value * 2
- GENERIC_READ_CONVERSION_END
- UNITS CELSIUS C
- APPEND_ITEM ITEM2 16 UINT "Int Item 3"
- KEY "/html/body/noscript/text()"
- FORMAT_STRING "0x%X"
- APPEND_ITEM ITEM3 64 FLOAT "Float Item"
- KEY "/html/body/img/@src"
- APPEND_ITEM ITEM4 128 STRING "String Item"
- KEY "/html/body/p/text()"
diff --git a/examples/openc3-cosmos-accessor-test/targets/ACCESS/lib/sim_access.py b/examples/openc3-cosmos-accessor-test/targets/ACCESS/lib/sim_access.py
deleted file mode 100644
index ae5fa1a4cc..0000000000
--- a/examples/openc3-cosmos-accessor-test/targets/ACCESS/lib/sim_access.py
+++ /dev/null
@@ -1,48 +0,0 @@
-# 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.
-
-# Provides a demonstration of accessors
-
-from openc3.utilities.simulated_target import SimulatedTarget
-
-
-class SimAccess(SimulatedTarget):
- def set_rates(self):
- self.set_rate("JSONTLM", 100)
- self.set_rate("CBORTLM", 100)
- self.set_rate("XMLTLM", 100)
- self.set_rate("HTMLTLM", 100)
-
- def tick_period_seconds(self):
- return 1 # Override this method to optimize
-
- def tick_increment(self):
- return 100 # Override this method to optimize
-
- def write(self, packet):
- name = packet.packet_name.upper()
-
- json_packet = self.tlm_packets["JSONTLM"]
- cbor_packet = self.tlm_packets["CBORTLM"]
- xml_packet = self.tlm_packets["XMLTLM"]
- html_packet = self.tlm_packets["HTMLTLM"]
-
- match name:
- case "JSONCMD":
- json_packet.buffer = packet.buffer
- case "CBORCMD":
- cbor_packet.buffer = packet.buffer
- case "XMLCMD":
- xml_packet.buffer = packet.buffer
- case "HTMLCMD":
- html_packet.buffer = packet.buffer
diff --git a/examples/openc3-cosmos-accessor-test/targets/ACCESS/lib/sim_access.rb b/examples/openc3-cosmos-accessor-test/targets/ACCESS/lib/sim_access.rb
deleted file mode 100644
index bf5e8f22ad..0000000000
--- a/examples/openc3-cosmos-accessor-test/targets/ACCESS/lib/sim_access.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-# encoding: ascii-8bit
-
-# Copyright 2025 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.
-
-# Provides a demonstration of accessors
-
-require 'openc3'
-
-module OpenC3
- class SimAccess < SimulatedTarget
- def set_rates
- set_rate('JSONTLM', 100)
- set_rate('CBORTLM', 100)
- set_rate('XMLTLM', 100)
- set_rate('HTMLTLM', 100)
- end
-
- def tick_period_seconds
- return 1 # Override this method to optimize
- end
-
- def tick_increment
- return 100 # Override this method to optimize
- end
-
- def write(packet)
- name = packet.packet_name.upcase
-
- json_packet = @tlm_packets['JSONTLM']
- cbor_packet = @tlm_packets['CBORTLM']
- xml_packet = @tlm_packets['XMLTLM']
- html_packet = @tlm_packets['HTMLTLM']
-
- case name
- when 'JSONCMD'
- json_packet.buffer = packet.buffer
- when 'CBORCMD'
- cbor_packet.buffer = packet.buffer
- when 'XMLCMD'
- xml_packet.buffer = packet.buffer
- when 'HTMLCMD'
- html_packet.buffer = packet.buffer
- else
- raise "Unknown packet name: #{name}"
- end
- end
- end
-end
diff --git a/examples/openc3-cosmos-accessor-test/targets/ACCESS/target.txt b/examples/openc3-cosmos-accessor-test/targets/ACCESS/target.txt
deleted file mode 100644
index 383aa52263..0000000000
--- a/examples/openc3-cosmos-accessor-test/targets/ACCESS/target.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-# Change language and edit plugin.txt to test either language
-LANGUAGE ruby
-
-IGNORE_PARAMETER ID_ITEM
-
-CMD_UNIQUE_ID_MODE
-TLM_UNIQUE_ID_MODE
\ No newline at end of file
diff --git a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/cmd_tlm/inst_cmds.txt b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/cmd_tlm/inst_cmds.txt
index fbaac49b3d..de7310a5c7 100644
--- a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/cmd_tlm/inst_cmds.txt
+++ b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/cmd_tlm/inst_cmds.txt
@@ -135,7 +135,7 @@ COMMAND <%= target_name %> SET_PASSWORD BIG_ENDIAN "Set Password Command"
COMMAND <%= target_name %> JSONCMD BIG_ENDIAN "JSON Accessor Command"
ACCESSOR JsonAccessor
- TEMPLATE '{"id_item":1, "item1":101, "more": { "item2":12, "item3":3.14, "item4":"Example", "item5":[4, 3, 2, 1] } }'
+ TEMPLATE '{"id_item":1, "item1":101, "more": { "item2":12, "item3":3.14, "item4":"Example", "item5":[4, 3, 2, 1] }, "item6": true, "item7": [1, "2", 3.14], "item8": {"a":"b"}, "item9": {"c":"d"} }'
APPEND_ID_PARAMETER ID_ITEM 32 INT 31 31 31 "Int Item"
KEY $.id_item
APPEND_PARAMETER ITEM1 16 UINT MIN MAX 101 "Int Item 2"
@@ -150,6 +150,14 @@ COMMAND <%= target_name %> JSONCMD BIG_ENDIAN "JSON Accessor Command"
KEY $.more.item4
APPEND_ARRAY_PARAMETER ITEM5 8 UINT 0 "Array Item"
KEY $.more.item5
+ APPEND_PARAMETER ITEM6 8 BOOL true "Bool Item"
+ KEY $.item6
+ APPEND_PARAMETER ITEM7 8 ARRAY '[1,"2",3.14]' "Complex Array Item"
+ KEY $.item7
+ APPEND_PARAMETER ITEM8 8 OBJECT '{"a":"b"}' "Object Item"
+ KEY $.item8
+ APPEND_PARAMETER ITEM9 8 ANY '{"c":"d"}' "Any Item"
+ KEY $.item9
COMMAND <%= target_name %> CBORCMD BIG_ENDIAN "CBOR Accessor Command"
ACCESSOR CborAccessor
diff --git a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/cmd_tlm/inst_tlm.txt b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/cmd_tlm/inst_tlm.txt
index 994765a4ed..9231e1551d 100644
--- a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/cmd_tlm/inst_tlm.txt
+++ b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/cmd_tlm/inst_tlm.txt
@@ -183,7 +183,7 @@ TELEMETRY <%= target_name %> HIDDEN BIG_ENDIAN "Hidden packet"
TELEMETRY <%= target_name %> JSONTLM BIG_ENDIAN "JSON Accessor Telemetry"
ACCESSOR JsonAccessor
# Template is not required for telemetry, but is useful for simulation
- TEMPLATE '{"id_item":1, "item1":101, "more": { "item2":12, "item3":3.14, "item4":"Example", "item5":[4, 3, 2, 1] } }'
+ TEMPLATE '{"id_item":1, "item1":101, "more": { "item2":12, "item3":3.14, "item4":"Example", "item5":[4, 3, 2, 1] }, "item6": true, "item7": [1, "2", 3.14], "item8": {"a":"b"}, "item9": {"c":"d"} }'
APPEND_ID_ITEM ID_ITEM 32 INT 31 "Int Item"
KEY $.id_item
APPEND_ITEM ITEM1 16 UINT "Int Item 2"
@@ -201,6 +201,14 @@ TELEMETRY <%= target_name %> JSONTLM BIG_ENDIAN "JSON Accessor Telemetry"
KEY $.more.item4
APPEND_ARRAY_ITEM ITEM5 8 UINT 0 "Array Item"
KEY $.more.item5
+ APPEND_ITEM ITEM6 8 BOOL "Bool Item"
+ KEY $.item6
+ APPEND_ITEM ITEM7 8 ARRAY "Complex Array Item"
+ KEY $.item7
+ APPEND_ITEM ITEM8 8 OBJECT "Object Item"
+ KEY $.item8
+ APPEND_ITEM ITEM9 8 ANY "Any Item"
+ KEY $.item9
TELEMETRY <%= target_name %> CBORTLM BIG_ENDIAN "CBOR Accessor Telemetry"
ACCESSOR CborAccessor
diff --git a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/cmd_tlm/inst_cmds.txt b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/cmd_tlm/inst_cmds.txt
index 8f55ecbc9a..876c45ba5c 100644
--- a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/cmd_tlm/inst_cmds.txt
+++ b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/cmd_tlm/inst_cmds.txt
@@ -150,6 +150,14 @@ COMMAND <%= target_name %> JSONCMD BIG_ENDIAN "JSON Accessor Command"
KEY $.more.item4
APPEND_ARRAY_PARAMETER ITEM5 8 UINT 0 "Array Item"
KEY $.more.item5
+ APPEND_PARAMETER ITEM6 8 BOOL true "Bool Item"
+ KEY $.item6
+ APPEND_PARAMETER ITEM7 8 ARRAY '[1,"2",3.14]' "Complex Array Item"
+ KEY $.item7
+ APPEND_PARAMETER ITEM8 8 OBJECT '{"a":"b"}' "Object Item"
+ KEY $.item8
+ APPEND_PARAMETER ITEM9 8 ANY '{"c":"d"}' "Any Item"
+ KEY $.item9
COMMAND <%= target_name %> CBORCMD BIG_ENDIAN "CBOR Accessor Command"
ACCESSOR CborAccessor
diff --git a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/cmd_tlm/inst_tlm.txt b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/cmd_tlm/inst_tlm.txt
index 41b4f272b4..589f303161 100644
--- a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/cmd_tlm/inst_tlm.txt
+++ b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/cmd_tlm/inst_tlm.txt
@@ -195,6 +195,14 @@ TELEMETRY <%= target_name %> JSONTLM BIG_ENDIAN "JSON Accessor Telemetry"
KEY $.more.item4
APPEND_ARRAY_ITEM ITEM5 8 UINT 0 "Array Item"
KEY $.more.item5
+ APPEND_ITEM ITEM6 8 BOOL "Bool Item"
+ KEY $.item6
+ APPEND_ITEM ITEM7 8 ARRAY "Complex Array Item"
+ KEY $.item7
+ APPEND_ITEM ITEM8 8 OBJECT "Object Item"
+ KEY $.item8
+ APPEND_ITEM ITEM9 8 ANY "Any Item"
+ KEY $.item9
TELEMETRY <%= target_name %> CBORTLM BIG_ENDIAN "CBOR Accessor Telemetry"
ACCESSOR CborAccessor
diff --git a/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdtlmserver/src/tools/CmdTlmServer/InterfaceComponents/DetailsTable.vue b/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdtlmserver/src/tools/CmdTlmServer/InterfaceComponents/DetailsTable.vue
index 61e2e0b5e4..e910cc88c5 100644
--- a/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdtlmserver/src/tools/CmdTlmServer/InterfaceComponents/DetailsTable.vue
+++ b/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdtlmserver/src/tools/CmdTlmServer/InterfaceComponents/DetailsTable.vue
@@ -230,7 +230,7 @@ export default {
},
formatValue(value) {
if (value === null || value === undefined) {
- return ''
+ return 'null'
}
if (typeof value === 'object') {
return JSON.stringify(value, null, 2)
diff --git a/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-packetviewer/src/tools/PacketViewer/PacketViewer.vue b/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-packetviewer/src/tools/PacketViewer/PacketViewer.vue
index 73d46566a7..acb2f5c8c5 100644
--- a/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-packetviewer/src/tools/PacketViewer/PacketViewer.vue
+++ b/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-packetviewer/src/tools/PacketViewer/PacketViewer.vue
@@ -13,7 +13,7 @@
# GNU Affero General Public License for more details.
# Modified by OpenC3, Inc.
-# All changes Copyright 2024, OpenC3, Inc.
+# All changes Copyright 2025, OpenC3, Inc.
# All Rights Reserved
#
# This file may also be used under the terms of a commercial license
@@ -478,10 +478,13 @@ export default {
// If we're passed in the route then manually call packetChanged to update
if (this.$route.params.target && this.$route.params.packet) {
// Initial position of chooser should be correct so call packetChanged for it
- await this.packetChanged({
- targetName: this.$route.params.target.toUpperCase(),
- packetName: this.$route.params.packet.toUpperCase(),
- })
+ await this.packetChanged(
+ {
+ targetName: this.$route.params.target.toUpperCase(),
+ packetName: this.$route.params.packet.toUpperCase(),
+ },
+ true,
+ )
} else {
if (config.target && config.packet) {
// Chooser probably won't be at the right packet so need to refresh
@@ -531,10 +534,11 @@ export default {
return false
}
},
- async packetChanged(event) {
+ async packetChanged(event, force = false) {
if (
this.targetName === event.targetName &&
- this.packetName === event.packetName
+ this.packetName === event.packetName &&
+ !force
) {
return // No change
}
diff --git a/openc3-cosmos-init/plugins/packages/openc3-vue-common/src/components/CommandEditor.vue b/openc3-cosmos-init/plugins/packages/openc3-vue-common/src/components/CommandEditor.vue
index 1dd87ef2d8..e2fd60a164 100644
--- a/openc3-cosmos-init/plugins/packages/openc3-vue-common/src/components/CommandEditor.vue
+++ b/openc3-cosmos-init/plugins/packages/openc3-vue-common/src/components/CommandEditor.vue
@@ -265,6 +265,9 @@ export default {
if (parameter.format_string && parameter.default) {
val = sprintf(parameter.format_string, parameter.default)
}
+ if (Object.prototype.toString.call(val).slice(8, -1) === 'Object') {
+ val = JSON.stringify(val).replace(/\\n/g, '')
+ }
let range = 'N/A'
if (
parameter.minimum != null &&
@@ -272,16 +275,12 @@ export default {
) {
if (parameter.data_type === 'FLOAT') {
if (parameter.minimum < -1e6) {
- if (Number.isSafeInteger(parameter.minimum)) {
- parameter.minimum =
- parameter.minimum.toExponential(3)
- }
+ parameter.minimum =
+ parameter.minimum.toExponential(3)
}
if (parameter.maximum > 1e6) {
- if (Number.isSafeInteger(parameter.maximum)) {
- parameter.maximum =
- parameter.maximum.toExponential(3)
- }
+ parameter.maximum =
+ parameter.maximum.toExponential(3)
}
}
range = `${parameter.minimum}..${parameter.maximum}`
diff --git a/openc3-cosmos-init/plugins/packages/openc3-vue-common/src/widgets/FormatValueBase.js b/openc3-cosmos-init/plugins/packages/openc3-vue-common/src/widgets/FormatValueBase.js
index 15288aeeda..934effc797 100644
--- a/openc3-cosmos-init/plugins/packages/openc3-vue-common/src/widgets/FormatValueBase.js
+++ b/openc3-cosmos-init/plugins/packages/openc3-vue-common/src/widgets/FormatValueBase.js
@@ -28,14 +28,17 @@ export default {
return this.formatJsonString(value)
}
if (Array.isArray(value)) {
- return this.formatArray(value)
+ return JSON.stringify(value).replace(/\\n/g, '')
}
if (this.isObject(value)) {
- return ''
+ return JSON.stringify(value).replace(/\\n/g, '')
}
if (formatString && value) {
return sprintf(formatString, value)
}
+ if (value === null || value === undefined) {
+ return 'null'
+ }
return String(value)
},
isJsonString(value) {
diff --git a/openc3.code-workspace b/openc3.code-workspace
index 83bf9f7466..af33b5395b 100644
--- a/openc3.code-workspace
+++ b/openc3.code-workspace
@@ -44,6 +44,12 @@
},
{
"path": "../openc3-cosmos-script-engine-cstol"
+ },
+ {
+ "path": "../api_tutorial"
+ },
+ {
+ "path": "../openc3-cosmos-nemesis"
}
],
"settings": {
diff --git a/openc3/lib/openc3/accessors/accessor.rb b/openc3/lib/openc3/accessors/accessor.rb
index 4f69f7dd2a..60edad4cdf 100644
--- a/openc3/lib/openc3/accessors/accessor.rb
+++ b/openc3/lib/openc3/accessors/accessor.rb
@@ -17,6 +17,7 @@
# if purchased from OpenC3, Inc.
require 'json'
+require 'openc3/config/config_parser'
module OpenC3
class Accessor
@@ -121,8 +122,16 @@ def self.write_items(items, values, buffer)
def self.convert_to_type(value, item)
return value if value.nil?
case item.data_type
+ when :ANY
+ begin
+ value = JSON.parse(value) if value.is_a? String
+ rescue Exception
+ # Just leave value as is
+ end
+ when :BOOL
+ value = ConfigParser.handle_true_false(value) if value.is_a? String
when :OBJECT, :ARRAY
- # Do nothing for complex object types
+ value = JSON.parse(value) if value.is_a? String
when :STRING, :BLOCK
if item.array_size
value = JSON.parse(value) if value.is_a? String
diff --git a/openc3/lib/openc3/accessors/template_accessor.rb b/openc3/lib/openc3/accessors/template_accessor.rb
index 607d2c44a6..69bd09ffe3 100644
--- a/openc3/lib/openc3/accessors/template_accessor.rb
+++ b/openc3/lib/openc3/accessors/template_accessor.rb
@@ -66,7 +66,7 @@ def read_item(item, buffer)
values.each_with_index do |value, i|
item_key = @item_keys[i]
if item_key == item.key
- return Accessor.convert_to_type(value, item)
+ return self.class.convert_to_type(value, item)
end
end
end
@@ -90,7 +90,7 @@ def read_items(items, buffer)
end
index = @item_keys.index(item.key)
if index
- result[item.name] = Accessor.convert_to_type(values[index], item)
+ result[item.name] = self.class.convert_to_type(values[index], item)
else
raise "Unknown item with key #{item.key} requested"
end
diff --git a/openc3/lib/openc3/packets/packet.rb b/openc3/lib/openc3/packets/packet.rb
index fce1d439f2..1bc06849de 100644
--- a/openc3/lib/openc3/packets/packet.rb
+++ b/openc3/lib/openc3/packets/packet.rb
@@ -1315,17 +1315,21 @@ def obfuscate()
current_value = read(item.name, :RAW)
case current_value
+ when Hash
+ obfuscated_value = {}
when Array
# For arrays, create a new array of zeros with the same size
case item.data_type
- when :INT, :UINT
- obfuscated_value = Array.new(current_value.size, 0)
- when :FLOAT
- obfuscated_value = Array.new(current_value.size, 0.0)
- when :STRING, :BLOCK
- obfuscated_value = Array.new(current_value.size) { |i|
- "\x00" * current_value[i].length if current_value[i]
- }
+ when :INT, :UINT
+ obfuscated_value = Array.new(current_value.size, 0)
+ when :FLOAT
+ obfuscated_value = Array.new(current_value.size, 0.0)
+ when :STRING, :BLOCK
+ obfuscated_value = Array.new(current_value.size) { |i|
+ "\x00" * current_value[i].length if current_value[i]
+ }
+ when :BOOL, :ARRAY, :OBJECT, :ANY
+ obfuscated_value = []
else
obfuscated_value = Array.new(current_value.size, 0)
end
@@ -1338,6 +1342,8 @@ def obfuscate()
obfuscated_value = 0
when :FLOAT
obfuscated_value = 0.0
+ when :BOOL
+ obfuscated_value = false
else
obfuscated_value = 0
end
diff --git a/openc3/lib/openc3/packets/packet_config.rb b/openc3/lib/openc3/packets/packet_config.rb
index 47aaf28615..71a60fd680 100644
--- a/openc3/lib/openc3/packets/packet_config.rb
+++ b/openc3/lib/openc3/packets/packet_config.rb
@@ -100,6 +100,8 @@ class PacketConfig
COMMAND = "Command"
TELEMETRY = "Telemetry"
+ # Note: DERIVED is not a valid converted type. Also TIME is currently only a converted type
+ CONVERTED_DATA_TYPES = [:INT, :UINT, :FLOAT, :STRING, :BLOCK, :BOOL, :OBJECT, :ARRAY, :ANY, :TIME]
def initialize
@name = nil
@@ -714,7 +716,7 @@ def process_current_item(parser, keyword, params)
@converted_bit_size = nil
if params[0]
@converted_type = params[0].upcase.intern
- raise parser.error("Invalid converted_type: #{@converted_type}.") unless [:INT, :UINT, :FLOAT, :STRING, :BLOCK, :TIME].include? @converted_type
+ raise parser.error("Invalid converted_type: #{@converted_type}.") unless CONVERTED_DATA_TYPES.include? @converted_type
end
@converted_bit_size = Integer(params[1]) if params[1]
if @converted_type.nil? or @converted_bit_size.nil?
diff --git a/openc3/lib/openc3/packets/packet_item.rb b/openc3/lib/openc3/packets/packet_item.rb
index 3b2ab1aff5..4e9864173c 100644
--- a/openc3/lib/openc3/packets/packet_item.rb
+++ b/openc3/lib/openc3/packets/packet_item.rb
@@ -233,6 +233,12 @@ def check_default_and_range_data_types
raise ArgumentError, "#{@name}: default must be a String but is a #{@default.class}" unless String === @default
@default = @default.clone.freeze
+ when :ARRAY
+ raise ArgumentError, "#{@name}: default must be an Array but is a #{@default.class}" unless Array === @default
+ when :OBJECT
+ raise ArgumentError, "#{@name}: default must be an Hash but is a #{@default.class}" unless Hash === @default
+ when :BOOL
+ raise ArgumentError, "#{@name}: default must be true/false but is a #{@default.class}" unless TrueClass === @default or FalseClass === @default
end
end
end
@@ -519,6 +525,10 @@ def convert(value, data_type)
Float(value)
when :STRING, :BLOCK
value.to_s.freeze
+ when :BOOL
+ ConfigParser.handle_true_false(value)
+ else
+ return value
end
rescue
raise ArgumentError, "#{@name}: Invalid value: #{value} for data type: #{data_type}"
diff --git a/openc3/lib/openc3/packets/parsers/packet_item_parser.rb b/openc3/lib/openc3/packets/parsers/packet_item_parser.rb
index 7373c5c560..884ad79f0e 100644
--- a/openc3/lib/openc3/packets/parsers/packet_item_parser.rb
+++ b/openc3/lib/openc3/packets/parsers/packet_item_parser.rb
@@ -177,7 +177,7 @@ def get_range
return nil if @parser.keyword.include?('ARRAY')
data_type = get_data_type()
- return nil if data_type == :STRING or data_type == :BLOCK
+ return nil unless data_type == :INT or data_type == :UINT or data_type == :FLOAT
index = append? ? 3 : 4
return nil if @parser.parameters[index] == 'nil'
@@ -232,8 +232,52 @@ def get_default
index = append? ? 3 : 4
data_type = get_data_type()
- return [] if data_type == :ARRAY
- return {} if data_type == :OBJECT
+ if data_type == :BOOL
+ value = @parser.parameters[index].to_s.upcase
+ if value == "TRUE" or value == "FALSE"
+ return ConfigParser.handle_true_false(@parser.parameters[index])
+ else
+ raise @parser.error("Default for BOOL data type must be TRUE or FALSE")
+ end
+ end
+ if data_type == :ARRAY
+ value = @parser.parameters[index].to_s
+ begin
+ value = JSON.parse(value, allow_nan: true)
+ rescue Exception
+ raise @parser.error("Unparsable value for ARRAY: #{value}")
+ end
+ if Array === value
+ return value
+ else
+ raise @parser.error("Default for ARRAY data type must be an Array")
+ end
+ end
+ if data_type == :OBJECT
+ value = @parser.parameters[index].to_s
+ begin
+ value = JSON.parse(value, allow_nan: true)
+ rescue Exception
+ raise @parser.error("Unparsable value for OBJECT: #{value}")
+ end
+ if Hash === value
+ return value
+ else
+ raise @parser.error("Default for OBJECT data type must be a Hash")
+ end
+ end
+ if data_type == :ANY
+ value = @parser.parameters[index].to_s
+ if value.length > 0
+ begin
+ return JSON.parse(value, allow_nan: true)
+ rescue Exception
+ return value
+ end
+ else
+ return ""
+ end
+ end
if data_type == :STRING or data_type == :BLOCK
return convert_string_value(index)
else
@@ -259,6 +303,52 @@ def get_id_value(item)
end
index = append? ? 3 : 4
+ if data_type == :BOOL
+ value = @parser.parameters[index].to_s.upcase
+ if value == "TRUE" or value == "FALSE"
+ return ConfigParser.handle_true_false(@parser.parameters[index])
+ else
+ raise @parser.error("ID Value for BOOL data type must be TRUE or FALSE")
+ end
+ end
+ if data_type == :ARRAY
+ value = @parser.parameters[index].to_s
+ begin
+ value = JSON.parse(value, allow_nan: true)
+ rescue Exception
+ raise @parser.error("Unparsable value for ARRAY: #{value}")
+ end
+ if Array === value
+ return value
+ else
+ raise @parser.error("ID Value for ARRAY data type must be an Array")
+ end
+ end
+ if data_type == :OBJECT
+ value = @parser.parameters[index].to_s
+ begin
+ value = JSON.parse(value, allow_nan: true)
+ rescue Exception
+ raise @parser.error("Unparsable value for OBJECT: #{value}")
+ end
+ if Hash === value
+ return value
+ else
+ raise @parser.error("ID Value for OBJECT data type must be a Hash")
+ end
+ end
+ if data_type == :ANY
+ value = @parser.parameters[index].to_s
+ if value.length > 0
+ begin
+ return JSON.parse(value, allow_nan: true)
+ rescue Exception
+ return value
+ end
+ else
+ return ""
+ end
+ end
if data_type == :STRING or data_type == :BLOCK
return convert_string_value(index)
else
@@ -301,13 +391,13 @@ def bit_size_usage
def type_usage
keyword = @parser.keyword
# Item type usage is simple so just return it
- return " " if keyword.include?("ITEM")
+ return " " if keyword.include?("ITEM")
# Build up the parameter type usage based on the keyword
usage = " "
+ usage << "INT/UINT/FLOAT/STRING/BLOCK/BOOL/OBJECT/ANY> "
else
begin
data_type = get_data_type()
@@ -315,14 +405,13 @@ def type_usage
# If the data type could not be determined set something
data_type = :INT
end
- # STRING, BLOCK, ARRAY, OBJECT types do not have min or max values
- if data_type == :STRING || data_type == :BLOCK
- usage << "STRING/BLOCK/ARRAY/OBJECT> "
+ if data_type == :INT || data_type == :UINT || data_type == :FLOAT || data_type == :DERIVED
+ usage << "INT/UINT/FLOAT/DERIVED> "
else
- usage << "INT/UINT/FLOAT> "
+ usage << "STRING/BLOCK/BOOL/ARRAY/OBJECT/ANY> "
end
- # ID Values do not have default values (or ARRAY/OBJECT)
- unless keyword.include?("ID") or data_type == :ARRAY or data_type == :OBJECT
+ # ID Values do not have default values
+ unless keyword.include?("ID")
usage << " "
end
end
diff --git a/openc3/lib/openc3/packets/parsers/xtce_converter.rb b/openc3/lib/openc3/packets/parsers/xtce_converter.rb
index 5719ecb48b..af974d7240 100644
--- a/openc3/lib/openc3/packets/parsers/xtce_converter.rb
+++ b/openc3/lib/openc3/packets/parsers/xtce_converter.rb
@@ -261,8 +261,8 @@ def to_xtce_type(item, param_or_arg, xml)
to_xtce_string(item, param_or_arg, xml, 'String')
when :BLOCK
to_xtce_string(item, param_or_arg, xml, 'Binary')
- when :DERIVED
- raise "DERIVED data type not supported in XTCE"
+ else
+ raise "#{item.data_type} data type not supported in XTCE"
end
# Handle arrays
diff --git a/openc3/lib/openc3/packets/structure_item.rb b/openc3/lib/openc3/packets/structure_item.rb
index 410cf18328..1800d308af 100644
--- a/openc3/lib/openc3/packets/structure_item.rb
+++ b/openc3/lib/openc3/packets/structure_item.rb
@@ -31,7 +31,7 @@ class StructureItem
@@create_index = 0
# Valid data types adds :DERIVED, :ARRAY, :OBJECT to those defined by BinaryAccessor
- DATA_TYPES = BinaryAccessor::DATA_TYPES << :DERIVED << :ARRAY << :OBJECT
+ DATA_TYPES = [:INT, :UINT, :FLOAT, :STRING, :BLOCK, :BOOL, :OBJECT, :ARRAY, :ANY, :DERIVED]
# Name is used by higher level classes to access the StructureItem.
# @return [String] Name of the item
@@ -210,7 +210,7 @@ def data_type=(data_type)
when *DATA_TYPES
# Valid data_type
else
- raise ArgumentError, "#{@name}: unknown data_type: #{data_type} - Must be :INT, :UINT, :FLOAT, :STRING, :BLOCK, or :DERIVED"
+ raise ArgumentError, "#{@name}: unknown data_type: #{data_type} - Must be #{DATA_TYPES.join(", ")}"
end
@data_type = data_type
diff --git a/openc3/lib/openc3/tools/table_manager/table_config.rb b/openc3/lib/openc3/tools/table_manager/table_config.rb
index 2189dc8c02..89a8d67ba6 100644
--- a/openc3/lib/openc3/tools/table_manager/table_config.rb
+++ b/openc3/lib/openc3/tools/table_manager/table_config.rb
@@ -266,6 +266,14 @@ def finish_packet
item.default = @defaults[index].to_f
when :STRING, :BLOCK
item.default = @defaults[index]
+ when :BOOL
+ item.default = ConfigParser.handle_true_false(@defaults[index])
+ when :ARRAY, :OBJECT, :ANY
+ begin
+ item.default = JSON.parse(@defaults[index], allow_nan: true)
+ rescue Exception
+ item.default = @defaults[index]
+ end
end
end
end
diff --git a/openc3/lib/openc3/utilities/logger.rb b/openc3/lib/openc3/utilities/logger.rb
index f40fc9883f..df9ce287bf 100644
--- a/openc3/lib/openc3/utilities/logger.rb
+++ b/openc3/lib/openc3/utilities/logger.rb
@@ -20,7 +20,6 @@
# This file may also be used under the terms of a commercial license
# if purchased from OpenC3, Inc.
-require 'openc3'
require 'openc3/core_ext/class'
require 'openc3/core_ext/time'
require 'openc3/utilities/store_queued'
diff --git a/openc3/python/openc3/accessors/accessor.py b/openc3/python/openc3/accessors/accessor.py
index cc6b44172c..3995c00084 100644
--- a/openc3/python/openc3/accessors/accessor.py
+++ b/openc3/python/openc3/accessors/accessor.py
@@ -15,7 +15,7 @@
# if purchased from OpenC3, Inc.
from ast import literal_eval
-
+from openc3.config.config_parser import ConfigParser
class Accessor:
def __init__(self, packet=None):
@@ -90,9 +90,26 @@ def convert_to_type(cls, value, item):
if value is None:
return None
match item.data_type:
+ case "ANY":
+ try:
+ if isinstance(value, str):
+ # Thought about using json.loads here but it doesn't
+ # support basic examples like "[2.2, '3', 4]"
+ # Seems it's pretty strict about quotes and escaping
+ value = literal_eval(value)
+ except Exception:
+ # Just leave value as is
+ pass
+ case "BOOL":
+ if isinstance(value, str):
+ value = ConfigParser.handle_true_false(value)
case "OBJECT" | "ARRAY":
- pass # No conversion on complex OBJECT types
- case "STRING" | "BLOCK":
+ if isinstance(value, str):
+ # Thought about using json.loads here but it doesn't
+ # support basic examples like "[2.2, '3', 4]"
+ # Seems it's pretty strict about quotes and escaping
+ value = literal_eval(value)
+ case "STRING":
if item.array_size is not None:
if isinstance(value, str):
# Thought about using json.loads here but it doesn't
@@ -102,6 +119,18 @@ def convert_to_type(cls, value, item):
value = [str(x) for x in value]
else:
value = str(value)
+ case "BLOCK":
+ if item.array_size is not None:
+ if isinstance(value, str):
+ # Thought about using json.loads here but it doesn't
+ # support basic examples like "[2.2, '3', 4]"
+ # Seems it's pretty strict about quotes and escaping
+ value = literal_eval(value)
+ else:
+ if isinstance(value, str):
+ value = bytearray(value.encode())
+ else:
+ value = bytearray(value)
case "INT" | "UINT":
if item.array_size is not None:
if isinstance(value, str):
diff --git a/openc3/python/openc3/accessors/template_accessor.py b/openc3/python/openc3/accessors/template_accessor.py
index 0ddf3ef64d..873230ebb1 100644
--- a/openc3/python/openc3/accessors/template_accessor.py
+++ b/openc3/python/openc3/accessors/template_accessor.py
@@ -75,7 +75,7 @@ def read_item(self, item, buffer):
for i, value in enumerate(values):
item_key = self.item_keys[i]
if item_key == item.key:
- return Accessor.convert_to_type(value, item)
+ return self.__class__.convert_to_type(value, item)
raise RuntimeError(f"Response does not include key {item.key}: {buffer}")
@@ -101,7 +101,7 @@ def read_items(self, items, buffer):
continue
try:
index = self.item_keys.index(item.key)
- result[item.name] = Accessor.convert_to_type(values[index], item)
+ result[item.name] = self.__class__.convert_to_type(values[index], item)
except ValueError:
raise RuntimeError(f"Unknown item with key {item.key} requested")
diff --git a/openc3/python/openc3/io/serial_driver.py b/openc3/python/openc3/io/serial_driver.py
index d486bfadd9..c7e135012f 100644
--- a/openc3/python/openc3/io/serial_driver.py
+++ b/openc3/python/openc3/io/serial_driver.py
@@ -21,13 +21,13 @@
class SerialDriver:
"""A platform independent serial driver"""
-
+
# Parity constants
EVEN = 'EVEN'
ODD = 'ODD'
NONE = 'NONE'
VALID_PARITY = [EVEN, ODD, NONE]
-
+
def __init__(self,
port_name: str,
baud_rate: int,
@@ -55,13 +55,13 @@ def __init__(self,
if parity not in self.VALID_PARITY:
raise ValueError(f"Invalid parity: {parity}")
-
+
if data_bits not in [5, 6, 7, 8]:
raise ValueError(f"Invalid data bits: {data_bits}")
-
+
if stop_bits not in [1, 2]:
raise ValueError(f"Invalid stop bits: {stop_bits}")
-
+
# Convert parity to pyserial constants
parity_map = {
'ODD': serial.PARITY_ODD,
@@ -69,18 +69,18 @@ def __init__(self,
'NONE': serial.PARITY_NONE
}
serial_parity = parity_map[parity]
-
+
# Convert stop bits to pyserial constants
serial_stopbits = serial.STOPBITS_TWO if stop_bits == 2 else serial.STOPBITS_ONE
-
+
# Configure flow control
rtscts = (flow_control == 'RTSCTS')
-
+
self.write_timeout = write_timeout
self.read_timeout = read_timeout
self.read_polling_period = read_polling_period
self.read_max_length = read_max_length
-
+
# Open the serial port using pyserial
self.handle = serial.Serial(
port=port_name,
@@ -92,16 +92,16 @@ def __init__(self,
write_timeout=write_timeout,
rtscts=rtscts
)
-
+
self.mutex = threading.Lock()
-
+
def close(self) -> None:
"""Disconnects the driver from the comm port"""
if hasattr(self, 'handle') and self.handle and self.handle.is_open:
with self.mutex:
self.handle.close()
self.handle = None
-
+
def closed(self) -> bool:
"""
Returns:
@@ -116,21 +116,21 @@ def write(self, data: Union[str, bytes]) -> None:
"""
if isinstance(data, str):
data = data.encode('utf-8')
-
+
start_time = time.time()
bytes_to_write = len(data)
total_bytes_written = 0
-
+
while total_bytes_written < bytes_to_write:
bytes_written = self.handle.write(data[total_bytes_written:])
if bytes_written <= 0:
raise RuntimeError("Error writing to comm port")
-
+
total_bytes_written += bytes_written
-
+
# Check for write timeout
- if (self.write_timeout and
- (time.time() - start_time > self.write_timeout) and
+ if (self.write_timeout and
+ (time.time() - start_time > self.write_timeout) and
total_bytes_written < bytes_to_write):
raise TimeoutError("Write Timeout")
@@ -141,7 +141,7 @@ def read(self) -> bytes:
"""
data = b''
sleep_time = 0.0
-
+
while True:
# Inner loop to read available data
while True:
@@ -149,58 +149,58 @@ def read(self) -> bytes:
with self.mutex:
if not self.handle or not self.handle.is_open:
break
-
+
# Read available bytes
available = self.handle.in_waiting
if available > 0:
read_size = min(available, self.read_max_length - len(data))
if read_size > 0:
buffer = self.handle.read(read_size)
-
- if not buffer:
+
+ if buffer is None:
break
-
+
data += buffer
- if (len(buffer) <= 0 or
- len(data) >= self.read_max_length or
- not self.handle or
+ if (len(buffer) <= 0 or
+ len(data) >= self.read_max_length or
+ not self.handle or
not self.handle.is_open):
break
-
+
# Break if we have data or handle is closed
if len(data) > 0 or not self.handle or not self.handle.is_open:
break
-
+
# Check for read timeout
if self.read_timeout and sleep_time >= self.read_timeout:
raise TimeoutError("Read Timeout")
-
+
# Sleep and update sleep time
time.sleep(self.read_polling_period)
sleep_time += self.read_polling_period
-
+
return data
-
+
def read_nonblock(self) -> bytes:
"""
Returns:
[bytes] Binary data read from the serial port
"""
data = b''
-
+
while True:
available = self.handle.in_waiting
if available <= 0:
break
-
+
read_size = min(available, self.read_max_length - len(data))
if read_size <= 0:
break
-
+
buffer = self.handle.read(read_size)
data += buffer
-
+
if len(buffer) <= 0 or len(data) >= self.read_max_length:
break
-
+
return data
\ No newline at end of file
diff --git a/openc3/python/openc3/packets/packet.py b/openc3/python/openc3/packets/packet.py
index 97e421a389..f28376c4d7 100644
--- a/openc3/python/openc3/packets/packet.py
+++ b/openc3/python/openc3/packets/packet.py
@@ -221,7 +221,7 @@ def virtual(self, virtual):
# self.param buffer [String] Raw buffer of binary data
# self.return [Boolean] Whether or not the buffer of data is this packet
def identify(self, buffer):
- if not buffer:
+ if buffer is None:
return False
if self.virtual:
return False
@@ -244,7 +244,7 @@ def identify(self, buffer):
# self.param buffer [String] Raw buffer of binary data
# self.return [Array] Array of read id values in order
def read_id_values(self, buffer):
- if not buffer:
+ if buffer is None:
return []
if not self.id_items:
return []
@@ -275,7 +275,7 @@ def config_name(self):
return self.config_name
@property
- def buffer(self, copy=True):
+ def buffer(self):
return self.allocate_buffer_if_needed()[:]
@buffer.setter
@@ -545,7 +545,7 @@ def get_item(self, name):
# as Strings. 'RAW' values will match their data_type. 'CONVERTED' values
# can be any type.
def read_item(self, item, value_type="CONVERTED", buffer=None, given_raw=None):
- if not buffer:
+ if buffer is None:
buffer = self._buffer
if given_raw:
# Must clone this since value is returned
@@ -641,9 +641,9 @@ def read_item(self, item, value_type="CONVERTED", buffer=None, given_raw=None):
# self.param buffer [String] The binary buffer to read the items from
# self.return Hash of read names and values
def read_items(self, items, value_type="RAW", buffer=None, raw_value=None):
- if not buffer:
+ if buffer is None:
buffer = self._buffer
- if not buffer:
+ if buffer is None:
buffer = self.allocate_buffer_if_needed()
if value_type == "RAW":
result = super().read_items(items, value_type, buffer)
@@ -664,7 +664,7 @@ def read_items(self, items, value_type="RAW", buffer=None, raw_value=None):
# self.param value_type (see #read_item)
# self.param buffer (see Structure#write_item)
def write_item(self, item, value, value_type="CONVERTED", buffer=None):
- if not buffer:
+ if buffer is None:
buffer = self._buffer
match value_type:
case "RAW":
@@ -712,9 +712,9 @@ def write_item(self, item, value, value_type="CONVERTED", buffer=None):
# self.param value_type [Symbol] Value type of each item to write
# self.param buffer [String] The binary buffer to write the values to
def write_items(self, items, values, value_type="RAW", buffer=None):
- if not buffer:
+ if buffer is None:
buffer = self._buffer
- if not buffer:
+ if buffer is None:
buffer = self.allocate_buffer_if_needed()
if value_type == "RAW":
return super().write_items(items, values, value_type, buffer)
@@ -730,7 +730,7 @@ def write_items(self, items, values, value_type="RAW", buffer=None):
# self.param buffer (see #read_item)
# self.return (see #read_item)
def read(self, name, value_type="CONVERTED", buffer=None):
- if not buffer:
+ if buffer is None:
buffer = self._buffer
return super().read(name, value_type, buffer)
@@ -741,7 +741,7 @@ def read(self, name, value_type="CONVERTED", buffer=None):
# self.param value_type (see #write_item)
# self.param buffer (see #write_item)
def write(self, name, value, value_type="CONVERTED", buffer=None):
- if not buffer:
+ if buffer is None:
buffer = self._buffer
super().write(name, value, value_type, buffer)
@@ -753,7 +753,7 @@ def write(self, name, value, value_type="CONVERTED", buffer=None):
# self.param top (See Structure#read_all)
# self.return (see Structure#read_all)
def read_all(self, value_type="CONVERTED", buffer=None, top=True):
- if not buffer:
+ if buffer is None:
buffer = self._buffer
return super().read_all(value_type, buffer, top)
@@ -766,7 +766,7 @@ def read_all(self, value_type="CONVERTED", buffer=None, top=True):
# of [item name, item value, item limits state] where the item limits
# state can be one of {OpenC3:'L'imits='LIMITS_STATES'}
def read_all_with_limits_states(self, value_type="CONVERTED", buffer=None):
- if not buffer:
+ if buffer is None:
buffer = self._buffer
result = None
with self.synchronize_allow_reads(True):
@@ -783,7 +783,7 @@ def read_all_with_limits_states(self, value_type="CONVERTED", buffer=None):
# self.param ignored (see Structure#ignored)
# self.return (see Structure#formatted)
def formatted(self, value_type="CONVERTED", indent=0, buffer=None, ignored=None):
- if not buffer:
+ if buffer is None:
buffer = self._buffer
return super().formatted(value_type, indent, buffer, ignored)
@@ -793,13 +793,13 @@ def formatted(self, value_type="CONVERTED", indent=0, buffer=None, ignored=None)
# self.param skip_item_names [Array] Array of item names to skip
# self.param use_templase [Boolean] Apply template before setting defaults (or not)
def restore_defaults(self, buffer=None, skip_item_names=None, use_template=True):
- if not buffer:
+ if buffer is None:
buffer = self._buffer
- if not buffer:
+ if buffer is None:
buffer = self.allocate_buffer_if_needed()
- if skip_item_names:
+ if skip_item_names is not None:
upcase_skip_item_names = [name.upper() for name in skip_item_names]
- if self.template and use_template:
+ if self.template is not None and use_template:
# Set both the internal buffer and our local copy
self.buffer = self.template
buffer = self._buffer
@@ -1194,7 +1194,7 @@ def decom(self):
# Performs packet specific processing on the packet.
# Intended to only be run once for each packet received
def process(self, buffer=None):
- if not buffer:
+ if buffer is None:
buffer = self._buffer
if not self.processors:
return
@@ -1320,6 +1320,9 @@ def obfuscate(self):
try:
current_value = self.read(item.name, "RAW")
+ if isinstance(current_value, dict):
+ obfuscated_value = {}
+
if isinstance(current_value, list):
# For arrays, create a new array of zeros with the same size
if item.data_type in ["INT", "UINT"]:
@@ -1328,6 +1331,8 @@ def obfuscate(self):
obfuscated_value = [0.0] * len(current_value)
elif item.data_type in ["STRING", "BLOCK"]:
obfuscated_value = ["\x00" * len(val) if val else None for val in current_value]
+ elif item.data_type in ["BOOL", "ARRAY", "OBJECT", "ANY"]:
+ obfuscated_value = []
else:
obfuscated_value = [0] * len(current_value)
@@ -1342,6 +1347,8 @@ def obfuscate(self):
obfuscated_value = 0.0
elif item.data_type == "BLOCK":
obfuscated_value = "\x00" * len(current_value)
+ elif item.data_type == "BOOL":
+ obfuscated_value = False
else:
obfuscated_value = 0
diff --git a/openc3/python/openc3/packets/packet_config.py b/openc3/python/openc3/packets/packet_config.py
index eb328c9bff..5392ae3fd6 100644
--- a/openc3/python/openc3/packets/packet_config.py
+++ b/openc3/python/openc3/packets/packet_config.py
@@ -47,6 +47,8 @@
class PacketConfig:
COMMAND = "Command"
TELEMETRY = "Telemetry"
+ # Note: DERIVED is not a valid converted type. Also TIME is currently only a converted type
+ CONVERTED_DATA_TYPES = ["INT", "UINT", "FLOAT", "STRING", "BLOCK", "BOOL", "OBJECT", "ARRAY", "ANY", "TIME"]
def __init__(self):
self.name = None
@@ -647,8 +649,6 @@ def process_current_packet(self, parser, keyword, params):
case "HIDDEN":
usage = keyword
parser.verify_num_parameters(0, 0, usage)
- if not self.current_packet:
- raise parser.error(f"{keyword} requires a current packet")
if self.current_item:
self.current_item.hidden = True
else:
@@ -856,13 +856,7 @@ def process_current_item(self, parser, keyword, params):
self.converted_bit_size = None
if len(params) == 2:
self.converted_type = params[0].upper()
- if self.converted_type not in [
- "INT",
- "UINT",
- "FLOAT",
- "STRING",
- "BLOCK",
- ]:
+ if self.converted_type not in self.CONVERTED_DATA_TYPES:
raise parser.error(f"Invalid converted_type: {self.converted_type}.")
self.converted_bit_size = int(params[1])
if self.converted_type is None or self.converted_bit_size is None:
diff --git a/openc3/python/openc3/packets/packet_item.py b/openc3/python/openc3/packets/packet_item.py
index ee23b0d6bc..193d965f21 100644
--- a/openc3/python/openc3/packets/packet_item.py
+++ b/openc3/python/openc3/packets/packet_item.py
@@ -20,7 +20,7 @@
from openc3.packets.packet_item_limits import PacketItemLimits
from openc3.utilities.string import quote_if_necessary, simple_formatted
from openc3.conversions.conversion import Conversion
-
+from openc3.config.config_parser import ConfigParser
class PacketItem(StructureItem):
# The allowable state colors
@@ -186,7 +186,7 @@ def units(self, units):
self.__units = None
def check_default_and_range_data_types(self):
- if self.default and not self.write_conversion:
+ if self.default is not None and self.write_conversion is None:
if self.array_size is not None:
if not isinstance(self.default, list):
raise TypeError(
@@ -228,6 +228,15 @@ def check_default_and_range_data_types(self):
raise TypeError(
f"{self.name}: default must be a str but is a {self.default.__class__.__name__}"
)
+ case "ARRAY":
+ if not isinstance(self.default, list):
+ raise TypeError(f"{self.name}: default must be a list but is a {self.default.__class__.__name__}")
+ case "OBJECT":
+ if not isinstance(self.default, dict):
+ raise TypeError(f"{self.name}: default must be a dict but is a {self.default.__class__.__name__}")
+ case "BOOL":
+ if not isinstance(self.default, bool):
+ raise TypeError(f"{self.name}: default must be a bool but is a {self.default.__class__.__name__}")
@property
def hazardous(self):
@@ -500,7 +509,16 @@ def convert(self, value, data_type):
return int(value)
case "FLOAT":
return float(value)
- case "STRING" | "BLOCK":
+ case "STRING":
+ return value
+ case "BLOCK":
+ if isinstance(value, str):
+ return bytearray(value.encode())
+ else:
+ return bytearray(value)
+ case "BOOL":
+ return ConfigParser.handle_true_false(value)
+ case _:
return value
except ValueError:
raise ValueError(f"{self.name}: Invalid value: {value} for data type: {data_type}")
diff --git a/openc3/python/openc3/packets/parsers/packet_item_parser.py b/openc3/python/openc3/packets/parsers/packet_item_parser.py
index af4c873e95..83f4be59f0 100644
--- a/openc3/python/openc3/packets/parsers/packet_item_parser.py
+++ b/openc3/python/openc3/packets/parsers/packet_item_parser.py
@@ -18,6 +18,7 @@
from openc3.config.config_parser import ConfigParser
from openc3.utilities.logger import Logger
from openc3.utilities.extract import hex_to_byte_string, convert_to_value
+from ast import literal_eval
class PacketItemParser:
COMMAND = "Command"
@@ -179,14 +180,15 @@ def _get_minimum(self):
return None
data_type = self._get_data_type()
- if data_type == "STRING" or data_type == "BLOCK":
+ if data_type != "INT" and data_type != "UINT" and data_type != "FLOAT":
return None
index = 3 if self._append() else 4
- if self.parser.parameters[index] == "nil":
+ value = self.parser.parameters[index]
+ if str(value).upper() == "NIL" or str(value).upper() == "NONE":
return None
return ConfigParser.handle_defined_constants(
- convert_to_value(self.parser.parameters[index]),
+ convert_to_value(value),
self._get_data_type(),
self._get_bit_size(),
)
@@ -196,14 +198,15 @@ def _get_maximum(self):
return None
data_type = self._get_data_type()
- if data_type == "STRING" or data_type == "BLOCK":
+ if data_type != "INT" and data_type != "UINT" and data_type != "FLOAT":
return None
index = 4 if self._append() else 5
- if self.parser.parameters[index] == "nil":
+ value = self.parser.parameters[index]
+ if str(value).upper() == "NIL" or str(value).upper() == "NONE":
return None
return ConfigParser.handle_defined_constants(
- convert_to_value(self.parser.parameters[index]),
+ convert_to_value(value),
self._get_data_type(),
self._get_bit_size(),
)
@@ -247,6 +250,41 @@ def _get_default(self):
index = 3 if self._append() else 4
data_type = self._get_data_type()
+ if data_type == "BOOL":
+ value = str(self.parser.parameters[index]).upper()
+ if value == "TRUE" or value == "FALSE":
+ return ConfigParser.handle_true_false(self.parser.parameters[index])
+ else:
+ raise self.parser.error("Default for BOOL data type must be TRUE or FALSE")
+ if data_type == "ARRAY":
+ value = str(self.parser.parameters[index])
+ try:
+ value = literal_eval(value)
+ except Exception:
+ raise self.parser.error(f"Unparsable value for ARRAY: {value}")
+ if isinstance(value, list):
+ return value
+ else:
+ raise self.parser.error("Default for ARRAY data type must be an Array")
+ if data_type == "OBJECT":
+ value = str(self.parser.parameters[index])
+ try:
+ value = literal_eval(value)
+ except Exception:
+ raise self.parser.error(f"Unparsable value for OBJECT: {value}")
+ if isinstance(value, dict):
+ return value
+ else:
+ raise self.parser.error("Default for OBJECT data type must be a Hash")
+ if data_type == "ANY":
+ value = str(self.parser.parameters[index])
+ if len(value) > 0:
+ try:
+ return literal_eval(value)
+ except Exception:
+ return value
+ else:
+ return ""
if data_type == "STRING" or data_type == "BLOCK":
return self._convert_string_value(index)
else:
@@ -270,6 +308,41 @@ def _get_id_value(self, item):
return item.default
index = 3 if self._append() else 4
+ if data_type == "BOOL":
+ value = str(self.parser.parameters[index]).upper()
+ if value == "TRUE" or value == "FALSE":
+ return ConfigParser.handle_true_false(self.parser.parameters[index])
+ else:
+ raise self.parser.error("ID Value for BOOL data type must be TRUE or FALSE")
+ if data_type == "ARRAY":
+ value = str(self.parser.parameters[index])
+ try:
+ value = literal_eval(value)
+ except Exception:
+ raise self.parser.error(f"Unparsable value for ARRAY: {value}")
+ if isinstance(value, list):
+ return value
+ else:
+ raise self.parser.error("ID Value for ARRAY data type must be an Array")
+ if data_type == "OBJECT":
+ value = str(self.parser.parameters[index])
+ try:
+ value = literal_eval(value)
+ except Exception:
+ raise self.parser.error(f"Unparsable value for OBJECT: {value}")
+ if isinstance(value, dict):
+ return value
+ else:
+ raise self.parser.error("ID Value for OBJECT data type must be a Hash")
+ if data_type == "ANY":
+ value = str(self.parser.parameters[index])
+ if len(value) > 0:
+ try:
+ return literal_eval(value)
+ except Exception:
+ return value
+ else:
+ return ""
if data_type == "STRING" or data_type == "BLOCK":
return self._convert_string_value(index)
else:
@@ -314,24 +387,23 @@ def _type_usage(self):
keyword = self.parser.keyword or ""
# Item type usage is simple so just return it
if "ITEM" in keyword:
- return " "
+ return " "
# Build up the parameter type usage based on the keyword
usage = " "
+ usage += "INT/UINT/FLOAT/STRING/BLOCK/BOOL/OBJECT/ANY> "
else:
try:
data_type = self._get_data_type()
except TypeError:
# If the data type could not be determined set something
data_type = "INT"
- # STRING and BLOCK types do not have min or max values
- if data_type == "STRING" or data_type == "BLOCK":
- usage += "STRING/BLOCK> "
+ if data_type == "INT" or data_type == "UINT" or data_type == "FLOAT" or data_type == "DERIVED":
+ usage += "INT/UINT/FLOAT/DERIVED> "
else:
- usage += "INT/UINT/FLOAT> "
+ usage += "STRING/BLOCK/BOOL/ARRAY/OBJECT/ANY> "
# ID Values do not have default values
if "ID" not in keyword:
usage += " "
diff --git a/openc3/python/openc3/packets/structure.py b/openc3/python/openc3/packets/structure.py
index 9467f4209b..d73bb47598 100644
--- a/openc3/python/openc3/packets/structure.py
+++ b/openc3/python/openc3/packets/structure.py
@@ -82,7 +82,7 @@ def length(self):
# Resize the buffer at least the defined length of the structure
def resize_buffer(self):
- if self._buffer:
+ if self._buffer is not None:
# Extend data size
if len(self._buffer) < self.defined_length:
self._buffer += Structure.ZERO_STRING * (self.defined_length - len(self._buffer))
@@ -112,15 +112,15 @@ def accessor(self, accessor):
# self.param buffer [String] The binary buffer to read the item from
# self.return Hash of read names and values
def read_items(self, items, value_type="RAW", buffer=None):
- if not buffer:
+ if buffer is None:
buffer = self._buffer
- if not buffer:
+ if buffer is None:
buffer = self.allocate_buffer_if_needed()
return self.accessor.read_items(items, buffer)
# Allocate a buffer if not available
def allocate_buffer_if_needed(self):
- if not self._buffer:
+ if self._buffer is None:
self._buffer = bytearray(Structure.ZERO_STRING * self.defined_length)
return self._buffer
@@ -244,7 +244,7 @@ def define(self, item):
self.defined_length += 1
# Resize the buffer if necessary
- if self.buffer:
+ if self.buffer is not None:
self.resize_buffer()
return item
@@ -357,9 +357,9 @@ def delete_item(self, name):
# parameter to check whether to perform conversions on the item.
# self.param buffer [String] The binary buffer to write the value to
def write_item(self, item, value, value_type="RAW", buffer=None):
- if not buffer:
+ if buffer is None:
buffer = self._buffer
- if not buffer:
+ if buffer is None:
buffer = self.allocate_buffer_if_needed()
self.accessor.write_item(item, value, buffer)
@@ -371,9 +371,9 @@ def write_item(self, item, value, value_type="RAW", buffer=None):
# parameter to check whether to perform conversions on the item.
# self.param buffer [String] The binary buffer to write the values to
def write_items(self, items, values, value_type="RAW", buffer=None):
- if not buffer:
+ if buffer is None:
buffer = self._buffer
- if not buffer:
+ if buffer is None:
buffer = self.allocate_buffer_if_needed()
self.accessor.write_items(items, values, buffer)
@@ -386,7 +386,7 @@ def write_items(self, items, values, value_type="RAW", buffer=None):
# self.return Value based on the item definition. This could be an integer,
# float, or array of values.
def read(self, name, value_type="RAW", buffer=None):
- if not buffer:
+ if buffer is None:
buffer = self._buffer
return self.read_item(self.get_item(name), value_type, buffer)
@@ -399,7 +399,7 @@ def read(self, name, value_type="RAW", buffer=None):
# parameter to check whether to perform conversions on the item.
# self.param buffer [String] The binary buffer to write the value to
def write(self, name, value, value_type="RAW", buffer=None):
- if not buffer:
+ if buffer is None:
buffer = self._buffer
self.write_item(self.get_item(name), value, value_type, buffer)
@@ -413,7 +413,7 @@ def write(self, name, value, value_type="RAW", buffer=None):
# self.return [Array] Array of two element arrays containing the item
# name as element 0 and item value as element 1.
def read_all(self, value_type="RAW", buffer=None, top=True):
- if not buffer:
+ if buffer is None:
buffer = self._buffer
item_array = []
with self.synchronize_allow_reads(top):
@@ -431,7 +431,7 @@ def read_all(self, value_type="RAW", buffer=None, top=True):
# self.param ignored [Array] List of items to ignore when building the string
# self.return [String] String formatted with all the item names and values
def formatted(self, value_type="RAW", indent=0, buffer=None, ignored=None):
- if not buffer:
+ if buffer is None:
buffer = self._buffer
indent_string = " " * indent
string = ""
diff --git a/openc3/python/openc3/packets/structure_item.py b/openc3/python/openc3/packets/structure_item.py
index 08426ae243..bc19164da1 100644
--- a/openc3/python/openc3/packets/structure_item.py
+++ b/openc3/python/openc3/packets/structure_item.py
@@ -24,7 +24,7 @@ class StructureItem:
create_index = 0
# Valid data types adds DERIVED to those defined by BinaryAccessor
- DATA_TYPES = BinaryAccessor.DATA_TYPES + ["DERIVED"]
+ DATA_TYPES = ["INT", "UINT", "FLOAT", "STRING", "BLOCK", "BOOL", "OBJECT", "ARRAY", "ANY", "DERIVED"]
# Create a StructureItem by setting all the attributes. It
# calls all the setter routines to do the attribute verification and then
@@ -169,9 +169,9 @@ def data_type(self, data_type):
raise TypeError(
f"{self.name}: data_type must be a str but {data_type} is a {type(data_type).__name__}"
)
- if data_type not in StructureItem.DATA_TYPES:
+ if data_type not in self.DATA_TYPES:
raise ValueError(
- f"{self.name}: unknown data_type: {data_type} - Must be 'INT', 'UINT', 'FLOAT', 'STRING', 'BLOCK', or 'DERIVED'"
+ f"{self.name}: unknown data_type: {data_type} - Must be {', '.join(self.DATA_TYPES)}"
)
self.__data_type = data_type
diff --git a/openc3/python/openc3/tools/table_manager/table_config.py b/openc3/python/openc3/tools/table_manager/table_config.py
index ba7ee638cb..74a27e1bf7 100644
--- a/openc3/python/openc3/tools/table_manager/table_config.py
+++ b/openc3/python/openc3/tools/table_manager/table_config.py
@@ -15,6 +15,7 @@
# if purchased from OpenC3, Inc.
import os
+from ast import literal_eval
from openc3.config.config_parser import ConfigParser
from openc3.packets.packet_config import PacketConfig
from openc3.tools.table_manager.table import Table
@@ -295,6 +296,13 @@ def finish_packet(self):
item.default = float(self.defaults[index])
elif item.data_type in ("STRING", "BLOCK"):
item.default = self.defaults[index]
+ elif item.data_type == "BOOL":
+ item.default = ConfigParser.handle_true_false(self.defaults[index])
+ elif item.data_type in ("ARRAY", "OBJECT", "ANY"):
+ try:
+ item.default = literal_eval(self.defaults[index])
+ except Exception:
+ item.default = self.defaults[index]
# Reset defaults after processing them
self.defaults = []
diff --git a/openc3/python/test/accessors/test_accessor.py b/openc3/python/test/accessors/test_accessor.py
new file mode 100644
index 0000000000..23ee5fcb71
--- /dev/null
+++ b/openc3/python/test/accessors/test_accessor.py
@@ -0,0 +1,131 @@
+# Copyright 2025 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 addums 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.
+
+import unittest
+from unittest.mock import Mock
+from openc3.accessors.accessor import Accessor
+
+
+class TestAccessor(unittest.TestCase):
+ def test_returns_none_for_none_values(self):
+ item = Mock()
+ item.data_type = "INT"
+ self.assertIsNone(Accessor.convert_to_type(None, item))
+
+ def test_converts_bool_values_from_strings(self):
+ item = Mock()
+ item.data_type = "BOOL"
+ self.assertEqual(Accessor.convert_to_type("True", item), True)
+ self.assertEqual(Accessor.convert_to_type("true", item), True)
+ self.assertEqual(Accessor.convert_to_type("False", item), False)
+ self.assertEqual(Accessor.convert_to_type("false", item), False)
+ self.assertEqual(Accessor.convert_to_type(True, item), True)
+ self.assertEqual(Accessor.convert_to_type(False, item), False)
+
+ def test_converts_array_values_from_strings(self):
+ item = Mock()
+ item.data_type = "ARRAY"
+ self.assertEqual(Accessor.convert_to_type("[1, 2, 3]", item), [1, 2, 3])
+ self.assertEqual(
+ Accessor.convert_to_type('["a", "b", "c"]', item), ["a", "b", "c"]
+ )
+ self.assertEqual(Accessor.convert_to_type([1, 2, 3], item), [1, 2, 3])
+
+ def test_converts_object_values_from_strings(self):
+ item = Mock()
+ item.data_type = "OBJECT"
+ self.assertEqual(
+ Accessor.convert_to_type('{"key": "value"}', item), {"key": "value"}
+ )
+ self.assertEqual(Accessor.convert_to_type('{"num": 123}', item), {"num": 123})
+ self.assertEqual(
+ Accessor.convert_to_type({"key": "value"}, item), {"key": "value"}
+ )
+
+ def test_converts_any_values_from_strings(self):
+ item = Mock()
+ item.data_type = "ANY"
+ self.assertEqual(Accessor.convert_to_type('"text"', item), "text")
+ self.assertEqual(Accessor.convert_to_type("123", item), 123)
+ self.assertEqual(Accessor.convert_to_type("[1, 2, 3]", item), [1, 2, 3])
+ self.assertEqual(
+ Accessor.convert_to_type('{"key": "value"}', item), {"key": "value"}
+ )
+ self.assertEqual(Accessor.convert_to_type("invalid json", item), "invalid json")
+ self.assertEqual(Accessor.convert_to_type(123, item), 123)
+ self.assertEqual(Accessor.convert_to_type([1, 2, 3], item), [1, 2, 3])
+
+ def test_converts_string_values_with_array_size_from_strings(self):
+ item = Mock()
+ item.data_type = "STRING"
+ item.array_size = 10
+ self.assertEqual(Accessor.convert_to_type('["a", "b"]', item), ["a", "b"])
+
+ def test_converts_string_values_without_array_size(self):
+ item = Mock()
+ item.data_type = "STRING"
+ item.array_size = None
+ self.assertEqual(Accessor.convert_to_type("test", item), "test")
+ self.assertEqual(Accessor.convert_to_type('["a", "b"]', item), '["a", "b"]')
+
+ def test_converts_block_values(self):
+ item = Mock()
+ item.data_type = "BLOCK"
+ item.array_size = None
+ self.assertEqual(Accessor.convert_to_type(b"\x01\x02\x03", item), b"\x01\x02\x03")
+ self.assertEqual(Accessor.convert_to_type("test", item), bytearray(b"test"))
+
+ def test_converts_int_values(self):
+ item = Mock()
+ item.data_type = "INT"
+ item.array_size = None
+ self.assertEqual(Accessor.convert_to_type(42, item), 42)
+ self.assertEqual(Accessor.convert_to_type("42", item), 42)
+ self.assertEqual(Accessor.convert_to_type(-10, item), -10)
+ self.assertEqual(Accessor.convert_to_type("-10", item), -10)
+
+ def test_converts_uint_values(self):
+ item = Mock()
+ item.data_type = "UINT"
+ item.array_size = None
+ self.assertEqual(Accessor.convert_to_type(42, item), 42)
+ self.assertEqual(Accessor.convert_to_type("42", item), 42)
+ self.assertEqual(Accessor.convert_to_type(0, item), 0)
+
+ def test_converts_float_values(self):
+ item = Mock()
+ item.data_type = "FLOAT"
+ item.array_size = None
+ self.assertEqual(Accessor.convert_to_type(3.14, item), 3.14)
+ self.assertEqual(Accessor.convert_to_type("3.14", item), 3.14)
+ self.assertEqual(Accessor.convert_to_type(0.0, item), 0.0)
+ self.assertEqual(Accessor.convert_to_type(42, item), 42.0)
+
+ def test_converts_int_array_values(self):
+ item = Mock()
+ item.data_type = "INT"
+ item.array_size = 12
+ self.assertEqual(Accessor.convert_to_type("[1, 2, 3]", item), [1, 2, 3])
+ self.assertEqual(Accessor.convert_to_type([1, 2, 3], item), [1, 2, 3])
+
+ def test_converts_float_array_values(self):
+ item = Mock()
+ item.data_type = "FLOAT"
+ item.array_size = 24
+ self.assertEqual(
+ Accessor.convert_to_type("[1.1, 2.2, 3.3]", item), [1.1, 2.2, 3.3]
+ )
+ self.assertEqual(Accessor.convert_to_type([1.1, 2.2, 3.3], item), [1.1, 2.2, 3.3])
diff --git a/openc3/python/test/accessors/test_cbor_accessor.py b/openc3/python/test/accessors/test_cbor_accessor.py
index 926d70003e..c4b305b52d 100644
--- a/openc3/python/test/accessors/test_cbor_accessor.py
+++ b/openc3/python/test/accessors/test_cbor_accessor.py
@@ -337,8 +337,8 @@ def test_should_write_different_types(self):
self.assertEqual(CborAccessor.class_read_item(item, self.data2), ({"happy": "sad"}))
item = self.Cbor("item", "$[1].packet.item5.happy", "OBJECT", None)
- CborAccessor.class_write_item(item, "art", self.data2)
- self.assertEqual(CborAccessor.class_read_item(item, self.data2), "art")
+ CborAccessor.class_write_item(item, "{'ryan': 'hello'}", self.data2)
+ self.assertEqual(CborAccessor.class_read_item(item, self.data2), {'ryan': 'hello'})
item = self.Cbor("item", "$[1].packet.item4[3]", "INT", None)
CborAccessor.class_write_item(item, 14, self.data2)
diff --git a/openc3/python/test/packets/parsers/test_packet_item_parser.py b/openc3/python/test/packets/parsers/test_packet_item_parser.py
index 6fa95f68d7..d68258eee7 100644
--- a/openc3/python/test/packets/parsers/test_packet_item_parser.py
+++ b/openc3/python/test/packets/parsers/test_packet_item_parser.py
@@ -153,6 +153,100 @@ def test_accepts_types_int_uint_float_string_block(self):
self.assertEqual(self.pc.telemetry["TGT1"]["PKT1"].id_items, id_items)
tf.close()
+ def test_accepts_types_bool_array_object_any(self):
+ tf = tempfile.NamedTemporaryFile(mode="w")
+ tf.write('COMMAND tgt1 pkt1 LITTLE_ENDIAN "Description"\n')
+ tf.write(" PARAMETER ITEM1 0 0 BOOL TRUE\n")
+ tf.write(" APPEND_PARAMETER ITEM2 0 BOOL FALSE\n")
+ tf.write(" APPEND_ID_PARAMETER ITEM3 0 BOOL TRUE\n")
+ tf.write(" APPEND_PARAMETER ITEM4 0 ARRAY [1,2,3]\n")
+ tf.write(' APPEND_ID_PARAMETER ITEM5 0 ARRAY ["a","b"]\n')
+ tf.write(' APPEND_PARAMETER ITEM6 0 OBJECT {"key":"value"}\n')
+ tf.write(' APPEND_ID_PARAMETER ITEM7 0 OBJECT {"test":123}\n')
+ tf.write(' APPEND_PARAMETER ITEM8 0 ANY "text"\n')
+ tf.write(" APPEND_ID_PARAMETER ITEM9 0 ANY 456\n")
+ tf.seek(0)
+ self.pc.process_file(tf.name, "TGT1")
+ packet = self.pc.commands["TGT1"]["PKT1"]
+ self.assertTrue(
+ set(["ITEM1", "ITEM2", "ITEM3", "ITEM4", "ITEM5", "ITEM6", "ITEM7", "ITEM8", "ITEM9"]).issubset(
+ set(packet.items.keys())
+ )
+ )
+ self.assertEqual(packet.items["ITEM1"].default, True)
+ self.assertEqual(packet.items["ITEM2"].default, False)
+ self.assertEqual(packet.items["ITEM3"].id_value, True)
+ self.assertEqual(packet.items["ITEM4"].default, [1, 2, 3])
+ self.assertEqual(packet.items["ITEM5"].id_value, ["a", "b"])
+ self.assertEqual(packet.items["ITEM6"].default, {"key": "value"})
+ self.assertEqual(packet.items["ITEM7"].id_value, {"test": 123})
+ self.assertEqual(packet.items["ITEM8"].default, "text")
+ self.assertEqual(packet.items["ITEM9"].id_value, 456)
+ tf.close()
+
+ def test_complains_about_invalid_bool_values(self):
+ tf = tempfile.NamedTemporaryFile(mode="w")
+ tf.write('COMMAND tgt1 pkt1 LITTLE_ENDIAN "Description"\n')
+ tf.write(" PARAMETER ITEM1 0 0 BOOL 1\n")
+ tf.seek(0)
+ with self.assertRaisesRegex(
+ ConfigParser.Error, "Default for BOOL data type must be TRUE or FALSE"
+ ):
+ self.pc.process_file(tf.name, "TGT1")
+ tf.close()
+
+ tf = tempfile.NamedTemporaryFile(mode="w")
+ tf.write('TELEMETRY tgt1 pkt1 LITTLE_ENDIAN "Description"\n')
+ tf.write(" APPEND_ID_ITEM ITEM1 0 BOOL invalid\n")
+ tf.seek(0)
+ with self.assertRaisesRegex(
+ ConfigParser.Error, "ID Value for BOOL data type must be TRUE or FALSE"
+ ):
+ self.pc.process_file(tf.name, "TGT1")
+ tf.close()
+
+ def test_complains_about_invalid_array_values(self):
+ tf = tempfile.NamedTemporaryFile(mode="w")
+ tf.write('COMMAND tgt1 pkt1 LITTLE_ENDIAN "Description"\n')
+ tf.write(" PARAMETER ITEM1 0 0 ARRAY notarray\n")
+ tf.seek(0)
+ with self.assertRaisesRegex(
+ ConfigParser.Error, "Unparsable value for ARRAY: notarray"
+ ):
+ self.pc.process_file(tf.name, "TGT1")
+ tf.close()
+
+ tf = tempfile.NamedTemporaryFile(mode="w")
+ tf.write('TELEMETRY tgt1 pkt1 LITTLE_ENDIAN "Description"\n')
+ tf.write(' APPEND_ID_ITEM ITEM1 0 ARRAY "string"\n')
+ tf.seek(0)
+ with self.assertRaisesRegex(
+ ConfigParser.Error, "Unparsable value for ARRAY: string"
+ ):
+ self.pc.process_file(tf.name, "TGT1")
+ tf.close()
+
+ def test_complains_about_invalid_object_values(self):
+ tf = tempfile.NamedTemporaryFile(mode="w")
+ tf.write('COMMAND tgt1 pkt1 LITTLE_ENDIAN "Description"\n')
+ tf.write(" PARAMETER ITEM1 0 0 OBJECT notobject\n")
+ tf.seek(0)
+ with self.assertRaisesRegex(
+ ConfigParser.Error, "Unparsable value for OBJECT: notobject"
+ ):
+ self.pc.process_file(tf.name, "TGT1")
+ tf.close()
+
+ tf = tempfile.NamedTemporaryFile(mode="w")
+ tf.write('TELEMETRY tgt1 pkt1 LITTLE_ENDIAN "Description"\n')
+ tf.write(" APPEND_ID_ITEM ITEM1 0 OBJECT [1,2,3]\n")
+ tf.seek(0)
+ with self.assertRaisesRegex(
+ ConfigParser.Error, "ID Value for OBJECT data type must be a Hash"
+ ):
+ self.pc.process_file(tf.name, "TGT1")
+ tf.close()
+
def test_supports_arbitrary_endianness_per_item(self):
tf = tempfile.NamedTemporaryFile(mode="w")
tf.write('TELEMETRY tgt1 pkt1 LITTLE_ENDIAN "Description"\n')
diff --git a/openc3/python/test/packets/test_packet_item.py b/openc3/python/test/packets/test_packet_item.py
index 76a09de50f..3a5dbff72e 100644
--- a/openc3/python/test/packets/test_packet_item.py
+++ b/openc3/python/test/packets/test_packet_item.py
@@ -340,6 +340,66 @@ def test_complains_about_default_not_matching_data_type(self):
pi.default = ""
pi.check_default_and_range_data_types()
+ def test_complains_about_bool_default_not_matching_data_type(self):
+ pi = PacketItem("test", 0, 0, "BOOL", "BIG_ENDIAN", None)
+ pi.default = "true"
+ with self.assertRaisesRegex(
+ TypeError, "TEST: default must be a bool but is a str"
+ ):
+ pi.check_default_and_range_data_types()
+ pi = PacketItem("test", 0, 0, "BOOL", "BIG_ENDIAN", None)
+ pi.default = 1
+ with self.assertRaisesRegex(
+ TypeError, "TEST: default must be a bool but is a int"
+ ):
+ pi.check_default_and_range_data_types()
+ pi = PacketItem("test", 0, 0, "BOOL", "BIG_ENDIAN", None)
+ pi.default = True
+ pi.check_default_and_range_data_types()
+ pi = PacketItem("test", 0, 0, "BOOL", "BIG_ENDIAN", None)
+ pi.default = False
+ pi.check_default_and_range_data_types()
+
+ def test_complains_about_array_default_not_matching_data_type(self):
+ pi = PacketItem("test", 0, 0, "ARRAY", "BIG_ENDIAN", None)
+ pi.default = "[]"
+ with self.assertRaisesRegex(
+ TypeError, "TEST: default must be a list but is a str"
+ ):
+ pi.check_default_and_range_data_types()
+ pi = PacketItem("test", 0, 0, "ARRAY", "BIG_ENDIAN", None)
+ pi.default = {}
+ with self.assertRaisesRegex(
+ TypeError, "TEST: default must be a list but is a dict"
+ ):
+ pi.check_default_and_range_data_types()
+ pi = PacketItem("test", 0, 0, "ARRAY", "BIG_ENDIAN", None)
+ pi.default = []
+ pi.check_default_and_range_data_types()
+ pi = PacketItem("test", 0, 0, "ARRAY", "BIG_ENDIAN", None)
+ pi.default = [1, 2, 3]
+ pi.check_default_and_range_data_types()
+
+ def test_complains_about_object_default_not_matching_data_type(self):
+ pi = PacketItem("test", 0, 0, "OBJECT", "BIG_ENDIAN", None)
+ pi.default = "{}"
+ with self.assertRaisesRegex(
+ TypeError, "TEST: default must be a dict but is a str"
+ ):
+ pi.check_default_and_range_data_types()
+ pi = PacketItem("test", 0, 0, "OBJECT", "BIG_ENDIAN", None)
+ pi.default = []
+ with self.assertRaisesRegex(
+ TypeError, "TEST: default must be a dict but is a list"
+ ):
+ pi.check_default_and_range_data_types()
+ pi = PacketItem("test", 0, 0, "OBJECT", "BIG_ENDIAN", None)
+ pi.default = {}
+ pi.check_default_and_range_data_types()
+ pi = PacketItem("test", 0, 0, "OBJECT", "BIG_ENDIAN", None)
+ pi.default = {"key": "value"}
+ pi.check_default_and_range_data_types()
+
def test_complains_about_range_not_matching_data_type(self):
pi = PacketItem("test", 0, 32, "UINT", "BIG_ENDIAN", None)
pi.default = 5
diff --git a/openc3/python/test/packets/test_structure_item.py b/openc3/python/test/packets/test_structure_item.py
index 2c6e400600..0715957af1 100644
--- a/openc3/python/test/packets/test_structure_item.py
+++ b/openc3/python/test/packets/test_structure_item.py
@@ -96,7 +96,7 @@ def test_accepts_data_types(self):
def test_complains_about_bad_data_type(self):
self.assertRaisesRegex(
ValueError,
- "TEST: unknown data_type: UNKNOWN - Must be 'INT', 'UINT', 'FLOAT', 'STRING', 'BLOCK', or 'DERIVED'",
+ "TEST: unknown data_type: UNKNOWN - Must be INT, UINT, FLOAT, STRING, BLOCK, BOOL, OBJECT, ARRAY, ANY, DERIVED",
StructureItem,
"TEST",
0,
diff --git a/openc3/python/test/utilities/test_logger.py b/openc3/python/test/utilities/test_logger.py
index 083d920957..d40adb8ccb 100644
--- a/openc3/python/test/utilities/test_logger.py
+++ b/openc3/python/test/utilities/test_logger.py
@@ -111,13 +111,13 @@ def test_log_message_includes_required_fields(self):
"""Test that log_message includes all required fields in output"""
orig_stdout = sys.stdout
sys.stdout = StringIO()
-
+
logger = Logger()
logger.log_message("INFO", "Test message", scope="TEST", user=None, type=Logger.LOG, url=None)
-
+
output = sys.stdout.getvalue()
sys.stdout = orig_stdout
-
+
data = json.loads(output)
self.assertEqual(data["level"], "INFO")
self.assertEqual(data["message"], "Test message")
@@ -129,14 +129,14 @@ def test_log_message_with_microservice_name(self):
"""Test that microservice_name is included when set"""
orig_stdout = sys.stdout
sys.stdout = StringIO()
-
+
logger = Logger()
logger.microservice_name = "test-service"
logger.log_message("INFO", "Test", scope="TEST", user=None, type=Logger.LOG, url=None)
-
+
output = sys.stdout.getvalue()
sys.stdout = orig_stdout
-
+
data = json.loads(output)
self.assertEqual(data["microservice_name"], "test-service")
@@ -144,14 +144,14 @@ def test_log_message_without_microservice_name(self):
"""Test that microservice_name is omitted when None"""
orig_stdout = sys.stdout
sys.stdout = StringIO()
-
+
logger = Logger()
logger.microservice_name = None
logger.log_message("INFO", "Test", scope="TEST", user=None, type=Logger.LOG, url=None)
-
+
output = sys.stdout.getvalue()
sys.stdout = orig_stdout
-
+
data = json.loads(output)
self.assertNotIn("microservice_name", data)
@@ -159,14 +159,14 @@ def test_log_message_with_detail_string(self):
"""Test that detail is included when detail_string is set"""
orig_stdout = sys.stdout
sys.stdout = StringIO()
-
+
logger = Logger()
logger.detail_string = "Additional details"
logger.log_message("INFO", "Test", scope="TEST", user=None, type=Logger.LOG, url=None)
-
+
output = sys.stdout.getvalue()
sys.stdout = orig_stdout
-
+
data = json.loads(output)
self.assertEqual(data["detail"], "Additional details")
@@ -174,14 +174,14 @@ def test_log_message_without_detail_string(self):
"""Test that detail is omitted when detail_string is None"""
orig_stdout = sys.stdout
sys.stdout = StringIO()
-
+
logger = Logger()
logger.detail_string = None
logger.log_message("INFO", "Test", scope="TEST", user=None, type=Logger.LOG, url=None)
-
+
output = sys.stdout.getvalue()
sys.stdout = orig_stdout
-
+
data = json.loads(output)
self.assertNotIn("detail", data)
@@ -189,13 +189,13 @@ def test_log_message_with_user(self):
"""Test that user is included when provided"""
orig_stdout = sys.stdout
sys.stdout = StringIO()
-
+
logger = Logger()
logger.log_message("INFO", "Test", scope="TEST", user="testuser", type=Logger.LOG, url=None)
-
+
output = sys.stdout.getvalue()
sys.stdout = orig_stdout
-
+
data = json.loads(output)
self.assertEqual(data["user"], "testuser")
@@ -203,13 +203,13 @@ def test_log_message_without_user(self):
"""Test that user is omitted when None"""
orig_stdout = sys.stdout
sys.stdout = StringIO()
-
+
logger = Logger()
logger.log_message("INFO", "Test", scope="TEST", user=None, type=Logger.LOG, url=None)
-
+
output = sys.stdout.getvalue()
sys.stdout = orig_stdout
-
+
data = json.loads(output)
self.assertNotIn("user", data)
@@ -217,13 +217,13 @@ def test_log_message_with_type(self):
"""Test that type is included when provided"""
orig_stdout = sys.stdout
sys.stdout = StringIO()
-
+
logger = Logger()
logger.log_message("INFO", "Test", scope="TEST", user=None, type="notification", url=None)
-
+
output = sys.stdout.getvalue()
sys.stdout = orig_stdout
-
+
data = json.loads(output)
self.assertEqual(data["type"], "notification")
@@ -231,13 +231,13 @@ def test_log_message_without_type(self):
"""Test that type is omitted when None"""
orig_stdout = sys.stdout
sys.stdout = StringIO()
-
+
logger = Logger()
logger.log_message("INFO", "Test", scope="TEST", user=None, type=None, url=None)
-
+
output = sys.stdout.getvalue()
sys.stdout = orig_stdout
-
+
data = json.loads(output)
self.assertNotIn("type", data)
@@ -245,13 +245,13 @@ def test_log_message_with_url(self):
"""Test that url is included when provided"""
orig_stdout = sys.stdout
sys.stdout = StringIO()
-
+
logger = Logger()
logger.log_message("INFO", "Test", scope="TEST", user=None, type=Logger.LOG, url="http://example.com")
-
+
output = sys.stdout.getvalue()
sys.stdout = orig_stdout
-
+
data = json.loads(output)
self.assertEqual(data["url"], "http://example.com")
@@ -259,13 +259,13 @@ def test_log_message_without_url(self):
"""Test that url is omitted when None"""
orig_stdout = sys.stdout
sys.stdout = StringIO()
-
+
logger = Logger()
logger.log_message("INFO", "Test", scope="TEST", user=None, type=Logger.LOG, url=None)
-
+
output = sys.stdout.getvalue()
sys.stdout = orig_stdout
-
+
data = json.loads(output)
self.assertNotIn("url", data)
@@ -273,14 +273,14 @@ def test_log_message_with_other_dict(self):
"""Test that other dict merges additional fields"""
orig_stdout = sys.stdout
sys.stdout = StringIO()
-
+
logger = Logger()
other = {"request_id": "12345", "custom_field": "custom_value"}
logger.log_message("INFO", "Test", scope="TEST", user=None, type=Logger.LOG, url=None, other=other)
-
+
output = sys.stdout.getvalue()
sys.stdout = orig_stdout
-
+
data = json.loads(output)
self.assertEqual(data["request_id"], "12345")
self.assertEqual(data["custom_field"], "custom_value")
@@ -289,36 +289,32 @@ def test_log_message_with_nested_other_dict(self):
"""Test that nested structures in other dict are preserved"""
orig_stdout = sys.stdout
sys.stdout = StringIO()
-
+
logger = Logger()
other = {
- "metadata": {
- "source": "test",
- "version": "1.0"
- },
- "tags": ["error", "critical"]
+ "metadata": "true",
+ "tag": "error"
}
logger.log_message("INFO", "Test", scope="TEST", user=None, type=Logger.LOG, url=None, other=other)
-
+
output = sys.stdout.getvalue()
sys.stdout = orig_stdout
-
+
data = json.loads(output)
- self.assertEqual(data["metadata"]["source"], "test")
- self.assertEqual(data["metadata"]["version"], "1.0")
- self.assertEqual(data["tags"], ["error", "critical"])
+ self.assertEqual(data["metadata"], "true")
+ self.assertEqual(data["tag"], "error")
def test_log_message_without_other(self):
"""Test that other is handled when None"""
orig_stdout = sys.stdout
sys.stdout = StringIO()
-
+
logger = Logger()
logger.log_message("INFO", "Test", scope="TEST", user=None, type=Logger.LOG, url=None, other=None)
-
+
output = sys.stdout.getvalue()
sys.stdout = orig_stdout
-
+
data = json.loads(output)
# Should only have standard fields
self.assertIn("level", data)
@@ -328,13 +324,13 @@ def test_log_message_with_none_message(self):
"""Test that message can be None"""
orig_stdout = sys.stdout
sys.stdout = StringIO()
-
+
logger = Logger()
logger.log_message("INFO", None, scope="TEST", user=None, type=Logger.LOG, url=None)
-
+
output = sys.stdout.getvalue()
sys.stdout = orig_stdout
-
+
data = json.loads(output)
self.assertNotIn("message", data)
@@ -346,23 +342,23 @@ def test_log_message_stdout_when_stderr_not_enabled(self):
import importlib
import openc3.environment
importlib.reload(openc3.environment)
-
+
orig_stdout = sys.stdout
orig_stderr = sys.stderr
sys.stdout = StringIO()
sys.stderr = StringIO()
-
+
logger = Logger()
logger.log_message("WARN", "Warning", scope="TEST", user=None, type=Logger.LOG, url=None)
logger.log_message("ERROR", "Error", scope="TEST", user=None, type=Logger.LOG, url=None)
logger.log_message("FATAL", "Fatal", scope="TEST", user=None, type=Logger.LOG, url=None)
-
+
stdout_output = sys.stdout.getvalue()
stderr_output = sys.stderr.getvalue()
-
+
sys.stdout = orig_stdout
sys.stderr = orig_stderr
-
+
# All should go to stdout
self.assertIn("Warning", stdout_output)
self.assertIn("Error", stdout_output)
@@ -376,16 +372,16 @@ def test_log_message_stderr_when_enabled_for_warn(self):
orig_stderr = sys.stderr
sys.stdout = StringIO()
sys.stderr = StringIO()
-
+
logger = Logger()
logger.log_message("WARN", "Warning", scope="TEST", user=None, type=Logger.LOG, url=None)
-
+
stdout_output = sys.stdout.getvalue()
stderr_output = sys.stderr.getvalue()
-
+
sys.stdout = orig_stdout
sys.stderr = orig_stderr
-
+
self.assertEqual(stdout_output, "")
self.assertIn("Warning", stderr_output)
data = json.loads(stderr_output)
@@ -398,16 +394,16 @@ def test_log_message_stderr_when_enabled_for_error(self):
orig_stderr = sys.stderr
sys.stdout = StringIO()
sys.stderr = StringIO()
-
+
logger = Logger()
logger.log_message("ERROR", "Error message", scope="TEST", user=None, type=Logger.LOG, url=None)
-
+
stdout_output = sys.stdout.getvalue()
stderr_output = sys.stderr.getvalue()
-
+
sys.stdout = orig_stdout
sys.stderr = orig_stderr
-
+
self.assertEqual(stdout_output, "")
self.assertIn("Error message", stderr_output)
@@ -418,16 +414,16 @@ def test_log_message_stderr_when_enabled_for_fatal(self):
orig_stderr = sys.stderr
sys.stdout = StringIO()
sys.stderr = StringIO()
-
+
logger = Logger()
logger.log_message("FATAL", "Fatal error", scope="TEST", user=None, type=Logger.LOG, url=None)
-
+
stdout_output = sys.stdout.getvalue()
stderr_output = sys.stderr.getvalue()
-
+
sys.stdout = orig_stdout
sys.stderr = orig_stderr
-
+
self.assertEqual(stdout_output, "")
self.assertIn("Fatal error", stderr_output)
@@ -438,16 +434,16 @@ def test_log_message_stdout_for_info_when_stderr_enabled(self):
orig_stderr = sys.stderr
sys.stdout = StringIO()
sys.stderr = StringIO()
-
+
logger = Logger()
logger.log_message("INFO", "Info message", scope="TEST", user=None, type=Logger.LOG, url=None)
-
+
stdout_output = sys.stdout.getvalue()
stderr_output = sys.stderr.getvalue()
-
+
sys.stdout = orig_stdout
sys.stderr = orig_stderr
-
+
self.assertIn("Info message", stdout_output)
self.assertEqual(stderr_output, "")
@@ -458,16 +454,16 @@ def test_log_message_stdout_for_debug_when_stderr_enabled(self):
orig_stderr = sys.stderr
sys.stdout = StringIO()
sys.stderr = StringIO()
-
+
logger = Logger()
logger.log_message("DEBUG", "Debug message", scope="TEST", user=None, type=Logger.LOG, url=None)
-
+
stdout_output = sys.stdout.getvalue()
stderr_output = sys.stderr.getvalue()
-
+
sys.stdout = orig_stdout
sys.stderr = orig_stderr
-
+
self.assertIn("Debug message", stdout_output)
self.assertEqual(stderr_output, "")
@@ -475,14 +471,14 @@ def test_log_message_respects_stdout_false(self):
"""Test that no output when stdout is False"""
orig_stdout = sys.stdout
sys.stdout = StringIO()
-
+
logger = Logger()
logger.stdout = False
logger.log_message("INFO", "Test", scope="TEST", user=None, type=Logger.LOG, url=None)
-
+
output = sys.stdout.getvalue()
sys.stdout = orig_stdout
-
+
self.assertEqual(output, "")
@patch("openc3.utilities.logger.EphemeralStoreQueued")
@@ -491,7 +487,7 @@ def test_log_message_writes_to_store_with_scope(self, mock_store):
logger = Logger()
logger.no_store = False
logger.log_message("INFO", "Test", scope="TESTSCOPE", user=None, type=Logger.LOG, url=None)
-
+
mock_store.write_topic.assert_called_once()
call_args = mock_store.write_topic.call_args
self.assertEqual(call_args[0][0], "TESTSCOPE__openc3_log_messages")
@@ -504,7 +500,7 @@ def test_log_message_writes_to_store_without_scope(self, mock_store):
logger = Logger()
logger.no_store = False
logger.log_message("INFO", "Test", scope=None, user=None, type=Logger.LOG, url=None)
-
+
mock_store.write_topic.assert_called_once()
call_args = mock_store.write_topic.call_args
self.assertEqual(call_args[0][0], "NOSCOPE__openc3_log_messages")
@@ -515,20 +511,20 @@ def test_log_message_does_not_write_to_store_when_no_store_true(self, mock_store
logger = Logger()
logger.no_store = True
logger.log_message("INFO", "Test", scope="TEST", user=None, type=Logger.LOG, url=None)
-
+
mock_store.write_topic.assert_not_called()
def test_log_message_timestamp_format(self):
"""Test that timestamp is in correct ISO format with Z suffix"""
orig_stdout = sys.stdout
sys.stdout = StringIO()
-
+
logger = Logger()
logger.log_message("INFO", "Test", scope="TEST", user=None, type=Logger.LOG, url=None)
-
+
output = sys.stdout.getvalue()
sys.stdout = orig_stdout
-
+
data = json.loads(output)
timestamp = data["@timestamp"]
# Verify format: YYYY-MM-DDTHH:MM:SS.ffffffZ
@@ -543,15 +539,15 @@ def test_log_message_time_is_nanoseconds(self):
"""Test that time field is in nanoseconds"""
orig_stdout = sys.stdout
sys.stdout = StringIO()
-
+
logger = Logger()
before_ns = time.time_ns()
logger.log_message("INFO", "Test", scope="TEST", user=None, type=Logger.LOG, url=None)
after_ns = time.time_ns()
-
+
output = sys.stdout.getvalue()
sys.stdout = orig_stdout
-
+
data = json.loads(output)
log_time = data["time"]
# Verify it's in the expected range (nanoseconds)
@@ -563,22 +559,22 @@ def test_log_message_thread_safety(self):
import threading
orig_stdout = sys.stdout
sys.stdout = StringIO()
-
+
logger = Logger()
results = []
-
+
def log_from_thread(n):
logger.log_message("INFO", f"Message {n}", scope="TEST", user=None, type=Logger.LOG, url=None)
-
+
threads = [threading.Thread(target=log_from_thread, args=(i,)) for i in range(10)]
for t in threads:
t.start()
for t in threads:
t.join()
-
+
output = sys.stdout.getvalue()
sys.stdout = orig_stdout
-
+
lines = output.strip().split("\n")
self.assertEqual(len(lines), 10)
# Each line should be valid JSON
diff --git a/openc3/spec/accessors/accessor_spec.rb b/openc3/spec/accessors/accessor_spec.rb
new file mode 100644
index 0000000000..fc51553440
--- /dev/null
+++ b/openc3/spec/accessors/accessor_spec.rb
@@ -0,0 +1,116 @@
+# encoding: ascii-8bit
+
+# Copyright 2025 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 'spec_helper'
+require 'openc3'
+require 'openc3/accessors/accessor'
+
+module OpenC3
+ describe Accessor do
+ describe "convert_to_type" do
+ it "returns nil for nil values" do
+ item = OpenStruct.new
+ item.data_type = :INT
+ expect(Accessor.convert_to_type(nil, item)).to be_nil
+ end
+
+ it "converts BOOL values from strings" do
+ item = OpenStruct.new
+ item.data_type = :BOOL
+ expect(Accessor.convert_to_type("true", item)).to eql true
+ expect(Accessor.convert_to_type("TRUE", item)).to eql true
+ expect(Accessor.convert_to_type("false", item)).to eql false
+ expect(Accessor.convert_to_type("FALSE", item)).to eql false
+ expect(Accessor.convert_to_type(true, item)).to eql true
+ expect(Accessor.convert_to_type(false, item)).to eql false
+ end
+
+ it "converts ARRAY values from strings" do
+ item = OpenStruct.new
+ item.data_type = :ARRAY
+ expect(Accessor.convert_to_type('[1, 2, 3]', item)).to eql [1, 2, 3]
+ expect(Accessor.convert_to_type('["a", "b", "c"]', item)).to eql ["a", "b", "c"]
+ expect(Accessor.convert_to_type([1, 2, 3], item)).to eql [1, 2, 3]
+ end
+
+ it "converts OBJECT values from strings" do
+ item = OpenStruct.new
+ item.data_type = :OBJECT
+ expect(Accessor.convert_to_type('{"key": "value"}', item)).to eql({"key" => "value"})
+ expect(Accessor.convert_to_type('{"num": 123}', item)).to eql({"num" => 123})
+ expect(Accessor.convert_to_type({"key" => "value"}, item)).to eql({"key" => "value"})
+ end
+
+ it "converts ANY values from strings" do
+ item = OpenStruct.new
+ item.data_type = :ANY
+ expect(Accessor.convert_to_type('"text"', item)).to eql "text"
+ expect(Accessor.convert_to_type('123', item)).to eql 123
+ expect(Accessor.convert_to_type('[1, 2, 3]', item)).to eql [1, 2, 3]
+ expect(Accessor.convert_to_type('{"key": "value"}', item)).to eql({"key" => "value"})
+ expect(Accessor.convert_to_type('invalid json', item)).to eql "invalid json"
+ expect(Accessor.convert_to_type(123, item)).to eql 123
+ expect(Accessor.convert_to_type([1, 2, 3], item)).to eql [1, 2, 3]
+ end
+
+ it "converts STRING values with array_size from strings" do
+ item = OpenStruct.new
+ item.data_type = :STRING
+ item.array_size = 10
+ expect(Accessor.convert_to_type('["a", "b"]', item)).to eql ["a", "b"]
+ end
+
+ it "leaves STRING values without array_size unchanged" do
+ item = OpenStruct.new
+ item.data_type = :STRING
+ item.array_size = nil
+ expect(Accessor.convert_to_type('test', item)).to eql "test"
+ expect(Accessor.convert_to_type('["a", "b"]', item)).to eql '["a", "b"]'
+ end
+
+ it "leaves BLOCK values unchanged" do
+ item = OpenStruct.new
+ item.data_type = :BLOCK
+ item.array_size = nil
+ expect(Accessor.convert_to_type("\x01\x02\x03", item)).to eql "\x01\x02\x03"
+ expect(Accessor.convert_to_type('test', item)).to eql "test"
+ end
+
+ it "leaves INT values unchanged" do
+ item = OpenStruct.new
+ item.data_type = :INT
+ expect(Accessor.convert_to_type(42, item)).to eql 42
+ expect(Accessor.convert_to_type(-10, item)).to eql(-10)
+ end
+
+ it "leaves UINT values unchanged" do
+ item = OpenStruct.new
+ item.data_type = :UINT
+ expect(Accessor.convert_to_type(42, item)).to eql 42
+ expect(Accessor.convert_to_type(0, item)).to eql 0
+ end
+
+ it "leaves FLOAT values unchanged" do
+ item = OpenStruct.new
+ item.data_type = :FLOAT
+ expect(Accessor.convert_to_type(3.14, item)).to eql 3.14
+ expect(Accessor.convert_to_type(0.0, item)).to eql 0.0
+ end
+ end
+ end
+end
diff --git a/openc3/spec/packets/packet_item_spec.rb b/openc3/spec/packets/packet_item_spec.rb
index 35005085c7..0d16a31841 100644
--- a/openc3/spec/packets/packet_item_spec.rb
+++ b/openc3/spec/packets/packet_item_spec.rb
@@ -271,6 +271,51 @@ module OpenC3
expect { pi.check_default_and_range_data_types }.to_not raise_error
end
+ it "complains about BOOL default not matching data_type" do
+ pi = PacketItem.new("test", 0, 0, :BOOL, :BIG_ENDIAN, nil)
+ pi.default = "true"
+ expect { pi.check_default_and_range_data_types }.to raise_error(ArgumentError, "TEST: default must be true/false but is a String")
+ pi = PacketItem.new("test", 0, 0, :BOOL, :BIG_ENDIAN, nil)
+ pi.default = 1
+ expect { pi.check_default_and_range_data_types }.to raise_error(ArgumentError, "TEST: default must be true/false but is a Integer")
+ pi = PacketItem.new("test", 0, 0, :BOOL, :BIG_ENDIAN, nil)
+ pi.default = true
+ expect { pi.check_default_and_range_data_types }.to_not raise_error
+ pi = PacketItem.new("test", 0, 0, :BOOL, :BIG_ENDIAN, nil)
+ pi.default = false
+ expect { pi.check_default_and_range_data_types }.to_not raise_error
+ end
+
+ it "complains about ARRAY default not matching data_type" do
+ pi = PacketItem.new("test", 0, 0, :ARRAY, :BIG_ENDIAN, nil)
+ pi.default = "[]"
+ expect { pi.check_default_and_range_data_types }.to raise_error(ArgumentError, "TEST: default must be an Array but is a String")
+ pi = PacketItem.new("test", 0, 0, :ARRAY, :BIG_ENDIAN, nil)
+ pi.default = {}
+ expect { pi.check_default_and_range_data_types }.to raise_error(ArgumentError, "TEST: default must be an Array but is a Hash")
+ pi = PacketItem.new("test", 0, 0, :ARRAY, :BIG_ENDIAN, nil)
+ pi.default = []
+ expect { pi.check_default_and_range_data_types }.to_not raise_error
+ pi = PacketItem.new("test", 0, 0, :ARRAY, :BIG_ENDIAN, nil)
+ pi.default = [1, 2, 3]
+ expect { pi.check_default_and_range_data_types }.to_not raise_error
+ end
+
+ it "complains about OBJECT default not matching data_type" do
+ pi = PacketItem.new("test", 0, 0, :OBJECT, :BIG_ENDIAN, nil)
+ pi.default = "{}"
+ expect { pi.check_default_and_range_data_types }.to raise_error(ArgumentError, "TEST: default must be an Hash but is a String")
+ pi = PacketItem.new("test", 0, 0, :OBJECT, :BIG_ENDIAN, nil)
+ pi.default = []
+ expect { pi.check_default_and_range_data_types }.to raise_error(ArgumentError, "TEST: default must be an Hash but is a Array")
+ pi = PacketItem.new("test", 0, 0, :OBJECT, :BIG_ENDIAN, nil)
+ pi.default = {}
+ expect { pi.check_default_and_range_data_types }.to_not raise_error
+ pi = PacketItem.new("test", 0, 0, :OBJECT, :BIG_ENDIAN, nil)
+ pi.default = {"key" => "value"}
+ expect { pi.check_default_and_range_data_types }.to_not raise_error
+ end
+
it "complains about range not matching data_type" do
pi = PacketItem.new("test", 0, 32, :UINT, :BIG_ENDIAN, nil)
pi.default = 5
diff --git a/openc3/spec/packets/parsers/packet_item_parser_spec.rb b/openc3/spec/packets/parsers/packet_item_parser_spec.rb
index da1482d4ae..3bfb959917 100644
--- a/openc3/spec/packets/parsers/packet_item_parser_spec.rb
+++ b/openc3/spec/packets/parsers/packet_item_parser_spec.rb
@@ -148,6 +148,82 @@ module OpenC3
tf.unlink
end
+ it "accepts types BOOL ARRAY OBJECT ANY" do
+ tf = Tempfile.new('unittest')
+ tf.puts 'COMMAND tgt1 pkt1 LITTLE_ENDIAN "Description"'
+ tf.puts ' PARAMETER ITEM1 0 0 BOOL TRUE'
+ tf.puts ' APPEND_PARAMETER ITEM2 0 BOOL FALSE'
+ tf.puts ' APPEND_ID_PARAMETER ITEM3 0 BOOL TRUE'
+ tf.puts ' APPEND_PARAMETER ITEM4 0 ARRAY [1,2,3]'
+ tf.puts ' APPEND_ID_PARAMETER ITEM5 0 ARRAY ["a","b"]'
+ tf.puts ' APPEND_PARAMETER ITEM6 0 OBJECT {"key":"value"}'
+ tf.puts ' APPEND_ID_PARAMETER ITEM7 0 OBJECT {"test":123}'
+ tf.puts " APPEND_PARAMETER ITEM8 0 ANY '\"text\"'"
+ tf.puts ' APPEND_ID_PARAMETER ITEM9 0 ANY 456'
+ tf.close
+ @pc.process_file(tf.path, "TGT1")
+ packet = @pc.commands["TGT1"]["PKT1"]
+ expect(packet.items.keys).to include('ITEM1', 'ITEM2', 'ITEM3', 'ITEM4', 'ITEM5', 'ITEM6', 'ITEM7', 'ITEM8', 'ITEM9')
+ expect(packet.items["ITEM1"].default).to eql true
+ expect(packet.items["ITEM2"].default).to eql false
+ expect(packet.items["ITEM3"].id_value).to eql true
+ expect(packet.items["ITEM4"].default).to eql [1,2,3]
+ expect(packet.items["ITEM5"].id_value).to eql ["a","b"]
+ expect(packet.items["ITEM6"].default).to eql({"key" => "value"})
+ expect(packet.items["ITEM7"].id_value).to eql({"test" => 123})
+ expect(packet.items["ITEM8"].default).to eql "text"
+ expect(packet.items["ITEM9"].id_value).to eql 456
+ tf.unlink
+ end
+
+ it "complains about invalid BOOL values" do
+ tf = Tempfile.new('unittest')
+ tf.puts 'COMMAND tgt1 pkt1 LITTLE_ENDIAN "Description"'
+ tf.puts ' PARAMETER ITEM1 0 0 BOOL 1'
+ tf.close
+ expect { @pc.process_file(tf.path, "TGT1") }.to raise_error(ConfigParser::Error, /Default for BOOL data type must be TRUE or FALSE/)
+ tf.unlink
+
+ tf = Tempfile.new('unittest')
+ tf.puts 'TELEMETRY tgt1 pkt1 LITTLE_ENDIAN "Description"'
+ tf.puts ' APPEND_ID_ITEM ITEM1 0 BOOL invalid'
+ tf.close
+ expect { @pc.process_file(tf.path, "TGT1") }.to raise_error(ConfigParser::Error, /ID Value for BOOL data type must be TRUE or FALSE/)
+ tf.unlink
+ end
+
+ it "complains about invalid ARRAY values" do
+ tf = Tempfile.new('unittest')
+ tf.puts 'COMMAND tgt1 pkt1 LITTLE_ENDIAN "Description"'
+ tf.puts ' PARAMETER ITEM1 0 0 ARRAY notarray'
+ tf.close
+ expect { @pc.process_file(tf.path, "TGT1") }.to raise_error(ConfigParser::Error, /Unparsable value for ARRAY: notarray/)
+ tf.unlink
+
+ tf = Tempfile.new('unittest')
+ tf.puts 'TELEMETRY tgt1 pkt1 LITTLE_ENDIAN "Description"'
+ tf.puts ' APPEND_ID_ITEM ITEM1 0 ARRAY "string"'
+ tf.close
+ expect { @pc.process_file(tf.path, "TGT1") }.to raise_error(ConfigParser::Error, /Unparsable value for ARRAY: string/)
+ tf.unlink
+ end
+
+ it "complains about invalid OBJECT values" do
+ tf = Tempfile.new('unittest')
+ tf.puts 'COMMAND tgt1 pkt1 LITTLE_ENDIAN "Description"'
+ tf.puts ' PARAMETER ITEM1 0 0 OBJECT notobject'
+ tf.close
+ expect { @pc.process_file(tf.path, "TGT1") }.to raise_error(ConfigParser::Error, /Unparsable value for OBJECT: notobject/)
+ tf.unlink
+
+ tf = Tempfile.new('unittest')
+ tf.puts 'TELEMETRY tgt1 pkt1 LITTLE_ENDIAN "Description"'
+ tf.puts ' APPEND_ID_ITEM ITEM1 0 OBJECT [1,2,3]'
+ tf.close
+ expect { @pc.process_file(tf.path, "TGT1") }.to raise_error(ConfigParser::Error, /ID Value for OBJECT data type must be a Hash/)
+ tf.unlink
+ end
+
it "supports arbitrary endianness per item" do
tf = Tempfile.new('unittest')
tf.puts 'TELEMETRY tgt1 pkt1 LITTLE_ENDIAN "Description"'
diff --git a/openc3/spec/packets/structure_item_spec.rb b/openc3/spec/packets/structure_item_spec.rb
index e4a37fdcaf..1738f23c06 100644
--- a/openc3/spec/packets/structure_item_spec.rb
+++ b/openc3/spec/packets/structure_item_spec.rb
@@ -69,7 +69,7 @@ module OpenC3
end
it "complains about bad data types" do
- expect { StructureItem.new("test", 0, 0, :UNKNOWN, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: unknown data_type: UNKNOWN - Must be :INT, :UINT, :FLOAT, :STRING, :BLOCK, or :DERIVED")
+ expect { StructureItem.new("test", 0, 0, :UNKNOWN, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: unknown data_type: UNKNOWN - Must be INT, UINT, FLOAT, STRING, BLOCK, BOOL, OBJECT, ARRAY, ANY, DERIVED")
end
end