How gremsy/gsdk works
Main Components
• Serial Communication Layer: Represented by files such as “serial_port.cpp” and “serial_port.h”, this component abstracts the USB/TTL serial port communication.
• MAVLink Message Processing: Show a module that includes the MAVLink subdirectory (inside “src/mavlink”) and its numerous header files for different protocols and message definitions. This handles encoding and decoding of MAVLink messages.
• Gimbal Interface & Protocol: Components like “gimbal_interface.cpp/h”, “gimbal_protocol.cpp/h”, and version-specific implementations (v1 and v2) that manage the core logic for communicating with and controlling the gimbal.
• Bootloader/Firmware Upgrade Module: Files such as “bootloader.cpp/h” (and the “upgrade_gimbal” example) are solely dedicated to upgrading firmware and handling bootloader mode.
• Auxiliary Utilities: Parsers (in “src/parsers”), and any additional support functions.
Relationships and Interactions
• The Application Core (command handler/menu) receives user input (e.g., selecting a gimbal mode or firmware upgrade).
• It then calls the Gimbal Interface, which in turn utilizes the Serial Communication Layer to send/receive data via the UART interface.
• The MAVLink processing module wraps around these interactions, translating the internal commands and messages into proper MAVLink packets using the numerous MAVLink definitions.
• For firmware upgrades, the core shifts to bootloader functionality where the Bootloader Module handles hex file parsing, connection initiation, and flashing via a dedicated protocol.
• An examples branch demonstrates how different operations (such as saving parameters or performing an upgrade) reuse the core modules and interact with hardware.
Architectural Patterns and Design Principles
• Layered Architecture: Organize components into distinct layers (UI/Command Layer, Communication Layer, Protocol/MAVLink Layer, and Hardware Abstraction Layer).
• Modular Structure: Note how the code is modularized; for instance, MAVLink messages are separated by protocol version and type.
• Clear Separation of Concerns: The project distinguishes between normal gimbal operation (configuration, commands, status monitoring) and the firmware upgrade process.
Relevant Technologies, Frameworks, and Libraries
• CMake is used for build configuration (evident from the top-level “CMakeLists.txt” files).
• The C++ standard libraries, along with platform-specific (Unix) serial port handling.