From 83a2edbd1b7219c53503ba25fa49358324ef95ea Mon Sep 17 00:00:00 2001 From: David Leskowicz Date: Wed, 7 Aug 2024 12:48:54 -0700 Subject: [PATCH 01/11] wip! Start adding support for the STA5635 based boards. --- BUILD | 1 + src/point_one/fusion_engine/messages/core.h | 1 + src/point_one/fusion_engine/messages/defs.h | 15 ++++ src/point_one/fusion_engine/messages/device.h | 4 + .../fusion_engine/messages/uart_to_st5635.h | 83 +++++++++++++++++++ 5 files changed, 104 insertions(+) create mode 100644 src/point_one/fusion_engine/messages/uart_to_st5635.h diff --git a/BUILD b/BUILD index bca55bd0..56a4a547 100644 --- a/BUILD +++ b/BUILD @@ -56,6 +56,7 @@ cc_library( "src/point_one/fusion_engine/messages/measurements.h", "src/point_one/fusion_engine/messages/signal_defs.h", "src/point_one/fusion_engine/messages/solution.h", + "src/point_one/fusion_engine/messages/uart_to_st5635.h", ], deps = [ ":common", diff --git a/src/point_one/fusion_engine/messages/core.h b/src/point_one/fusion_engine/messages/core.h index f1e009e3..c4998c60 100644 --- a/src/point_one/fusion_engine/messages/core.h +++ b/src/point_one/fusion_engine/messages/core.h @@ -12,3 +12,4 @@ #include "point_one/fusion_engine/messages/device.h" #include "point_one/fusion_engine/messages/measurements.h" #include "point_one/fusion_engine/messages/solution.h" +#include "point_one/fusion_engine/messages/uart_to_st5635.h" diff --git a/src/point_one/fusion_engine/messages/defs.h b/src/point_one/fusion_engine/messages/defs.h index 19a4d4e9..d58e1be5 100644 --- a/src/point_one/fusion_engine/messages/defs.h +++ b/src/point_one/fusion_engine/messages/defs.h @@ -86,6 +86,9 @@ enum class MessageType : uint16_t { FAULT_CONTROL = 13006, ///< @ref FaultControlMessage DEVICE_ID = 13007, ///< @ref DeviceIDMessage STARTUP_REQUEST = 13008, ///< @ref StartupRequest + SPI_CMD = 13009, ///< @ref SpiCmd + SPI_CMD_RESPONSE = 13010, ///< @ref SpiCmdResponse + SPI_LBAND_PACKET = 13011, ///< @ref SpiLbandPacket SET_CONFIG = 13100, ///< @ref SetConfigMessage GET_CONFIG = 13101, ///< @ref GetConfigMessage @@ -228,6 +231,15 @@ P1_CONSTEXPR_FUNC const char* to_string(MessageType type) { case MessageType::STARTUP_REQUEST: return "Startup Request"; + case MessageType::SPI_CMD: + return "SPI Command"; + + case MessageType::SPI_CMD_RESPONSE: + return "SPI Command Response"; + + case MessageType::SPI_LBAND_PACKET: + return "SPI Lband Packet"; + case MessageType::DEVICE_ID: return "Device ID Information"; @@ -301,6 +313,9 @@ P1_CONSTEXPR_FUNC bool IsCommand(MessageType message_type) { case MessageType::RESET_REQUEST: case MessageType::STARTUP_REQUEST: case MessageType::SHUTDOWN_REQUEST: + case MessageType::SPI_CMD: + case MessageType::SPI_CMD_RESPONSE: + case MessageType::SPI_LBAND_PACKET: case MessageType::FAULT_CONTROL: case MessageType::SET_CONFIG: case MessageType::GET_CONFIG: diff --git a/src/point_one/fusion_engine/messages/device.h b/src/point_one/fusion_engine/messages/device.h index 56c3e497..568a9b2c 100644 --- a/src/point_one/fusion_engine/messages/device.h +++ b/src/point_one/fusion_engine/messages/device.h @@ -103,6 +103,8 @@ enum class DeviceType : uint8_t { SSR_LG69T = 6, /** Point One SSR client running on a desktop platform. */ SSR_DESKTOP = 7, + /** Point One Uart to SPI prototype system (host to ST5635) */ + P1_ST5635 = 8, }; /** @@ -131,6 +133,8 @@ P1_CONSTEXPR_FUNC const char* to_string(DeviceType val) { return "SSR_LG69T"; case DeviceType::SSR_DESKTOP: return "SSR_DESKTOP"; + case DeviceType::P1_ST5635: + return "P1_ST5635"; } return "Unrecognized"; } diff --git a/src/point_one/fusion_engine/messages/uart_to_st5635.h b/src/point_one/fusion_engine/messages/uart_to_st5635.h new file mode 100644 index 00000000..d4e78c3f --- /dev/null +++ b/src/point_one/fusion_engine/messages/uart_to_st5635.h @@ -0,0 +1,83 @@ +/**************************************************************************/ /** + * @brief Uart to ST5365 and back messages. + * @file + ******************************************************************************/ + +#pragma once + +#include "point_one/fusion_engine/common/portability.h" +#include "point_one/fusion_engine/messages/defs.h" + +namespace point_one { +namespace fusion_engine { +namespace messages { + +// Enforce 4-byte alignment and packing of all data structures and values. +// Floating point values are aligned on platforms that require it. This is done +// with a combination of setting struct attributes, and manual alignment +// within the definitions. See the "Message Packing" section of the README. +#pragma pack(push, 1) + +/** + * @defgroup uart_spi Uart to/from SPI messages + * @brief Messages for sending/receiving control messages to/from the ST5635 + * @ingroup device_control + * + * See also @ref messages. + */ + +/**************************************************************************/ /** + * @defgroup device_control Device Control Messages + * @brief Messages for high-level device control (reset, shutdown, etc.). + * @ingroup config_and_ctrl_messages + ******************************************************************************/ + +/** + * @brief Response to indicate if SPI command was processed successfully (@ref + * MessageType::SPI_CMD_RESPONSE, version 1.0). + * @ingroup device_control + */ +struct P1_ALIGNAS(4) SpiCmdResponse : public MessagePayload { + static constexpr MessageType MESSAGE_TYPE = MessageType::SPI_CMD_RESPONSE; + static constexpr uint8_t MESSAGE_VERSION = 0; + + int64_t system_time_ns = 0; + uint8_t data_0 = 0; + uint8_t data_1 = 0; + uint8_t data_2 = 0; + uint8_t data_3 = 0; +}; + +/** + * @brief SPI Command to be sent to ST5635 (@ref + * MessageType::SPI_CMD, version 1.0). + * @ingroup device_control + */ +struct P1_ALIGNAS(4) SpiCmd : public MessagePayload { + static constexpr MessageType MESSAGE_TYPE = MessageType::SPI_CMD; + static constexpr uint8_t MESSAGE_VERSION = 0; + + uint8_t cmd = 0; + uint8_t address = 0; + uint8_t val1 = 0; + uint8_t val2 = 0; +}; + +/** + * @brief L-band frame contents from ST5635 (@ref + * MessageType::SPI_LBAND_PACKET, version 1.0). + * @ingroup device_control + + */ +struct P1_ALIGNAS(4) SpiLbandPacket : public MessagePayload { + static constexpr MessageType MESSAGE_TYPE = MessageType::SPI_LBAND_PACKET; + static constexpr uint8_t MESSAGE_VERSION = 0; + uint32_t msg_counter; + uint8_t packet[260]; +}; + +#pragma pack(pop) + +} // namespace messages +} // namespace fusion_engine +} // namespace point_one From aab1229f474dd397b40f698dbe4bddf9de1946e3 Mon Sep 17 00:00:00 2001 From: David Leskowicz Date: Fri, 25 Oct 2024 15:23:16 -0700 Subject: [PATCH 02/11] Addressed PR comments. Cleaned up message definitions, and removed ST5635LbandPacket in favor of InputDataWrapper. --- BUILD | 2 +- src/point_one/fusion_engine/messages/core.h | 1 - src/point_one/fusion_engine/messages/defs.h | 28 +++---- src/point_one/fusion_engine/messages/device.h | 4 - src/point_one/fusion_engine/messages/st5635.h | 82 ++++++++++++++++++ .../fusion_engine/messages/uart_to_st5635.h | 83 ------------------- 6 files changed, 95 insertions(+), 105 deletions(-) create mode 100644 src/point_one/fusion_engine/messages/st5635.h delete mode 100644 src/point_one/fusion_engine/messages/uart_to_st5635.h diff --git a/BUILD b/BUILD index 56a4a547..394143dc 100644 --- a/BUILD +++ b/BUILD @@ -56,7 +56,7 @@ cc_library( "src/point_one/fusion_engine/messages/measurements.h", "src/point_one/fusion_engine/messages/signal_defs.h", "src/point_one/fusion_engine/messages/solution.h", - "src/point_one/fusion_engine/messages/uart_to_st5635.h", + "src/point_one/fusion_engine/messages/st5635.h", ], deps = [ ":common", diff --git a/src/point_one/fusion_engine/messages/core.h b/src/point_one/fusion_engine/messages/core.h index c4998c60..f1e009e3 100644 --- a/src/point_one/fusion_engine/messages/core.h +++ b/src/point_one/fusion_engine/messages/core.h @@ -12,4 +12,3 @@ #include "point_one/fusion_engine/messages/device.h" #include "point_one/fusion_engine/messages/measurements.h" #include "point_one/fusion_engine/messages/solution.h" -#include "point_one/fusion_engine/messages/uart_to_st5635.h" diff --git a/src/point_one/fusion_engine/messages/defs.h b/src/point_one/fusion_engine/messages/defs.h index d58e1be5..df8b179d 100644 --- a/src/point_one/fusion_engine/messages/defs.h +++ b/src/point_one/fusion_engine/messages/defs.h @@ -86,9 +86,6 @@ enum class MessageType : uint16_t { FAULT_CONTROL = 13006, ///< @ref FaultControlMessage DEVICE_ID = 13007, ///< @ref DeviceIDMessage STARTUP_REQUEST = 13008, ///< @ref StartupRequest - SPI_CMD = 13009, ///< @ref SpiCmd - SPI_CMD_RESPONSE = 13010, ///< @ref SpiCmdResponse - SPI_LBAND_PACKET = 13011, ///< @ref SpiLbandPacket SET_CONFIG = 13100, ///< @ref SetConfigMessage GET_CONFIG = 13101, ///< @ref GetConfigMessage @@ -107,8 +104,11 @@ enum class MessageType : uint16_t { LBAND_FRAME = 14000, ///< @ref LBandFrameMessage + ST5635_COMMAND = 14100, ///< @ref ST5635Command + ST5635_COMMAND_RESPONSE = 14101, ///< @ref ST5635CommandResponse + /// The maximum defined @ref MessageType enum value. - MAX_VALUE = LBAND_FRAME, + MAX_VALUE = ST5635_COMMAND_RESPONSE, }; /** @@ -231,15 +231,6 @@ P1_CONSTEXPR_FUNC const char* to_string(MessageType type) { case MessageType::STARTUP_REQUEST: return "Startup Request"; - case MessageType::SPI_CMD: - return "SPI Command"; - - case MessageType::SPI_CMD_RESPONSE: - return "SPI Command Response"; - - case MessageType::SPI_LBAND_PACKET: - return "SPI Lband Packet"; - case MessageType::DEVICE_ID: return "Device ID Information"; @@ -284,6 +275,12 @@ P1_CONSTEXPR_FUNC const char* to_string(MessageType type) { case MessageType::LBAND_FRAME: return "L-band Frame Contents"; + + case MessageType::ST5635_COMMAND: + return "ST5635 Command"; + + case MessageType::ST5635_COMMAND_RESPONSE: + return "ST5635 Command Response"; } return "Unrecognized Message"; } @@ -313,9 +310,6 @@ P1_CONSTEXPR_FUNC bool IsCommand(MessageType message_type) { case MessageType::RESET_REQUEST: case MessageType::STARTUP_REQUEST: case MessageType::SHUTDOWN_REQUEST: - case MessageType::SPI_CMD: - case MessageType::SPI_CMD_RESPONSE: - case MessageType::SPI_LBAND_PACKET: case MessageType::FAULT_CONTROL: case MessageType::SET_CONFIG: case MessageType::GET_CONFIG: @@ -324,6 +318,7 @@ P1_CONSTEXPR_FUNC bool IsCommand(MessageType message_type) { case MessageType::EXPORT_DATA: case MessageType::SET_MESSAGE_RATE: case MessageType::GET_MESSAGE_RATE: + case MessageType::ST5635_COMMAND: return true; case MessageType::INVALID: case MessageType::POSE: @@ -363,6 +358,7 @@ P1_CONSTEXPR_FUNC bool IsCommand(MessageType message_type) { case MessageType::MESSAGE_RATE_RESPONSE: case MessageType::SUPPORTED_IO_INTERFACES: case MessageType::LBAND_FRAME: + case MessageType::ST5635_COMMAND_RESPONSE: return false; } return false; diff --git a/src/point_one/fusion_engine/messages/device.h b/src/point_one/fusion_engine/messages/device.h index 568a9b2c..56c3e497 100644 --- a/src/point_one/fusion_engine/messages/device.h +++ b/src/point_one/fusion_engine/messages/device.h @@ -103,8 +103,6 @@ enum class DeviceType : uint8_t { SSR_LG69T = 6, /** Point One SSR client running on a desktop platform. */ SSR_DESKTOP = 7, - /** Point One Uart to SPI prototype system (host to ST5635) */ - P1_ST5635 = 8, }; /** @@ -133,8 +131,6 @@ P1_CONSTEXPR_FUNC const char* to_string(DeviceType val) { return "SSR_LG69T"; case DeviceType::SSR_DESKTOP: return "SSR_DESKTOP"; - case DeviceType::P1_ST5635: - return "P1_ST5635"; } return "Unrecognized"; } diff --git a/src/point_one/fusion_engine/messages/st5635.h b/src/point_one/fusion_engine/messages/st5635.h new file mode 100644 index 00000000..5a164847 --- /dev/null +++ b/src/point_one/fusion_engine/messages/st5635.h @@ -0,0 +1,82 @@ +/**************************************************************************/ /** + * @brief Command/control support for an attached ST5365 RF front-end. + * @file + ******************************************************************************/ + +#pragma once + +#include "point_one/fusion_engine/common/portability.h" +#include "point_one/fusion_engine/messages/defs.h" + +namespace point_one { +namespace fusion_engine { +namespace messages { + +// Enforce 4-byte alignment and packing of all data structures and values. +// Floating point values are aligned on platforms that require it. This is done +// with a combination of setting struct attributes, and manual alignment +// within the definitions. See the "Message Packing" section of the README. +#pragma pack(push, 1) + +/**************************************************************************/ /** + * @defgroup st5635 ST5635 Command/Control Messages + * @brief Messages for interacting with an attached ST5635 RF front-end device. + * @ingroup device_control + * + * These messages are intended to be used only for devices with an + * STMicroelectronics ST5635 RF front-end where direct user control of the + * front-end is needed. This is not common and should not be used on most + * platforms. + * + * For platforms using an ST5635, the device will output @ref LBandFrameMessage + * containing I/Q samples from the RF front-end. The format and use of the I/Q + * samples is platform-specific. + * + * See also @ref messages. + ******************************************************************************/ + +/** + * @brief Result from a ST5635 sent in response to an @ref ST5635Command (@ref + * MessageType::ST5635_COMMAND_RESPONSE, version 1.0). + * @ingroup st5635 + */ +struct P1_ALIGNAS(4) ST5635CommandResponse : public MessagePayload { + static constexpr MessageType MESSAGE_TYPE = + MessageType::ST5635_COMMAND_RESPONSE; + static constexpr uint8_t MESSAGE_VERSION = 0; + + /** + * The system time when the response was received (in nanoseconds). Note that + * this is not synchronized to P1 or GNSS time. + */ + int64_t system_time_ns = 0; + uint32_t sequence_number = 0; + uint8_t data_0 = 0; + uint8_t data_1 = 0; + uint8_t data_2 = 0; + uint8_t data_3 = 0; +}; + +/** + * @brief ~SPI~ Command to be sent to an attached ST5635 front end. (@ref + * MessageType::ST5635_COMMAND, version 1.0). + * @ingroup st5635 + */ +struct P1_ALIGNAS(4) ST5635Command : public MessagePayload { + static constexpr MessageType MESSAGE_TYPE = MessageType::ST5635_COMMAND; + static constexpr uint8_t MESSAGE_VERSION = 0; + + /** + * See the STA5635 data sheet for the values below can be. + */ + uint8_t command = 0; // ST5635 command code + uint8_t address = 0; // ST5635 register address + uint8_t value_msb = 0; // STA5635 register value msb + uint8_t value_lsb = 0; // STA5635 register value lsb +}; + +#pragma pack(pop) + +} // namespace messages +} // namespace fusion_engine +} // namespace point_one diff --git a/src/point_one/fusion_engine/messages/uart_to_st5635.h b/src/point_one/fusion_engine/messages/uart_to_st5635.h deleted file mode 100644 index d4e78c3f..00000000 --- a/src/point_one/fusion_engine/messages/uart_to_st5635.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************/ /** - * @brief Uart to ST5365 and back messages. - * @file - ******************************************************************************/ - -#pragma once - -#include "point_one/fusion_engine/common/portability.h" -#include "point_one/fusion_engine/messages/defs.h" - -namespace point_one { -namespace fusion_engine { -namespace messages { - -// Enforce 4-byte alignment and packing of all data structures and values. -// Floating point values are aligned on platforms that require it. This is done -// with a combination of setting struct attributes, and manual alignment -// within the definitions. See the "Message Packing" section of the README. -#pragma pack(push, 1) - -/** - * @defgroup uart_spi Uart to/from SPI messages - * @brief Messages for sending/receiving control messages to/from the ST5635 - * @ingroup device_control - * - * See also @ref messages. - */ - -/**************************************************************************/ /** - * @defgroup device_control Device Control Messages - * @brief Messages for high-level device control (reset, shutdown, etc.). - * @ingroup config_and_ctrl_messages - ******************************************************************************/ - -/** - * @brief Response to indicate if SPI command was processed successfully (@ref - * MessageType::SPI_CMD_RESPONSE, version 1.0). - * @ingroup device_control - */ -struct P1_ALIGNAS(4) SpiCmdResponse : public MessagePayload { - static constexpr MessageType MESSAGE_TYPE = MessageType::SPI_CMD_RESPONSE; - static constexpr uint8_t MESSAGE_VERSION = 0; - - int64_t system_time_ns = 0; - uint8_t data_0 = 0; - uint8_t data_1 = 0; - uint8_t data_2 = 0; - uint8_t data_3 = 0; -}; - -/** - * @brief SPI Command to be sent to ST5635 (@ref - * MessageType::SPI_CMD, version 1.0). - * @ingroup device_control - */ -struct P1_ALIGNAS(4) SpiCmd : public MessagePayload { - static constexpr MessageType MESSAGE_TYPE = MessageType::SPI_CMD; - static constexpr uint8_t MESSAGE_VERSION = 0; - - uint8_t cmd = 0; - uint8_t address = 0; - uint8_t val1 = 0; - uint8_t val2 = 0; -}; - -/** - * @brief L-band frame contents from ST5635 (@ref - * MessageType::SPI_LBAND_PACKET, version 1.0). - * @ingroup device_control - - */ -struct P1_ALIGNAS(4) SpiLbandPacket : public MessagePayload { - static constexpr MessageType MESSAGE_TYPE = MessageType::SPI_LBAND_PACKET; - static constexpr uint8_t MESSAGE_VERSION = 0; - uint32_t msg_counter; - uint8_t packet[260]; -}; - -#pragma pack(pop) - -} // namespace messages -} // namespace fusion_engine -} // namespace point_one From 6ce0c3d4a1d95b775ba214cced9c98c2a5735058 Mon Sep 17 00:00:00 2001 From: Adam Shapiro Date: Tue, 29 Oct 2024 13:58:56 -0400 Subject: [PATCH 03/11] Corrected STA5635 name. --- BUILD | 2 +- src/point_one/fusion_engine/messages/defs.h | 18 +++++----- .../messages/{st5635.h => sta5635.h} | 34 +++++++++---------- 3 files changed, 27 insertions(+), 27 deletions(-) rename src/point_one/fusion_engine/messages/{st5635.h => sta5635.h} (65%) diff --git a/BUILD b/BUILD index 394143dc..a20ac246 100644 --- a/BUILD +++ b/BUILD @@ -56,7 +56,7 @@ cc_library( "src/point_one/fusion_engine/messages/measurements.h", "src/point_one/fusion_engine/messages/signal_defs.h", "src/point_one/fusion_engine/messages/solution.h", - "src/point_one/fusion_engine/messages/st5635.h", + "src/point_one/fusion_engine/messages/sta5635.h", ], deps = [ ":common", diff --git a/src/point_one/fusion_engine/messages/defs.h b/src/point_one/fusion_engine/messages/defs.h index df8b179d..f3947090 100644 --- a/src/point_one/fusion_engine/messages/defs.h +++ b/src/point_one/fusion_engine/messages/defs.h @@ -104,11 +104,11 @@ enum class MessageType : uint16_t { LBAND_FRAME = 14000, ///< @ref LBandFrameMessage - ST5635_COMMAND = 14100, ///< @ref ST5635Command - ST5635_COMMAND_RESPONSE = 14101, ///< @ref ST5635CommandResponse + STA5635_COMMAND = 14100, ///< @ref STA5635Command + STA5635_COMMAND_RESPONSE = 14101, ///< @ref STA5635CommandResponse /// The maximum defined @ref MessageType enum value. - MAX_VALUE = ST5635_COMMAND_RESPONSE, + MAX_VALUE = STA5635_COMMAND_RESPONSE, }; /** @@ -276,11 +276,11 @@ P1_CONSTEXPR_FUNC const char* to_string(MessageType type) { case MessageType::LBAND_FRAME: return "L-band Frame Contents"; - case MessageType::ST5635_COMMAND: - return "ST5635 Command"; + case MessageType::STA5635_COMMAND: + return "STA5635 Command"; - case MessageType::ST5635_COMMAND_RESPONSE: - return "ST5635 Command Response"; + case MessageType::STA5635_COMMAND_RESPONSE: + return "STA5635 Command Response"; } return "Unrecognized Message"; } @@ -318,7 +318,7 @@ P1_CONSTEXPR_FUNC bool IsCommand(MessageType message_type) { case MessageType::EXPORT_DATA: case MessageType::SET_MESSAGE_RATE: case MessageType::GET_MESSAGE_RATE: - case MessageType::ST5635_COMMAND: + case MessageType::STA5635_COMMAND: return true; case MessageType::INVALID: case MessageType::POSE: @@ -358,7 +358,7 @@ P1_CONSTEXPR_FUNC bool IsCommand(MessageType message_type) { case MessageType::MESSAGE_RATE_RESPONSE: case MessageType::SUPPORTED_IO_INTERFACES: case MessageType::LBAND_FRAME: - case MessageType::ST5635_COMMAND_RESPONSE: + case MessageType::STA5635_COMMAND_RESPONSE: return false; } return false; diff --git a/src/point_one/fusion_engine/messages/st5635.h b/src/point_one/fusion_engine/messages/sta5635.h similarity index 65% rename from src/point_one/fusion_engine/messages/st5635.h rename to src/point_one/fusion_engine/messages/sta5635.h index 5a164847..6a1a4b89 100644 --- a/src/point_one/fusion_engine/messages/st5635.h +++ b/src/point_one/fusion_engine/messages/sta5635.h @@ -1,5 +1,5 @@ /**************************************************************************/ /** - * @brief Command/control support for an attached ST5365 RF front-end. + * @brief Command/control support for an attached STA5635 RF front-end. * @file ******************************************************************************/ @@ -19,16 +19,16 @@ namespace messages { #pragma pack(push, 1) /**************************************************************************/ /** - * @defgroup st5635 ST5635 Command/Control Messages - * @brief Messages for interacting with an attached ST5635 RF front-end device. + * @defgroup sta5635 STA5635 Command/Control Messages + * @brief Messages for interacting with an attached STA5635 RF front-end device. * @ingroup device_control * * These messages are intended to be used only for devices with an - * STMicroelectronics ST5635 RF front-end where direct user control of the + * STMicroelectronics STA5635 RF front-end where direct user control of the * front-end is needed. This is not common and should not be used on most * platforms. * - * For platforms using an ST5635, the device will output @ref LBandFrameMessage + * For platforms using an STA5635, the device will output @ref LBandFrameMessage * containing I/Q samples from the RF front-end. The format and use of the I/Q * samples is platform-specific. * @@ -36,13 +36,13 @@ namespace messages { ******************************************************************************/ /** - * @brief Result from a ST5635 sent in response to an @ref ST5635Command (@ref - * MessageType::ST5635_COMMAND_RESPONSE, version 1.0). - * @ingroup st5635 + * @brief Result from a STA5635 sent in response to an @ref STA5635Command (@ref + * MessageType::STA5635_COMMAND_RESPONSE, version 1.0). + * @ingroup sta5635 */ -struct P1_ALIGNAS(4) ST5635CommandResponse : public MessagePayload { +struct P1_ALIGNAS(4) STA5635CommandResponse : public MessagePayload { static constexpr MessageType MESSAGE_TYPE = - MessageType::ST5635_COMMAND_RESPONSE; + MessageType::STA5635_COMMAND_RESPONSE; static constexpr uint8_t MESSAGE_VERSION = 0; /** @@ -58,19 +58,19 @@ struct P1_ALIGNAS(4) ST5635CommandResponse : public MessagePayload { }; /** - * @brief ~SPI~ Command to be sent to an attached ST5635 front end. (@ref - * MessageType::ST5635_COMMAND, version 1.0). - * @ingroup st5635 + * @brief A command to be sent to an attached STA5635 front end. (@ref + * MessageType::STA5635_COMMAND, version 1.0). + * @ingroup sta5635 */ -struct P1_ALIGNAS(4) ST5635Command : public MessagePayload { - static constexpr MessageType MESSAGE_TYPE = MessageType::ST5635_COMMAND; +struct P1_ALIGNAS(4) STA5635Command : public MessagePayload { + static constexpr MessageType MESSAGE_TYPE = MessageType::STA5635_COMMAND; static constexpr uint8_t MESSAGE_VERSION = 0; /** * See the STA5635 data sheet for the values below can be. */ - uint8_t command = 0; // ST5635 command code - uint8_t address = 0; // ST5635 register address + uint8_t command = 0; // STA5635 command code + uint8_t address = 0; // STA5635 register address uint8_t value_msb = 0; // STA5635 register value msb uint8_t value_lsb = 0; // STA5635 register value lsb }; From 8fd40c360f0d68d1af8c2be400425d8337fb4089 Mon Sep 17 00:00:00 2001 From: Adam Shapiro Date: Tue, 29 Oct 2024 14:03:28 -0400 Subject: [PATCH 04/11] Combined data fields into arrays, and improved documentation. --- .../fusion_engine/messages/sta5635.h | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/point_one/fusion_engine/messages/sta5635.h b/src/point_one/fusion_engine/messages/sta5635.h index 6a1a4b89..fd158c62 100644 --- a/src/point_one/fusion_engine/messages/sta5635.h +++ b/src/point_one/fusion_engine/messages/sta5635.h @@ -50,29 +50,37 @@ struct P1_ALIGNAS(4) STA5635CommandResponse : public MessagePayload { * this is not synchronized to P1 or GNSS time. */ int64_t system_time_ns = 0; + /** + * The sequence number contained in the @ref STA5635Command to which this + * response belongs. + */ uint32_t sequence_number = 0; - uint8_t data_0 = 0; - uint8_t data_1 = 0; - uint8_t data_2 = 0; - uint8_t data_3 = 0; + /** + * The response from the device, where `data[0]` contains the first byte in + * the response. + */ + uint8_t data[4] = {0}; }; /** * @brief A command to be sent to an attached STA5635 front end. (@ref * MessageType::STA5635_COMMAND, version 1.0). * @ingroup sta5635 + * + * See the STA5635 data sheet for the allowed command, address, and data values. */ struct P1_ALIGNAS(4) STA5635Command : public MessagePayload { static constexpr MessageType MESSAGE_TYPE = MessageType::STA5635_COMMAND; static constexpr uint8_t MESSAGE_VERSION = 0; + /** The STA5635 command code to be issued. */ + uint8_t command = 0; + /** The address of the STA5635 register to be accessed. */ + uint8_t address = 0; /** - * See the STA5635 data sheet for the values below can be. + * The value to be sent to the device, where `data[0]` contains the MSB. */ - uint8_t command = 0; // STA5635 command code - uint8_t address = 0; // STA5635 register address - uint8_t value_msb = 0; // STA5635 register value msb - uint8_t value_lsb = 0; // STA5635 register value lsb + uint8_t data[2] = {0}; }; #pragma pack(pop) From 023ce01b0392763356e4e85aeccf8fabba3d4d9f Mon Sep 17 00:00:00 2001 From: Adam Shapiro Date: Tue, 29 Oct 2024 14:06:17 -0400 Subject: [PATCH 05/11] Swapped struct order. --- .../fusion_engine/messages/sta5635.h | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/point_one/fusion_engine/messages/sta5635.h b/src/point_one/fusion_engine/messages/sta5635.h index fd158c62..83281736 100644 --- a/src/point_one/fusion_engine/messages/sta5635.h +++ b/src/point_one/fusion_engine/messages/sta5635.h @@ -35,6 +35,27 @@ namespace messages { * See also @ref messages. ******************************************************************************/ +/** + * @brief A command to be sent to an attached STA5635 front end. (@ref + * MessageType::STA5635_COMMAND, version 1.0). + * @ingroup sta5635 + * + * See the STA5635 data sheet for the allowed command, address, and data values. + */ +struct P1_ALIGNAS(4) STA5635Command : public MessagePayload { + static constexpr MessageType MESSAGE_TYPE = MessageType::STA5635_COMMAND; + static constexpr uint8_t MESSAGE_VERSION = 0; + + /** The STA5635 command code to be issued. */ + uint8_t command = 0; + /** The address of the STA5635 register to be accessed. */ + uint8_t address = 0; + /** + * The value to be sent to the device, where `data[0]` contains the MSB. + */ + uint8_t data[2] = {0}; +}; + /** * @brief Result from a STA5635 sent in response to an @ref STA5635Command (@ref * MessageType::STA5635_COMMAND_RESPONSE, version 1.0). @@ -62,27 +83,6 @@ struct P1_ALIGNAS(4) STA5635CommandResponse : public MessagePayload { uint8_t data[4] = {0}; }; -/** - * @brief A command to be sent to an attached STA5635 front end. (@ref - * MessageType::STA5635_COMMAND, version 1.0). - * @ingroup sta5635 - * - * See the STA5635 data sheet for the allowed command, address, and data values. - */ -struct P1_ALIGNAS(4) STA5635Command : public MessagePayload { - static constexpr MessageType MESSAGE_TYPE = MessageType::STA5635_COMMAND; - static constexpr uint8_t MESSAGE_VERSION = 0; - - /** The STA5635 command code to be issued. */ - uint8_t command = 0; - /** The address of the STA5635 register to be accessed. */ - uint8_t address = 0; - /** - * The value to be sent to the device, where `data[0]` contains the MSB. - */ - uint8_t data[2] = {0}; -}; - #pragma pack(pop) } // namespace messages From f99fca2fffd9ccf9a09dedf98756a27c2916e9a8 Mon Sep 17 00:00:00 2001 From: Adam Shapiro Date: Tue, 29 Oct 2024 14:06:57 -0400 Subject: [PATCH 06/11] Minor cleanup. --- src/point_one/fusion_engine/messages/sta5635.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/point_one/fusion_engine/messages/sta5635.h b/src/point_one/fusion_engine/messages/sta5635.h index 83281736..70bb39cd 100644 --- a/src/point_one/fusion_engine/messages/sta5635.h +++ b/src/point_one/fusion_engine/messages/sta5635.h @@ -36,7 +36,7 @@ namespace messages { ******************************************************************************/ /** - * @brief A command to be sent to an attached STA5635 front end. (@ref + * @brief A command to be sent to an attached STA5635 RF front-end. (@ref * MessageType::STA5635_COMMAND, version 1.0). * @ingroup sta5635 * @@ -57,8 +57,8 @@ struct P1_ALIGNAS(4) STA5635Command : public MessagePayload { }; /** - * @brief Result from a STA5635 sent in response to an @ref STA5635Command (@ref - * MessageType::STA5635_COMMAND_RESPONSE, version 1.0). + * @brief Result from an STA5635 sent in response to an @ref STA5635Command. + * (@ref MessageType::STA5635_COMMAND_RESPONSE, version 1.0). * @ingroup sta5635 */ struct P1_ALIGNAS(4) STA5635CommandResponse : public MessagePayload { From 78f152a8dec8117b265d068cf5714e1127598be3 Mon Sep 17 00:00:00 2001 From: Adam Shapiro Date: Tue, 29 Oct 2024 14:16:57 -0400 Subject: [PATCH 07/11] Renamed command sequence number. --- src/point_one/fusion_engine/messages/sta5635.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/point_one/fusion_engine/messages/sta5635.h b/src/point_one/fusion_engine/messages/sta5635.h index 70bb39cd..503587f5 100644 --- a/src/point_one/fusion_engine/messages/sta5635.h +++ b/src/point_one/fusion_engine/messages/sta5635.h @@ -75,7 +75,7 @@ struct P1_ALIGNAS(4) STA5635CommandResponse : public MessagePayload { * The sequence number contained in the @ref STA5635Command to which this * response belongs. */ - uint32_t sequence_number = 0; + uint32_t command_sequence_number = 0; /** * The response from the device, where `data[0]` contains the first byte in * the response. From 0e3120691635604ab70e33a5c4b5e6178449766d Mon Sep 17 00:00:00 2001 From: Adam Shapiro Date: Tue, 29 Oct 2024 14:17:20 -0400 Subject: [PATCH 08/11] Added STA5635 Python support. --- .../fusion_engine_client/messages/__init__.py | 1 + python/fusion_engine_client/messages/defs.py | 3 + .../fusion_engine_client/messages/sta5635.py | 80 +++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 python/fusion_engine_client/messages/sta5635.py diff --git a/python/fusion_engine_client/messages/__init__.py b/python/fusion_engine_client/messages/__init__.py index 8081f995..42a29a5a 100644 --- a/python/fusion_engine_client/messages/__init__.py +++ b/python/fusion_engine_client/messages/__init__.py @@ -1,6 +1,7 @@ from .core import * from .fault_control import * from . import ros +from . import sta5635 message_type_to_class = MessagePayload.message_type_to_class message_type_by_name = MessagePayload.message_type_by_name diff --git a/python/fusion_engine_client/messages/defs.py b/python/fusion_engine_client/messages/defs.py index 253af2fa..8fcfb0c2 100644 --- a/python/fusion_engine_client/messages/defs.py +++ b/python/fusion_engine_client/messages/defs.py @@ -154,6 +154,9 @@ class MessageType(IntEnum): LBAND_FRAME = 14000 + STA5635_COMMAND = 14100 + STA5635_COMMAND_RESPONSE = 14101 + RESERVED = 20000 @classmethod diff --git a/python/fusion_engine_client/messages/sta5635.py b/python/fusion_engine_client/messages/sta5635.py new file mode 100644 index 00000000..05a3ff4b --- /dev/null +++ b/python/fusion_engine_client/messages/sta5635.py @@ -0,0 +1,80 @@ +from construct import (Struct, Int8ul, Int32ul, Int64sl, Bytes) + +from ..utils.construct_utils import construct_message_to_string +from .defs import * + + +class STA5635Command(MessagePayload): + """! + @brief A command to be sent to an attached STA5635 RF front-end. + """ + MESSAGE_TYPE = MessageType.STA5635_COMMAND + MESSAGE_VERSION = 0 + + Construct = Struct( + "command" / Int8ul, + "address" / Int8ul, + "data" / Bytes(2), + ) + + def __init__(self): + self.command = 0 + self.address = 0 + self.data = bytes() + + def pack(self, buffer: Optional[bytes] = None, offset: int = 0, return_buffer: bool = True) -> (bytes, int): + values = vars(self) + packed_data = self.Construct.build(values) + return PackedDataToBuffer(packed_data, buffer, offset, return_buffer) + + def unpack(self, buffer: bytes, offset: int = 0, message_version: int = MessagePayload._UNSPECIFIED_VERSION) -> int: + parsed = self.Construct.parse(buffer[offset:]) + self.__dict__.update(parsed) + del self.__dict__['_io'] + return parsed._io.tell() + + def calcsize(self) -> int: + return self.Construct.sizeof() + + def __repr__(self): + result = super().__repr__()[:-1] + result += f', command=0x{self.command:02X}, address=0x{self.address:02X}, data={self.data}]' + return result + + +class STA5635CommandResponse(MessagePayload): + """! + @brief Result from an STA5635 sent in response to an @ref STA5635Command. + """ + MESSAGE_TYPE = MessageType.STA5635_COMMAND_RESPONSE + MESSAGE_VERSION = 0 + + Construct = Struct( + "system_time_ns" / Int64sl, + "command_sequence_number" / Int32ul, + "data" / Bytes(4), + ) + + def __init__(self): + self.system_time_ns = 0 + self.command_sequence_number = 0 + self.data = bytes() + + def pack(self, buffer: Optional[bytes] = None, offset: int = 0, return_buffer: bool = True) -> (bytes, int): + values = vars(self) + packed_data = self.Construct.build(values) + return PackedDataToBuffer(packed_data, buffer, offset, return_buffer) + + def unpack(self, buffer: bytes, offset: int = 0, message_version: int = MessagePayload._UNSPECIFIED_VERSION) -> int: + parsed = self.Construct.parse(buffer[offset:]) + self.__dict__.update(parsed) + del self.__dict__['_io'] + return parsed._io.tell() + + def calcsize(self) -> int: + return self.Construct.sizeof() + + def __repr__(self): + result = super().__repr__()[:-1] + result += f', seq={self.command_sequence_number}, data={self.data}]' + return result From 858a363c6cf1cba1f538eae2f6f1477c103b76ec Mon Sep 17 00:00:00 2001 From: Adam Shapiro Date: Tue, 29 Oct 2024 14:24:55 -0400 Subject: [PATCH 09/11] Separated STA5635 into its own Bazel target. --- BUILD | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/BUILD b/BUILD index a20ac246..7189a67c 100644 --- a/BUILD +++ b/BUILD @@ -56,7 +56,6 @@ cc_library( "src/point_one/fusion_engine/messages/measurements.h", "src/point_one/fusion_engine/messages/signal_defs.h", "src/point_one/fusion_engine/messages/solution.h", - "src/point_one/fusion_engine/messages/sta5635.h", ], deps = [ ":common", @@ -64,6 +63,17 @@ cc_library( ], ) +# STA5635 RF front-end message definitions. +cc_library( + name = "sta5635", + hdrs = [ + "src/point_one/fusion_engine/messages/sta5635.h", + ], + deps = [ + ":core_headers", + ], +) + # ROS translation message definitions. cc_library( name = "ros_support", From 3d00602504eecc191878aa254869da3099fa84cc Mon Sep 17 00:00:00 2001 From: Adam Shapiro Date: Tue, 29 Oct 2024 14:26:35 -0400 Subject: [PATCH 10/11] Include STA5635 response in IsResponse(). --- src/point_one/fusion_engine/messages/defs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/point_one/fusion_engine/messages/defs.h b/src/point_one/fusion_engine/messages/defs.h index f3947090..26e964a4 100644 --- a/src/point_one/fusion_engine/messages/defs.h +++ b/src/point_one/fusion_engine/messages/defs.h @@ -379,6 +379,7 @@ P1_CONSTEXPR_FUNC bool IsResponse(MessageType message_type) { case MessageType::COMMAND_RESPONSE: case MessageType::CONFIG_RESPONSE: case MessageType::MESSAGE_RATE_RESPONSE: + case MessageType::STA5635_COMMAND_RESPONSE: return true; default: return false; From b7110c2ea4b4c14af7347bd967c4fb10376bec22 Mon Sep 17 00:00:00 2001 From: Adam Shapiro Date: Tue, 29 Oct 2024 17:02:04 -0400 Subject: [PATCH 11/11] Print command and address in hex. --- python/fusion_engine_client/messages/sta5635.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/fusion_engine_client/messages/sta5635.py b/python/fusion_engine_client/messages/sta5635.py index 05a3ff4b..421575c3 100644 --- a/python/fusion_engine_client/messages/sta5635.py +++ b/python/fusion_engine_client/messages/sta5635.py @@ -41,6 +41,12 @@ def __repr__(self): result += f', command=0x{self.command:02X}, address=0x{self.address:02X}, data={self.data}]' return result + def __str__(self): + return construct_message_to_string(message=self, value_to_string={ + 'command': lambda x: f'0x{x:02X}', + 'address': lambda x: f'0x{x:02X}', + }) + class STA5635CommandResponse(MessagePayload): """!