├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── bitbucket-pipelines.yml ├── contributors.md ├── examples ├── MultiTurnDemo │ └── MultiTurnDemo.ino ├── PropellerDemo │ └── PropellerDemo.ino └── tests │ ├── test_api_2306_speed │ ├── adc_interface_client.hpp │ ├── anticogging_client.hpp │ ├── anticogging_pro_client.hpp │ ├── arming_handler_client.hpp │ ├── bipbuffer.h │ ├── brushless_drive_client.hpp │ ├── buzzer_control_client.hpp │ ├── byte_queue.c │ ├── byte_queue.h │ ├── client_communication.cpp │ ├── client_communication.hpp │ ├── coil_temperature_estimator_client.hpp │ ├── communication_interface.h │ ├── crc_helper.c │ ├── crc_helper.h │ ├── esc_propeller_input_parser_client.hpp │ ├── generic_interface.cpp │ ├── generic_interface.hpp │ ├── gpio_controller_client.hpp │ ├── hobby_input_client.hpp │ ├── iq_module_communication.hpp │ ├── iq_module_communication_local.hpp │ ├── iq_serial.hpp │ ├── iquart_flight_controller_interface_client.hpp │ ├── mag_alpha_client.hpp │ ├── multi_turn_angle_control_client.hpp │ ├── packet_finder.c │ ├── packet_finder.h │ ├── persistent_memory_client.hpp │ ├── power_monitor_client.hpp │ ├── power_safety_client.hpp │ ├── propeller_motor_control_client.hpp │ ├── pulsing_rectangular_input_parser_client.hpp │ ├── pwm_interface_client.hpp │ ├── rgb_led.hpp │ ├── serial_interface_client.hpp │ ├── servo_input_parser_client.hpp │ ├── step_direction_input_client.hpp │ ├── stopping_handler_client.hpp │ ├── stow_user_interface_client.hpp │ ├── system_control_client.hpp │ ├── temperature_estimator_client.hpp │ ├── temperature_monitor_uc_client.hpp │ ├── test_api_2306_speed.ino │ ├── throttle_source_manager_client.hpp │ ├── uavcan_node_client.hpp │ ├── voltage_superposition_client.hpp │ └── white_led.hpp │ ├── test_api_8108_speed │ ├── adc_interface_client.hpp │ ├── anticogging_client.hpp │ ├── anticogging_pro_client.hpp │ ├── arming_handler_client.hpp │ ├── bipbuffer.h │ ├── brushless_drive_client.hpp │ ├── buzzer_control_client.hpp │ ├── byte_queue.c │ ├── byte_queue.h │ ├── client_communication.cpp │ ├── client_communication.hpp │ ├── coil_temperature_estimator_client.hpp │ ├── communication_interface.h │ ├── crc_helper.c │ ├── crc_helper.h │ ├── esc_propeller_input_parser_client.hpp │ ├── generic_interface.cpp │ ├── generic_interface.hpp │ ├── gpio_controller_client.hpp │ ├── hobby_input_client.hpp │ ├── iq_module_communication_local.hpp │ ├── iq_serial.hpp │ ├── iquart_flight_controller_interface_client.hpp │ ├── mag_alpha_client.hpp │ ├── multi_turn_angle_control_client.hpp │ ├── packet_finder.c │ ├── packet_finder.h │ ├── persistent_memory_client.hpp │ ├── power_monitor_client.hpp │ ├── power_safety_client.hpp │ ├── propeller_motor_control_client.hpp │ ├── pulsing_rectangular_input_parser_client.hpp │ ├── pwm_interface_client.hpp │ ├── rgb_led.hpp │ ├── serial_interface_client.hpp │ ├── servo_input_parser_client.hpp │ ├── step_direction_input_client.hpp │ ├── stopping_handler_client.hpp │ ├── stow_user_interface_client.hpp │ ├── system_control_client.hpp │ ├── temperature_estimator_client.hpp │ ├── temperature_monitor_uc_client.hpp │ ├── test_api_8108_speed.ino │ ├── throttle_source_manager_client.hpp │ ├── uavcan_node_client.hpp │ ├── voltage_superposition_client.hpp │ └── white_led.hpp │ └── test_api_8108_speed_hyperdrive │ ├── adc_interface_client.hpp │ ├── anticogging_client.hpp │ ├── anticogging_pro_client.hpp │ ├── arming_handler_client.hpp │ ├── bipbuffer.h │ ├── brushless_drive_client.hpp │ ├── buzzer_control_client.hpp │ ├── byte_queue.c │ ├── byte_queue.h │ ├── client_communication.cpp │ ├── client_communication.hpp │ ├── coil_temperature_estimator_client.hpp │ ├── communication_interface.h │ ├── crc_helper.c │ ├── crc_helper.h │ ├── current_safeties_client.hpp │ ├── drive_control_interface_client.hpp │ ├── esc_propeller_input_parser_client.hpp │ ├── generic_interface.cpp │ ├── generic_interface.hpp │ ├── gpio_controller_client.hpp │ ├── hobby_input_client.hpp │ ├── iq_module_communication_local.hpp │ ├── iq_serial.hpp │ ├── iquart_flight_controller_interface_client.hpp │ ├── mag_alpha_client.hpp │ ├── motor_driver_client.hpp │ ├── motor_model_client.hpp │ ├── multi_turn_angle_control_client.hpp │ ├── packet_finder.c │ ├── packet_finder.h │ ├── persistent_memory_client.hpp │ ├── power_monitor_client.hpp │ ├── power_safety_client.hpp │ ├── propeller_motor_control_client.hpp │ ├── pulsing_rectangular_input_parser_client.hpp │ ├── pwm_interface_client.hpp │ ├── rgb_led.hpp │ ├── rotor_angle_generator_client.hpp │ ├── serial_interface_client.hpp │ ├── servo_input_parser_client.hpp │ ├── step_direction_input_client.hpp │ ├── stopping_handler_client.hpp │ ├── stow_user_interface_client.hpp │ ├── system_control_client.hpp │ ├── temperature_estimator_client.hpp │ ├── temperature_monitor_uc_client.hpp │ ├── test_api_8108_speed_hyperdrive.ino │ ├── throttle_source_manager_client.hpp │ ├── uavcan_node_client.hpp │ ├── voltage_superposition_client.hpp │ ├── voltage_target_generator_client.hpp │ └── white_led.hpp ├── keywords.txt ├── library.properties └── src ├── adc_interface_client.hpp ├── anticogging_client.hpp ├── anticogging_pro_client.hpp ├── arming_handler_client.hpp ├── bipbuffer.h ├── brushless_drive_client.hpp ├── buzzer_control_client.hpp ├── byte_queue.c ├── byte_queue.h ├── client_communication.cpp ├── client_communication.hpp ├── coil_temperature_estimator_client.hpp ├── communication_interface.h ├── crc_helper.c ├── crc_helper.h ├── current_safeties_client.hpp ├── drive_control_interface_client.hpp ├── esc_propeller_input_parser_client.hpp ├── generic_interface.cpp ├── generic_interface.hpp ├── gpio_controller_client.hpp ├── hobby_input_client.hpp ├── iq_module_communication.hpp ├── iq_serial.hpp ├── iquart_flight_controller_interface_client.hpp ├── mag_alpha_client.hpp ├── motor_driver_client.hpp ├── motor_model_client.hpp ├── multi_turn_angle_control_client.hpp ├── packet_finder.c ├── packet_finder.h ├── persistent_memory_client.hpp ├── power_monitor_client.hpp ├── power_safety_client.hpp ├── propeller_motor_control_client.hpp ├── pulsing_rectangular_input_parser_client.hpp ├── pwm_interface_client.hpp ├── rgb_led.hpp ├── rotor_angle_generator_client.hpp ├── serial_interface_client.hpp ├── servo_input_parser_client.hpp ├── step_direction_input_client.hpp ├── stopping_handler_client.hpp ├── stow_user_interface_client.hpp ├── system_control_client.hpp ├── temperature_estimator_client.hpp ├── temperature_monitor_uc_client.hpp ├── throttle_source_manager_client.hpp ├── uavcan_node_client.hpp ├── voltage_superposition_client.hpp ├── voltage_target_generator_client.hpp └── white_led.hpp /.gitignore: -------------------------------------------------------------------------------- 1 | # These are some examples of commonly ignored file patterns. 2 | # You should customize this list as applicable to your project. 3 | # Learn more about .gitignore: 4 | # https://www.atlassian.com/git/tutorials/saving-changes/gitignore 5 | 6 | # Node artifact files 7 | node_modules/ 8 | dist/ 9 | 10 | # Compiled Java class files 11 | *.class 12 | 13 | # Compiled Python bytecode 14 | *.py[cod] 15 | 16 | # Log files 17 | *.log 18 | 19 | # Package files 20 | *.jar 21 | 22 | # Maven 23 | target/ 24 | dist/ 25 | 26 | # JetBrains IDE 27 | .idea/ 28 | 29 | # Unit test reports 30 | TEST*.xml 31 | 32 | # Generated by MacOS 33 | .DS_Store 34 | 35 | # Generated by Windows 36 | Thumbs.db 37 | 38 | # Applications 39 | *.app 40 | *.exe 41 | *.war 42 | 43 | # Large media files 44 | *.mp4 45 | *.tiff 46 | *.avi 47 | *.flv 48 | *.mov 49 | *.wmv 50 | 51 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | When contributing to this repository, please first discuss the change you wish to make via issue, 4 | email, or any other method with the owners of this repository before making a change. 5 | 6 | Please note we have a code of conduct, please follow it in all your interactions with the project. 7 | 8 | ## Pull Request Process 9 | 10 | 1. Ensure any install or build dependencies are removed before the end of the layer when doing a 11 | build. 12 | 2. Increase the version numbers in any example files and the README.md to the new version that this 13 | Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/). Use [shields.io](https://shields.io/category/version) to create the tag. 14 | 4. Add yourself to the contributor.md page explaining your work and adding your github account if you want. 15 | 3. Contact somebody at IQ Motion Control to make sure that your contribution is good (asking for a pull request is fine if you give us your contact information so that we can contact you). 16 | 17 | ## Code of Conduct 18 | 19 | Please read our [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) 20 | 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![tag](https://img.shields.io/github/v/tag/iq-motion-control/iq-module-communication-arduino) 2 | ![release](https://img.shields.io/github/release/iq-motion-control/iq-module-communication-arduino/all.svg) 3 | 4 | # Arduino API 5 | 6 | This is the library to control a IQ Motion Control Module with an Arduino 7 | 8 | ## Getting Started 9 | 10 | You can download the latest stable release of this library on the arduino IDE [library manager](https://www.arduino.cc/en/guide/libraries). Just look up "IQ Module Communication". Read the programming [documentation](https://iqmotion.readthedocs.io/en/latest/langs/arduino.html) on our website to learn how to use this library. 11 | A .zip of the library can also be found on our [release page](https://github.com/iq-motion-control/iq-module-communication-arduino/releases). Follow these [instructions](https://www.arduino.cc/en/guide/libraries#toc4) to install a library manually. 12 | Read the programming [documentation](https://www.iq-control.com/support) on our website to learn how to use this library. 13 | 14 | ### Prerequisites 15 | 16 | You will need an arduino with serial ports and the arduino [IDE](https://www.arduino.cc/en/Main/Software). 17 | This library might work on other boards that is supported by the IDE but we have not tested them. 18 | 19 | ## Contributing 20 | 21 | Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. 22 | 23 | ## Versioning 24 | 25 | We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/iq-motion-control/iq-module-communication-arduino/tags). 26 | For the releases available, see the [releases on this repository](https://github.com/iq-motion-control/iq-module-communication-arduino/releases). 27 | 28 | ## Authors 29 | 30 | * **Matthew piccoli** 31 | 32 | See also the list of [contributors](contributors.md) who participated in this project. 33 | 34 | ## License 35 | 36 | This project is licensed under the GNU LGPL-3.0-or-later license - see the [LICENSE.md](LICENSE) file for details 37 | 38 | -------------------------------------------------------------------------------- /bitbucket-pipelines.yml: -------------------------------------------------------------------------------- 1 | # This is an example Starter pipeline configuration 2 | # Use a skeleton to build, test and deploy using manual and parallel steps 3 | # ----- 4 | # You can specify a custom docker image from Docker Hub as your build environment. 5 | 6 | image: atlassian/default-image:3 7 | 8 | pipelines: 9 | branches: 10 | master: 11 | - step: 12 | script: 13 | - git remote add sync git@github.com:iq-motion-control/iq-module-communication-arduino.git 14 | - git checkout master 15 | - git pull 16 | - git push sync master --force 17 | -------------------------------------------------------------------------------- /contributors.md: -------------------------------------------------------------------------------- 1 | # Contributors to this library 2 | 3 | * **Raphael Van Hoffelen** -*work*- Helped set up repo and its architecture 4 | * **Ben Quan** -*work*- Currently maintining repo -------------------------------------------------------------------------------- /examples/PropellerDemo/PropellerDemo.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * IQ propeller serial demo. 3 | * 4 | * This code will command a propeller controller to vary its speed in the 5 | * positive and negative direction repeatedly. 6 | * 7 | * The circuit: 8 | * Arduino RX is directly connected to motor TX 9 | * Arduino TX is directly connected to motor RX 10 | * 11 | * For more information about communicating to IQ Motor Modules please go to: 12 | * http://iq-control.com/documentation 13 | * 14 | * Created 2019/3/6 by Matthew Piccoli 15 | * Last updated 2019/11/5 by Matthew Piccoli 16 | * 17 | * This example code is in the public domain. 18 | */ 19 | 20 | #include 21 | 22 | // USER SETABLE VALUES HERE--------------------------------------------------- 23 | // Sets the maximum speed (in rad/s) 24 | const float kSpeed = 50.0f; 25 | // Sets the velocity increment size (in rad/s/100ms) 26 | const float kSpeedStep = 1.0f; 27 | // END USER SETABLE VALUES----------------------------------------------------- 28 | 29 | // Make an IqSerial object using Serial0 (same as Serial) 30 | IqSerial ser(Serial); 31 | // Make a PropellerMotorControlClient to interface with a motor module (ID 0) 32 | PropellerMotorControlClient prop(0); 33 | 34 | void setup() { 35 | // Initialize the Serial peripheral for motor controller 36 | ser.begin(115200); 37 | 38 | // The motor must already be powered on and booted up 39 | // for these setup messages to be received. 40 | // Wait for one second just in case both devices are powered at the same time 41 | delay(1000); 42 | } 43 | 44 | void loop() { 45 | static float velocity_to_set = 0.0f; 46 | static float velocity_sign = 1.0f; 47 | 48 | // Update velocity command 49 | if(abs(velocity_to_set) >= kSpeed) 50 | { 51 | velocity_sign = -1*velocity_sign; 52 | } 53 | velocity_to_set += kSpeedStep*velocity_sign; 54 | 55 | // Send velocity command to motor 56 | ser.set(prop.ctrl_velocity_,velocity_to_set); 57 | 58 | // Limit the acceleration by updating at a limited rate 59 | delay(25); 60 | } 61 | -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/adc_interface_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: adc_interface_client.hpp 11 | Last update: 2023/04/18 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef ADC_INTERFACE_CLIENT_HPP_ 17 | #define ADC_INTERFACE_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeAdcInterface = 91; 22 | 23 | class AdcInterfaceClient : public ClientAbstract { 24 | public: 25 | AdcInterfaceClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypeAdcInterface, obj_idn), 27 | adc_voltage_(kTypeAdcInterface, obj_idn, kSubAdcVoltage), 28 | raw_value_(kTypeAdcInterface, obj_idn, kSubRawValue){}; 29 | 30 | // Client Entries 31 | ClientEntry adc_voltage_; 32 | ClientEntry raw_value_; 33 | 34 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 35 | static const uint8_t kEntryLength = kSubRawValue + 1; 36 | ClientEntryAbstract* entry_array[kEntryLength] = { 37 | &adc_voltage_, // 0 38 | &raw_value_ // 1 39 | }; 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubAdcVoltage = 0; 45 | static const uint8_t kSubRawValue = 1; 46 | }; 47 | 48 | #endif /* ADC_INTERFACE_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/anticogging_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: anticogging_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef ANTICOGGING_CLIENT_H 17 | #define ANTICOGGING_CLIENT_H 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeAnticogging = 71; 22 | 23 | class AnticoggingClient: public ClientAbstract{ 24 | public: 25 | AnticoggingClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeAnticogging, obj_idn), 27 | table_size_( kTypeAnticogging, obj_idn, kSubTableSize), 28 | is_data_valid_( kTypeAnticogging, obj_idn, kSubIsDataValid), 29 | is_enabled_( kTypeAnticogging, obj_idn, kSubIsEnabled), 30 | erase_( kTypeAnticogging, obj_idn, kSubErase), 31 | left_shift_( kTypeAnticogging, obj_idn, kSubLeftShift) 32 | {}; 33 | 34 | // Client Entries 35 | ClientEntry table_size_; 36 | ClientEntry is_data_valid_; 37 | ClientEntry is_enabled_; 38 | ClientEntryVoid erase_; 39 | ClientEntry left_shift_; 40 | 41 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 42 | { 43 | static const uint8_t kEntryLength = kSubLeftShift+1; 44 | ClientEntryAbstract* entry_array[kEntryLength] = { 45 | &table_size_, // 0 46 | &is_data_valid_, // 1 47 | &is_enabled_, // 2 48 | &erase_, // 3 49 | &left_shift_ // 4 50 | }; 51 | 52 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 53 | } 54 | 55 | private: 56 | static const uint8_t kSubTableSize = 0; 57 | static const uint8_t kSubIsDataValid = 1; 58 | static const uint8_t kSubIsEnabled = 2; 59 | static const uint8_t kSubErase = 3; 60 | static const uint8_t kSubLeftShift = 4; 61 | }; 62 | 63 | #endif // ANTICOGGING_CLIENT_H 64 | -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/anticogging_pro_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 Vertiq support@vertiq.co 3 | 4 | This file is part of the Vertiq C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: anticogging_pro_client.hpp 11 | Last update: 2023/06/29 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef ANTICOGGING_PRO_CLIENT_HPP 17 | #define ANTICOGGING_PRO_CLIENT_HPP 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeAnticoggingPro = 79; 22 | 23 | class AnticoggingProClient: public ClientAbstract{ 24 | public: 25 | AnticoggingProClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeAnticoggingPro, obj_idn), 27 | enabled_(kTypeAnticoggingPro, obj_idn, kSubEnabled), 28 | tau_(kTypeAnticoggingPro, obj_idn, kSubTau), 29 | num_harmonics_(kTypeAnticoggingPro, obj_idn, kSubNumHarmonics), 30 | voltage_(kTypeAnticoggingPro, obj_idn, kSubVoltage), 31 | index_(kTypeAnticoggingPro, obj_idn, kSubIndex), 32 | harmonic_(kTypeAnticoggingPro, obj_idn, kSubHarmonic), 33 | a_(kTypeAnticoggingPro, obj_idn, kSubA), 34 | phase_(kTypeAnticoggingPro, obj_idn, kSubPhase), 35 | phase_total_(kTypeAnticoggingPro, obj_idn, kSubPhaseTotal), 36 | amplitude_(kTypeAnticoggingPro, obj_idn, kSubAmplitude), 37 | max_harmonics_(kTypeAnticoggingPro, obj_idn, kSubMaxHarmonics) 38 | {}; 39 | 40 | // Client Entries 41 | ClientEntry enabled_; 42 | ClientEntry tau_; 43 | ClientEntry num_harmonics_; 44 | ClientEntry voltage_; 45 | ClientEntry index_; 46 | ClientEntry harmonic_; 47 | ClientEntry a_; 48 | ClientEntry phase_; 49 | ClientEntry phase_total_; 50 | ClientEntry amplitude_; 51 | ClientEntry max_harmonics_; 52 | 53 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 54 | { 55 | static const uint8_t kEntryLength = kSubMaxHarmonics+1; 56 | ClientEntryAbstract* entry_array[kEntryLength] = { 57 | &enabled_, // 0 58 | &tau_, // 1 59 | &num_harmonics_, // 2 60 | &voltage_, // 3 61 | &index_, // 4 62 | &harmonic_, // 5 63 | &a_, // 6 64 | &phase_, // 7 65 | &phase_total_, // 8 66 | &litude_, // 9 67 | &max_harmonics_ // 10 68 | }; 69 | 70 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 71 | } 72 | 73 | private: 74 | static const uint8_t kSubEnabled = 0; 75 | static const uint8_t kSubTau = 1; 76 | static const uint8_t kSubNumHarmonics = 2; 77 | static const uint8_t kSubVoltage = 3; 78 | static const uint8_t kSubIndex = 4; 79 | static const uint8_t kSubHarmonic = 5; 80 | static const uint8_t kSubA = 6; 81 | static const uint8_t kSubPhase = 7; 82 | static const uint8_t kSubPhaseTotal = 8; 83 | static const uint8_t kSubAmplitude = 9; 84 | static const uint8_t kSubMaxHarmonics = 10; 85 | }; 86 | 87 | #endif // ANTICOGGING_PRO_CLIENT_H 88 | -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/buzzer_control_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: buzzer_control_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef BUZZER_CONTROL_CLIENT_H 17 | #define BUZZER_CONTROL_CLIENT_H 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeBuzzerControl = 61; 22 | 23 | class BuzzerControlClient: public ClientAbstract{ 24 | public: 25 | BuzzerControlClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeBuzzerControl, obj_idn), 27 | ctrl_mode_( kTypeBuzzerControl, obj_idn, kSubCtrlMode), 28 | ctrl_brake_( kTypeBuzzerControl, obj_idn, kSubCtrlBrake), 29 | ctrl_coast_( kTypeBuzzerControl, obj_idn, kSubCtrlCoast), 30 | ctrl_note_( kTypeBuzzerControl, obj_idn, kSubCtrlNote), 31 | volume_max_( kTypeBuzzerControl, obj_idn, kSubVolumeMax), 32 | hz_( kTypeBuzzerControl, obj_idn, kSubHz), 33 | volume_( kTypeBuzzerControl, obj_idn, kSubVolume), 34 | duration_( kTypeBuzzerControl, obj_idn, kSubDuration) 35 | {}; 36 | 37 | // Client Entries 38 | ClientEntryVoid ctrl_mode_; 39 | ClientEntryVoid ctrl_brake_; 40 | ClientEntryVoid ctrl_coast_; 41 | ClientEntryVoid ctrl_note_; 42 | ClientEntry volume_max_; 43 | ClientEntry hz_; 44 | ClientEntry volume_; 45 | ClientEntry duration_; 46 | 47 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 48 | { 49 | static const uint8_t kEntryLength = kSubDuration+1; 50 | ClientEntryAbstract* entry_array[kEntryLength] = { 51 | &ctrl_mode_, // 0 52 | &ctrl_brake_, // 1 53 | &ctrl_coast_, // 2 54 | &ctrl_note_, // 3 55 | &volume_max_, // 4 56 | &hz_, // 5 57 | &volume_, // 6 58 | &duration_, // 7 59 | }; 60 | 61 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 62 | } 63 | 64 | private: 65 | static const uint8_t kSubCtrlMode = 0; 66 | static const uint8_t kSubCtrlBrake = 1; 67 | static const uint8_t kSubCtrlCoast = 2; 68 | static const uint8_t kSubCtrlNote = 3; 69 | static const uint8_t kSubVolumeMax = 4; 70 | static const uint8_t kSubHz = 5; 71 | static const uint8_t kSubVolume = 6; 72 | static const uint8_t kSubDuration = 7; 73 | }; 74 | 75 | #endif // BUZZER_CONTROL_CLIENT_H 76 | -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/byte_queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: byte_queue.h 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: James Paulos 13 | Contributors: Matthew Piccoli, Raphael Van Hoffelen 14 | */ 15 | 16 | /* A FIFO buffer for uint8 bytes implemented with a fixed size circular 17 | * buffer. A ByteQueue struct maintains the buffer data and state for one 18 | * buffer instance, and many simultaneous instances are supported. An operation 19 | * on one buffer must not be interrupted by another operation on that same 20 | * buffer (possibly via an interrupt). This restriction is not enforced and no 21 | * error code is generated. 22 | */ 23 | 24 | #ifndef BYTE_QUEUE_H 25 | #define BYTE_QUEUE_H 26 | 27 | #include 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /// ByteQueue instance state struct, voluntarily opaque. 34 | struct ByteQueue { 35 | uint8_t* data; // pointer to array allocated for data 36 | uint8_t *start; // points to first data byte 37 | uint8_t *end; // points to empty byte past last data byte 38 | uint16_t data_size; // size allocated for data 39 | uint16_t count; // current contained element count 40 | }; 41 | 42 | // initialize buffer as empty 43 | // must provide pointer to allocated array for buffer to use 44 | void InitBQ(struct ByteQueue *b, uint8_t* data, uint16_t data_size); 45 | 46 | // return 1 if buffer full, 0 else 47 | int8_t IsFullBQ(struct ByteQueue *b); 48 | 49 | // return 1 if buffer empty, 0 else 50 | int8_t IsEmptyBQ(struct ByteQueue *b); 51 | 52 | // return number elements in buffer 53 | uint16_t CountBQ(struct ByteQueue *p); 54 | 55 | // read and remove next character from buffer 56 | uint8_t GetByteBQ(struct ByteQueue *b); 57 | 58 | // read but don't remove next character from buffer 59 | uint8_t PeekByteBQ(struct ByteQueue *b); 60 | 61 | // add one character to buffer 62 | // return 1 for success, 0 for failure (buffer overflow) 63 | int8_t PutByteBQ(struct ByteQueue *b, uint8_t item); 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif // __cplusplus 68 | 69 | #endif // BYTE_QUEUE_H 70 | -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/client_communication.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: client_communication.cpp 11 | Last update: 4/12/2019 by Matthew Piccoli 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #include "client_communication.hpp" 17 | 18 | int8_t ParseMsg(uint8_t* rx_data, uint8_t rx_length, 19 | ClientEntryAbstract** entry_array, uint8_t entry_length) 20 | { 21 | uint8_t type_idn = rx_data[0]; 22 | uint8_t sub_idn = rx_data[1]; 23 | uint8_t obj_idn = rx_data[2] >> 2; // high 6 bits are obj_idn 24 | Access dir = static_cast(rx_data[2] & 0b00000011); // low two bits 25 | 26 | // if we have a reply (we only parse replies here) 27 | if(dir == kReply) 28 | { 29 | // if sub_idn is within array range (safe to access array at this location) 30 | if(sub_idn < entry_length) 31 | { 32 | // if there is a ClientEntry object at this sub_idn 33 | if(entry_array[sub_idn] != nullptr) 34 | { 35 | // if the type and obj identifiers match 36 | if(entry_array[sub_idn]->type_idn_ == type_idn && 37 | entry_array[sub_idn]->obj_idn_ == obj_idn) 38 | { 39 | // ... then we have a valid message 40 | entry_array[sub_idn]->Reply(&rx_data[3],rx_length-3); 41 | return 1; // I parsed something 42 | } 43 | } 44 | } 45 | } 46 | return 0; // I didn't parse anything 47 | } 48 | 49 | int8_t ParseMsg(uint8_t* rx_data, uint8_t rx_length, 50 | ClientEntryAbstract& entry) 51 | { 52 | uint8_t type_idn = rx_data[0]; 53 | uint8_t sub_idn = rx_data[1]; 54 | uint8_t obj_idn = rx_data[2] >> 2; // high 6 bits are obj_idn 55 | Access dir = static_cast(rx_data[2] & 0b00000011); // low two bits 56 | 57 | // if we have a reply (we only parse replies here) 58 | if(dir == kReply) 59 | { 60 | // if the type and obj identifiers match 61 | if(entry.type_idn_ == type_idn && 62 | entry.obj_idn_ == obj_idn && entry.sub_idn_ == sub_idn) 63 | { 64 | // ... then we have a valid message 65 | entry.Reply(&rx_data[3],rx_length-3); 66 | return 1; // I parsed something 67 | } 68 | } 69 | return 0; // I didn't parse anything 70 | } -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/crc_helper.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | IQ C++ API is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | IQ C++ API is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | /* 21 | Name: crc_helper.c 22 | Last update: 3/7/2019 by Raphael Van Hoffelen 23 | Author: James Paulos 24 | Contributors: Matthew Piccoli, Raphael Van Hoffelen 25 | */ 26 | 27 | #include "crc_helper.h" 28 | 29 | // Compute CRC word for a byte string. 30 | uint16_t MakeCrc(const uint8_t *data, uint16_t count) { 31 | 32 | uint16_t crc = 0xffff; 33 | 34 | uint16_t i; 35 | for(i = 0; i < count; i++) { 36 | crc = ByteUpdateCrc(crc, data[i]); 37 | } 38 | return crc; 39 | } 40 | 41 | // Update a CRC accumulation with one data byte. 42 | uint16_t ByteUpdateCrc(uint16_t crc, uint8_t data) { 43 | 44 | uint16_t x = (crc >> 8) ^ data; 45 | x ^= x >> 4; 46 | 47 | crc = (crc << 8) ^ (x << 12) ^ (x <<5) ^ x; 48 | return crc; 49 | } 50 | 51 | // Update a CRC accumulation with several data bytes. 52 | uint16_t ArrayUpdateCrc(uint16_t crc, const uint8_t *data, uint16_t count) { 53 | 54 | uint16_t i; 55 | for(i = 0; i < count; i++) { 56 | crc = ByteUpdateCrc(crc, data[i]); 57 | } 58 | return crc; 59 | } 60 | -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/crc_helper.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: crc_helper.h 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: James Paulos 13 | Contributors: Matthew Piccoli, Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef CRC_HELPER_H 17 | #define CRC_HELPER_H 18 | 19 | #include 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /* Compute CRC word for a byte string. 26 | */ 27 | uint16_t MakeCrc(const uint8_t *data, uint16_t count); 28 | 29 | /* Update a CRC accumulation with one data byte. 30 | */ 31 | uint16_t ByteUpdateCrc(uint16_t crc, uint8_t data); 32 | 33 | /* Update a CRC accumulation with several data bytes. 34 | */ 35 | uint16_t ArrayUpdateCrc(uint16_t crc, const uint8_t *data, uint16_t count); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif // __cplusplus 40 | 41 | #endif -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/hobby_input_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: hobby_input_client.hpp 11 | Last update: 09/16/2022 by Ben Quan 12 | Author: Matthew Piccoli 13 | Contributors: Ben Quan, Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef HOBBY_INPUT_CLIENT_HPP_ 17 | #define HOBBY_INPUT_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeHobbyInput = 76; 22 | 23 | class HobbyInputClient: public ClientAbstract{ 24 | public: 25 | HobbyInputClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeHobbyInput, obj_idn), 27 | allowed_protocols_( kTypeHobbyInput, obj_idn, kSubAllowedProtocols), 28 | protocol_( kTypeHobbyInput, obj_idn, kSubProtocol), 29 | calibrated_protocol_( kTypeHobbyInput, obj_idn, kSubCalibratedProtocol), 30 | calibrated_high_ticks_us_( kTypeHobbyInput, obj_idn, kSubCalibratedHighTicksUs), 31 | calibrated_low_ticks_us_( kTypeHobbyInput, obj_idn, kSubCalibratedLowTicksUs), 32 | reset_calibration_( kTypeHobbyInput, obj_idn, kSubResetCalibration) 33 | {}; 34 | 35 | // Client Entries 36 | // Control commands 37 | ClientEntry allowed_protocols_; 38 | ClientEntry protocol_; 39 | ClientEntry calibrated_protocol_; 40 | ClientEntry calibrated_high_ticks_us_; 41 | ClientEntry calibrated_low_ticks_us_; 42 | ClientEntryVoid reset_calibration_; 43 | 44 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 45 | { 46 | static const uint8_t kEntryLength = kSubResetCalibration+1; 47 | ClientEntryAbstract* entry_array[kEntryLength] = { 48 | &allowed_protocols_, // 0 49 | &protocol_, // 1 50 | &calibrated_protocol_, // 2 51 | &calibrated_high_ticks_us_, // 3 52 | &calibrated_low_ticks_us_, // 4 53 | &reset_calibration_ // 5 54 | }; 55 | 56 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 57 | } 58 | 59 | private: 60 | static const uint8_t kSubAllowedProtocols = 0; 61 | static const uint8_t kSubProtocol = 1; 62 | static const uint8_t kSubCalibratedProtocol = 2; 63 | static const uint8_t kSubCalibratedHighTicksUs = 3; 64 | static const uint8_t kSubCalibratedLowTicksUs = 4; 65 | static const uint8_t kSubResetCalibration = 5; 66 | }; 67 | 68 | #endif /* HOBBY_INPUT_CLIENT_HPP_ */ 69 | -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/iq_module_communication.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: iq_module_communication.hpp 11 | Last update: 2023/04/24 by Ben Quan 12 | Author: Ben Quan, Matthew Piccoli 13 | */ 14 | 15 | #include "adc_interface_client.hpp" 16 | #include "anticogging_client.hpp" 17 | #include "arming_handler_client.hpp" 18 | #include "brushless_drive_client.hpp" 19 | #include "buzzer_control_client.hpp" 20 | #include "coil_temperature_estimator_client.hpp" 21 | #include "esc_propeller_input_parser_client.hpp" 22 | #include "gpio_controller_client.hpp" 23 | #include "hobby_input_client.hpp" 24 | #include "iq_serial.hpp" 25 | #include "iquart_flight_controller_interface_client.hpp" 26 | #include "multi_turn_angle_control_client.hpp" 27 | #include "persistent_memory_client.hpp" 28 | #include "power_monitor_client.hpp" 29 | #include "power_safety_client.hpp" 30 | #include "propeller_motor_control_client.hpp" 31 | #include "pulsing_rectangular_input_parser_client.hpp" 32 | #include "pwm_interface_client.hpp" 33 | #include "serial_interface_client.hpp" 34 | #include "servo_input_parser_client.hpp" 35 | #include "step_direction_input_client.hpp" 36 | #include "stopping_handler_client.hpp" 37 | #include "stow_user_interface_client.hpp" 38 | #include "system_control_client.hpp" 39 | #include "temperature_estimator_client.hpp" 40 | #include "temperature_monitor_uc_client.hpp" 41 | #include "uavcan_node_client.hpp" 42 | #include "voltage_superposition_client.hpp" 43 | -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/iq_module_communication_local.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: iq_module_communication.hpp 11 | Last update: 2023/07/14 by Fred Kummer 12 | Author: Ben Quan, Matthew Piccoli 13 | */ 14 | 15 | #include "adc_interface_client.hpp" 16 | #include "anticogging_client.hpp" 17 | #include "anticogging_pro_client.hpp" 18 | #include "arming_handler_client.hpp" 19 | #include "brushless_drive_client.hpp" 20 | #include "buzzer_control_client.hpp" 21 | #include "coil_temperature_estimator_client.hpp" 22 | #include "esc_propeller_input_parser_client.hpp" 23 | #include "gpio_controller_client.hpp" 24 | #include "hobby_input_client.hpp" 25 | #include "iq_serial.hpp" 26 | #include "iquart_flight_controller_interface_client.hpp" 27 | #include "mag_alpha_client.hpp" 28 | #include "multi_turn_angle_control_client.hpp" 29 | #include "persistent_memory_client.hpp" 30 | #include "power_monitor_client.hpp" 31 | #include "power_safety_client.hpp" 32 | #include "propeller_motor_control_client.hpp" 33 | #include "pulsing_rectangular_input_parser_client.hpp" 34 | #include "pwm_interface_client.hpp" 35 | #include "serial_interface_client.hpp" 36 | #include "servo_input_parser_client.hpp" 37 | #include "step_direction_input_client.hpp" 38 | #include "stopping_handler_client.hpp" 39 | #include "stow_user_interface_client.hpp" 40 | #include "system_control_client.hpp" 41 | #include "temperature_estimator_client.hpp" 42 | #include "temperature_monitor_uc_client.hpp" 43 | #include "throttle_source_manager_client.hpp" 44 | #include "uavcan_node_client.hpp" 45 | #include "voltage_superposition_client.hpp" 46 | -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/mag_alpha_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 Vertiq support@vertiq.co 3 | 4 | This file is part of the Vertiq C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: mag_alpha_client.hpp 11 | Last update: 2023/06/29 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef MAG_ALPHA_CLIENT_HPP 17 | #define MAG_ALPHA_CLIENT_HPP 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeMagAlpha = 75; 22 | 23 | class MagAlphaClient: public ClientAbstract{ 24 | public: 25 | MagAlphaClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeMagAlpha, obj_idn), 27 | angle_raw_(kTypeMagAlpha, obj_idn, kSubAngleRaw), 28 | angle_rad_(kTypeMagAlpha, obj_idn, kSubAngleRad), 29 | alarm_(kTypeMagAlpha, obj_idn, kSubAlarm), 30 | mght_(kTypeMagAlpha, obj_idn, kSubMght), 31 | mglt_(kTypeMagAlpha, obj_idn, kSubMglt), 32 | reg_val_(kTypeMagAlpha, obj_idn, kSubRegVal), 33 | reg_adr_(kTypeMagAlpha, obj_idn, kSubRegAdr), 34 | reg_str_(kTypeMagAlpha, obj_idn, kSubRegStr) 35 | {}; 36 | 37 | // Client Entries 38 | ClientEntry angle_raw_; 39 | ClientEntry angle_rad_; 40 | ClientEntry alarm_; 41 | ClientEntry mght_; 42 | ClientEntry mglt_; 43 | ClientEntry reg_val_; 44 | ClientEntry reg_adr_; 45 | ClientEntryVoid reg_str_; 46 | 47 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 48 | { 49 | static const uint8_t kEntryLength = kSubRegStr+1; 50 | ClientEntryAbstract* entry_array[kEntryLength] = { 51 | &angle_raw_, // 0 52 | &angle_rad_, // 1 53 | &alarm_, // 2 54 | &mght_, // 3 55 | &mglt_, // 4 56 | ®_val_, // 5 57 | ®_adr_, // 6 58 | ®_str_ // 7 59 | }; 60 | 61 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 62 | } 63 | 64 | private: 65 | static const uint8_t kSubAngleRaw = 0; 66 | static const uint8_t kSubAngleRad = 1; 67 | static const uint8_t kSubAlarm = 2; 68 | static const uint8_t kSubMght = 3; 69 | static const uint8_t kSubMglt = 4; 70 | static const uint8_t kSubRegVal = 5; 71 | static const uint8_t kSubRegAdr = 6; 72 | static const uint8_t kSubRegStr = 7; 73 | }; 74 | 75 | #endif // MAG_ALPHA_CLIENT_H -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/persistent_memory_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: persistent_memory_client.hpp 11 | Last update: 10/31/2022 by Ben Quan 12 | Author: Matthew Piccoli 13 | Contributors: Ben Quan, Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef PERSISTENT_MEMORY_CLIENT_HPP_ 17 | #define PERSISTENT_MEMORY_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypePersistentMemory = 11; 22 | 23 | class PersistentMemoryClient: public ClientAbstract{ 24 | public: 25 | PersistentMemoryClient(uint8_t obj_idn): 26 | ClientAbstract( kTypePersistentMemory, obj_idn), 27 | erase_( kTypePersistentMemory, obj_idn, kSubErase), 28 | revert_to_default_( kTypePersistentMemory, obj_idn, kSubRevertToDefault), 29 | format_key_1_( kTypePersistentMemory, obj_idn, kSubFormatKey1), 30 | format_key_2_( kTypePersistentMemory, obj_idn, kSubFormatKey2) 31 | {}; 32 | 33 | // Client Entries 34 | // Control commands 35 | ClientEntryVoid erase_; 36 | ClientEntryVoid revert_to_default_; 37 | ClientEntry format_key_1_; 38 | ClientEntry format_key_2_; 39 | 40 | 41 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 42 | { 43 | static const uint8_t kEntryLength = kSubFormatKey2+1; 44 | ClientEntryAbstract* entry_array[kEntryLength] = { 45 | &erase_, // 0 46 | &revert_to_default_, // 1 47 | &format_key_1_, // 2 48 | &format_key_2_ // 3 49 | }; 50 | 51 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 52 | } 53 | 54 | private: 55 | static const uint8_t kSubErase = 0; 56 | static const uint8_t kSubRevertToDefault = 1; 57 | static const uint8_t kSubFormatKey1 = 2; 58 | static const uint8_t kSubFormatKey2 = 3; 59 | }; 60 | 61 | #endif /* PERSISTENT_MEMORY_CLIENT_HPP_ */ 62 | -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/pulsing_rectangular_input_parser_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: pulsing_rectangular_input_parser_client.hpp 11 | Last update: 2024/08/26 by Fred Kummer 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef PULSING_RECTANGULAR_INPUT_PARSER_CLIENT_HPP_ 17 | #define PULSING_RECTANGULAR_INPUT_PARSER_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypePulsingRectangularInputParser = 89; 22 | 23 | class PulsingRectangularInputParserClient : public ClientAbstract { 24 | public: 25 | PulsingRectangularInputParserClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypePulsingRectangularInputParser, obj_idn), 27 | pulsing_scaling_mode_(kTypePulsingRectangularInputParser, obj_idn, kSubPulsingScalingMode), 28 | pulsing_scaling_limit_(kTypePulsingRectangularInputParser, obj_idn, kSubPulsingScalingLimit){}; 29 | 30 | // Client Entries 31 | ClientEntry pulsing_scaling_mode_; 32 | ClientEntry pulsing_scaling_limit_; 33 | 34 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 35 | static const uint8_t kEntryLength = kSubPulsingScalingLimit + 1; 36 | ClientEntryAbstract* entry_array[kEntryLength] = { 37 | &pulsing_scaling_mode_, // 0 38 | &pulsing_scaling_limit_ // 1 39 | }; 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubPulsingScalingMode = 0; 45 | static const uint8_t kSubPulsingScalingLimit = 1; 46 | }; 47 | 48 | #endif /* PULSING_RECTANGULAR_INPUT_PARSER_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/pwm_interface_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: pwm_interface_client.hpp 11 | Last update: 2023/04/18 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef PWM_INTERFACE_CLIENT_HPP_ 17 | #define PWM_INTERFACE_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypePwmInterface = 92; 22 | 23 | class PwmInterfaceClient : public ClientAbstract { 24 | public: 25 | PwmInterfaceClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypePwmInterface, obj_idn), 27 | pwm_frequency_(kTypePwmInterface, obj_idn, kSubPwmFrequency), 28 | duty_cycle_(kTypePwmInterface, obj_idn, kSubDutyCycle), 29 | pwm_mode_(kTypePwmInterface, obj_idn, kSubPwmMode){}; 30 | 31 | // Client Entries 32 | ClientEntry pwm_frequency_; 33 | ClientEntry duty_cycle_; 34 | ClientEntry pwm_mode_; 35 | 36 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 37 | static const uint8_t kEntryLength = kSubPwmMode + 1; 38 | ClientEntryAbstract* entry_array[kEntryLength] = { 39 | &pwm_frequency_, // 0 40 | &duty_cycle_, // 1 41 | &pwm_mode_ // 2 42 | }; 43 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 44 | } 45 | 46 | private: 47 | static const uint8_t kSubPwmFrequency = 0; 48 | static const uint8_t kSubDutyCycle = 1; 49 | static const uint8_t kSubPwmMode = 2; 50 | }; 51 | 52 | #endif /* PWM_INTERFACE_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/rgb_led.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 Vertiq, Inc support@vertiq.co 3 | 4 | This file is part of the Vertiq C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | #ifndef RGB_LED_CLIENT_H 10 | #define RGB_LED_CLIENT_H 11 | 12 | #include "client_communication.hpp" 13 | 14 | const uint8_t kTypeRgbLed = 100; 15 | 16 | class RgbLedClient : public ClientAbstract { 17 | public: 18 | RgbLedClient(uint8_t obj_idn) 19 | : ClientAbstract(kTypeRgbLed, obj_idn), 20 | red_(kTypeRgbLed, obj_idn, kSubRed), 21 | green_(kTypeRgbLed, obj_idn, kSubGreen), 22 | blue_(kTypeRgbLed, obj_idn, kSubBlue), 23 | update_color_(kTypeRgbLed, obj_idn, kSubUpdateColor), 24 | strobe_active_(kTypeRgbLed, obj_idn, kSubStrobeActive), 25 | strobe_period_(kTypeRgbLed, obj_idn, kSubStrobePeriod), 26 | strobe_pattern_(kTypeRgbLed, obj_idn, kSubStrobePattern){}; 27 | 28 | // Client Entries 29 | ClientEntry red_; 30 | ClientEntry green_; 31 | ClientEntry blue_; 32 | ClientEntryVoid update_color_; 33 | ClientEntry strobe_active_; 34 | ClientEntry strobe_period_; 35 | ClientEntry strobe_pattern_; 36 | 37 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 38 | static const uint8_t kEntryLength = kSubStrobePattern + 1; 39 | ClientEntryAbstract* entry_array[kEntryLength] = { 40 | &red_, // 0 41 | &green_, // 1 42 | &blue_, // 2 43 | &update_color_, // 3 44 | &strobe_active_, // 4 45 | &strobe_period_, // 5 46 | &strobe_pattern_ // 6 47 | }; 48 | 49 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 50 | } 51 | 52 | private: 53 | static const uint8_t kSubRed = 0; 54 | static const uint8_t kSubGreen = 1; 55 | static const uint8_t kSubBlue = 2; 56 | static const uint8_t kSubUpdateColor = 3; 57 | static const uint8_t kSubStrobeActive = 4; 58 | static const uint8_t kSubStrobePeriod = 5; 59 | static const uint8_t kSubStrobePattern = 6; 60 | 61 | }; 62 | 63 | #endif // RGB_LED_CLIENT_H 64 | -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/serial_interface_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: serial_interface_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef SERIAL_INTERFACE_CLIENT_H 17 | #define SERIAL_INTERFACE_CLIENT_H 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeSerialInterface = 16; 22 | 23 | class SerialInterfaceClient: public ClientAbstract{ 24 | public: 25 | SerialInterfaceClient(uint8_t obj_idn): 26 | ClientAbstract(kTypeSerialInterface, obj_idn), 27 | baud_rate_( kTypeSerialInterface, obj_idn, kSubBaudRate) 28 | {}; 29 | 30 | // Client Entries 31 | ClientEntry baud_rate_; 32 | 33 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 34 | { 35 | static const uint8_t kEntryLength = kSubBaudRate+1; 36 | ClientEntryAbstract* entry_array[kEntryLength] = { 37 | &baud_rate_, // 0 38 | }; 39 | 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubBaudRate = 0; 45 | }; 46 | 47 | #endif // SERIAL_INTERFACE_CLIENT_H 48 | -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/servo_input_parser_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: servo_input_parser_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef SERVO_INPUT_PARSER_CLIENT_HPP_ 17 | #define SERVO_INPUT_PARSER_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeServoInputParser = 78; 22 | 23 | class ServoInputParserClient: public ClientAbstract{ 24 | public: 25 | ServoInputParserClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeServoInputParser, obj_idn), 27 | mode_( kTypeServoInputParser, obj_idn, kSubMode), 28 | unit_min_( kTypeServoInputParser, obj_idn, kSubUnitMin), 29 | unit_max_( kTypeServoInputParser, obj_idn, kSubUnitMax) 30 | {}; 31 | 32 | // Client Entries 33 | // Control commands 34 | ClientEntry mode_; 35 | ClientEntry unit_min_; 36 | ClientEntry unit_max_; 37 | 38 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 39 | { 40 | static const uint8_t kEntryLength = kSubUnitMax+1; 41 | ClientEntryAbstract* entry_array[kEntryLength] = { 42 | &mode_, // 0 43 | &unit_min_, // 1 44 | &unit_max_ // 2 45 | }; 46 | 47 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 48 | } 49 | 50 | private: 51 | static const uint8_t kSubMode = 0; 52 | static const uint8_t kSubUnitMin = 1; 53 | static const uint8_t kSubUnitMax = 2; 54 | }; 55 | 56 | #endif /* SERVO_INPUT_PARSER_CLIENT_HPP_ */ 57 | -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/step_direction_input_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: step_direction_input_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef STEP_DIRECTION_INPUT_CLIENT_HPP_ 17 | #define STEP_DIRECTION_INPUT_CLIENT_HPP_ 18 | 19 | 20 | #include "client_communication.hpp" 21 | 22 | const uint8_t kTypeStepDirInput = 58; 23 | 24 | class StepDirectionInputClient: public ClientAbstract{ 25 | public: 26 | StepDirectionInputClient(uint8_t obj_idn): 27 | ClientAbstract( kTypeStepDirInput, obj_idn), 28 | angle_( kTypeStepDirInput, obj_idn, kSubAngle), 29 | angle_step_( kTypeStepDirInput, obj_idn, kSubAngleStep) 30 | {}; 31 | 32 | // Client Entries 33 | ClientEntry angle_; 34 | ClientEntry angle_step_; 35 | 36 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 37 | { 38 | static const uint8_t kEntryLength = kSubAngleStep+1; 39 | ClientEntryAbstract* entry_array[kEntryLength] = { 40 | &angle_, // 0 41 | &angle_step_ // 1 42 | }; 43 | 44 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 45 | } 46 | 47 | private: 48 | static const uint8_t kSubAngle = 0; 49 | static const uint8_t kSubAngleStep = 1; 50 | }; 51 | 52 | #endif /* STEP_DIRECTION_INPUT_CLIENT_HPP_ */ 53 | -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/stopping_handler_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: stopping_handler_client.hpp 11 | Last update: 2023/04/12 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef STOPPING_HANDLER_CLIENT_HPP_ 17 | #define STOPPING_HANDLER_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeStoppingHandler = 87; 22 | 23 | class StoppingHandlerClient : public ClientAbstract { 24 | public: 25 | StoppingHandlerClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypeStoppingHandler, obj_idn), 27 | stopped_speed_(kTypeStoppingHandler, obj_idn, kSubStoppedSpeed), 28 | stopped_time_(kTypeStoppingHandler, obj_idn, kSubStoppedTime){}; 29 | 30 | // Client Entries 31 | ClientEntry stopped_speed_; 32 | ClientEntry stopped_time_; 33 | 34 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 35 | static const uint8_t kEntryLength = kSubStoppedTime + 1; 36 | ClientEntryAbstract* entry_array[kEntryLength] = { 37 | &stopped_speed_, // 0 38 | &stopped_time_ // 1 39 | }; 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubStoppedSpeed = 0; 45 | static const uint8_t kSubStoppedTime = 1; 46 | }; 47 | 48 | #endif /* STOPPING_HANDLER_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/temperature_estimator_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: temperature_estimator_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | 17 | #ifndef TEMPERATURE_ESTIMATOR_CLIENT_HPP_ 18 | #define TEMPERATURE_ESTIMATOR_CLIENT_HPP_ 19 | 20 | #include "client_communication.hpp" 21 | 22 | const uint8_t kTypeTemperatureEstimatorClient = 77; 23 | 24 | class TemperatureEstimatorClient: public ClientAbstract{ 25 | public: 26 | TemperatureEstimatorClient(uint8_t obj_idn): 27 | ClientAbstract( kTypeTemperatureEstimatorClient, obj_idn), 28 | temp_( kTypeTemperatureEstimatorClient, obj_idn, kSubTemp), 29 | otw_( kTypeTemperatureEstimatorClient, obj_idn, kSubOtw), 30 | otlo_( kTypeTemperatureEstimatorClient, obj_idn, kSubOtlo), 31 | thermal_resistance_( kTypeTemperatureEstimatorClient, obj_idn, kSubThermalResistance), 32 | thermal_capacitance_( kTypeTemperatureEstimatorClient, obj_idn, kSubThermalCapacitance), 33 | derate_( kTypeTemperatureEstimatorClient, obj_idn, kSubDerate) 34 | {}; 35 | 36 | // Client Entries 37 | // Control commands 38 | ClientEntry temp_; 39 | ClientEntry otw_; 40 | ClientEntry otlo_; 41 | ClientEntry thermal_resistance_; 42 | ClientEntry thermal_capacitance_; 43 | ClientEntry derate_; 44 | 45 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 46 | { 47 | static const uint8_t kEntryLength = kSubDerate+1; 48 | ClientEntryAbstract* entry_array[kEntryLength] = { 49 | &temp_, // 0 50 | &otw_, // 1 51 | &otlo_, // 2 52 | &thermal_resistance_, // 3 53 | &thermal_capacitance_,// 4 54 | &derate_ // 5 55 | }; 56 | 57 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 58 | } 59 | 60 | private: 61 | static const uint8_t kSubTemp = 0; 62 | static const uint8_t kSubOtw = 1; 63 | static const uint8_t kSubOtlo = 2; 64 | static const uint8_t kSubThermalResistance = 3; 65 | static const uint8_t kSubThermalCapacitance = 4; 66 | static const uint8_t kSubDerate = 5; 67 | }; 68 | 69 | #endif /* TEMPERATURE_ESTIMATOR_CLIENT_HPP_ */ 70 | -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/temperature_monitor_uc_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: temperature_monitor_uc_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef TEMPERATURE_MONITOR_UC_CLIENT_HPP_ 17 | #define TEMPERATURE_MONITOR_UC_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeTemperatureMonitorUcClient = 73; 22 | 23 | class TemperatureMonitorUcClient: public ClientAbstract{ 24 | public: 25 | TemperatureMonitorUcClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeTemperatureMonitorUcClient, obj_idn), 27 | uc_temp_( kTypeTemperatureMonitorUcClient, obj_idn, kSubUcTemp), 28 | filter_fs_( kTypeTemperatureMonitorUcClient, obj_idn, kSubFilterFs), 29 | filter_fc_( kTypeTemperatureMonitorUcClient, obj_idn, kSubFilterFc), 30 | otw_( kTypeTemperatureMonitorUcClient, obj_idn, kSubOtw), 31 | otlo_( kTypeTemperatureMonitorUcClient, obj_idn, kSubOtlo), 32 | derate_( kTypeTemperatureMonitorUcClient, obj_idn, kSubDerate) 33 | {}; 34 | 35 | // Client Entries 36 | // Control commands 37 | ClientEntry uc_temp_; 38 | ClientEntry filter_fs_; 39 | ClientEntry filter_fc_; 40 | ClientEntry otw_; 41 | ClientEntry otlo_; 42 | ClientEntry derate_; 43 | 44 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 45 | { 46 | static const uint8_t kEntryLength = kSubDerate+1; 47 | ClientEntryAbstract* entry_array[kEntryLength] = { 48 | &uc_temp_, // 0 49 | &filter_fs_, // 1 50 | &filter_fc_, // 2 51 | &otw_, // 3 52 | &otlo_, // 4 53 | &derate_ // 5 54 | }; 55 | 56 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 57 | } 58 | 59 | private: 60 | static const uint8_t kSubUcTemp = 0; 61 | static const uint8_t kSubFilterFs = 1; 62 | static const uint8_t kSubFilterFc = 2; 63 | static const uint8_t kSubOtw = 3; 64 | static const uint8_t kSubOtlo = 4; 65 | static const uint8_t kSubDerate = 5; 66 | }; 67 | 68 | #endif /* TEMPERATURE_MONITOR_UC_CLIENT_HPP_ */ 69 | -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/throttle_source_manager_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 Vertiq, Inc support@vertiq.co 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: throttle_source_manager_client.hpp 11 | Last update: 2024/01/30 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef THROTTLE_SOURCE_MANAGER_CLIENT_HPP_ 17 | #define THROTTLE_SOURCE_MANAGER_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeThrottleSourceManager = 104; 22 | 23 | class ThrottleSourceManagerClient : public ClientAbstract { 24 | public: 25 | ThrottleSourceManagerClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypeThrottleSourceManager, obj_idn), 27 | throttle_timeout_(kTypeThrottleSourceManager, obj_idn, kSubThrottleTimeout), 28 | dronecan_priority_(kTypeThrottleSourceManager, obj_idn, kSubDronecanPriority), 29 | hobby_priority_(kTypeThrottleSourceManager, obj_idn, kSubHobbyPriority), 30 | iquart_priority_(kTypeThrottleSourceManager, obj_idn, kSubIquartPriority) 31 | {}; 32 | 33 | // Client Entries 34 | ClientEntry throttle_timeout_; 35 | ClientEntry dronecan_priority_; 36 | ClientEntry hobby_priority_; 37 | ClientEntry iquart_priority_; 38 | 39 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 40 | static const uint8_t kEntryLength = kSubIquartPriority + 1; 41 | ClientEntryAbstract* entry_array[kEntryLength] = { 42 | &throttle_timeout_, // 0 43 | &dronecan_priority_, // 1 44 | &hobby_priority_, // 2 45 | &iquart_priority_, // 3 46 | }; 47 | 48 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 49 | } 50 | 51 | private: 52 | static const uint8_t kSubThrottleTimeout = 0; 53 | static const uint8_t kSubDronecanPriority = 1; 54 | static const uint8_t kSubHobbyPriority = 2; 55 | static const uint8_t kSubIquartPriority = 3; 56 | }; 57 | 58 | #endif /* THROTTLE_SOURCE_MANAGER_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /examples/tests/test_api_2306_speed/white_led.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 Vertiq, Inc support@vertiq.co 3 | 4 | This file is part of the Vertiq C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | #ifndef WHITE_LED_CLIENT_H 10 | #define WHITE_LED_CLIENT_H 11 | 12 | #include "client_communication.hpp" 13 | 14 | const uint8_t kTypeWhiteLed = 101; 15 | 16 | class WhiteLedClient : public ClientAbstract { 17 | public: 18 | WhiteLedClient(uint8_t obj_idn) 19 | : ClientAbstract(kTypeWhiteLed, obj_idn), 20 | intensity_(kTypeWhiteLed, obj_idn, kSubIntensity), 21 | strobe_active_(kTypeWhiteLed, obj_idn, kSubStrobeActive), 22 | strobe_period_(kTypeWhiteLed, obj_idn, kSubStrobePeriod), 23 | strobe_pattern_(kTypeWhiteLed, obj_idn, kSubStrobePattern){}; 24 | 25 | // Client Entries 26 | ClientEntry intensity_; 27 | ClientEntry strobe_active_; 28 | ClientEntry strobe_period_; 29 | ClientEntry strobe_pattern_; 30 | 31 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 32 | static const uint8_t kEntryLength = kSubStrobePattern + 1; 33 | ClientEntryAbstract* entry_array[kEntryLength] = { 34 | &intensity_, // 0 35 | &strobe_active_, // 1 36 | &strobe_period_, // 2 37 | &strobe_pattern_ // 3 38 | }; 39 | 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubIntensity = 0; 45 | static const uint8_t kSubStrobeActive = 1; 46 | static const uint8_t kSubStrobePeriod = 2; 47 | static const uint8_t kSubStrobePattern = 3; 48 | 49 | }; 50 | 51 | #endif // WHITE_LED_CLIENT_H 52 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/adc_interface_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: adc_interface_client.hpp 11 | Last update: 2023/04/18 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef ADC_INTERFACE_CLIENT_HPP_ 17 | #define ADC_INTERFACE_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeAdcInterface = 91; 22 | 23 | class AdcInterfaceClient : public ClientAbstract { 24 | public: 25 | AdcInterfaceClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypeAdcInterface, obj_idn), 27 | adc_voltage_(kTypeAdcInterface, obj_idn, kSubAdcVoltage), 28 | raw_value_(kTypeAdcInterface, obj_idn, kSubRawValue){}; 29 | 30 | // Client Entries 31 | ClientEntry adc_voltage_; 32 | ClientEntry raw_value_; 33 | 34 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 35 | static const uint8_t kEntryLength = kSubRawValue + 1; 36 | ClientEntryAbstract* entry_array[kEntryLength] = { 37 | &adc_voltage_, // 0 38 | &raw_value_ // 1 39 | }; 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubAdcVoltage = 0; 45 | static const uint8_t kSubRawValue = 1; 46 | }; 47 | 48 | #endif /* ADC_INTERFACE_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/anticogging_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: anticogging_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef ANTICOGGING_CLIENT_H 17 | #define ANTICOGGING_CLIENT_H 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeAnticogging = 71; 22 | 23 | class AnticoggingClient: public ClientAbstract{ 24 | public: 25 | AnticoggingClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeAnticogging, obj_idn), 27 | table_size_( kTypeAnticogging, obj_idn, kSubTableSize), 28 | is_data_valid_( kTypeAnticogging, obj_idn, kSubIsDataValid), 29 | is_enabled_( kTypeAnticogging, obj_idn, kSubIsEnabled), 30 | erase_( kTypeAnticogging, obj_idn, kSubErase), 31 | left_shift_( kTypeAnticogging, obj_idn, kSubLeftShift) 32 | {}; 33 | 34 | // Client Entries 35 | ClientEntry table_size_; 36 | ClientEntry is_data_valid_; 37 | ClientEntry is_enabled_; 38 | ClientEntryVoid erase_; 39 | ClientEntry left_shift_; 40 | 41 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 42 | { 43 | static const uint8_t kEntryLength = kSubLeftShift+1; 44 | ClientEntryAbstract* entry_array[kEntryLength] = { 45 | &table_size_, // 0 46 | &is_data_valid_, // 1 47 | &is_enabled_, // 2 48 | &erase_, // 3 49 | &left_shift_ // 4 50 | }; 51 | 52 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 53 | } 54 | 55 | private: 56 | static const uint8_t kSubTableSize = 0; 57 | static const uint8_t kSubIsDataValid = 1; 58 | static const uint8_t kSubIsEnabled = 2; 59 | static const uint8_t kSubErase = 3; 60 | static const uint8_t kSubLeftShift = 4; 61 | }; 62 | 63 | #endif // ANTICOGGING_CLIENT_H 64 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/anticogging_pro_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 Vertiq support@vertiq.co 3 | 4 | This file is part of the Vertiq C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: anticogging_pro_client.hpp 11 | Last update: 2023/07/14 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef ANTICOGGING_PRO_CLIENT_HPP 17 | #define ANTICOGGING_PRO_CLIENT_HPP 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeAnticoggingPro = 79; 22 | 23 | class AnticoggingProClient: public ClientAbstract{ 24 | public: 25 | AnticoggingProClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeAnticoggingPro, obj_idn), 27 | enabled_(kTypeAnticoggingPro, obj_idn, kSubEnabled), 28 | tau_(kTypeAnticoggingPro, obj_idn, kSubTau), 29 | num_harmonics_(kTypeAnticoggingPro, obj_idn, kSubNumHarmonics), 30 | voltage_(kTypeAnticoggingPro, obj_idn, kSubVoltage), 31 | index_(kTypeAnticoggingPro, obj_idn, kSubIndex), 32 | harmonic_(kTypeAnticoggingPro, obj_idn, kSubHarmonic), 33 | a_(kTypeAnticoggingPro, obj_idn, kSubA), 34 | phase_(kTypeAnticoggingPro, obj_idn, kSubPhase), 35 | phase_total_(kTypeAnticoggingPro, obj_idn, kSubPhaseTotal), 36 | amplitude_(kTypeAnticoggingPro, obj_idn, kSubAmplitude), 37 | max_harmonics_(kTypeAnticoggingPro, obj_idn, kSubMaxHarmonics) 38 | {}; 39 | 40 | // Client Entries 41 | ClientEntry enabled_; 42 | ClientEntry tau_; 43 | ClientEntry num_harmonics_; 44 | ClientEntry voltage_; 45 | ClientEntry index_; 46 | ClientEntry harmonic_; 47 | ClientEntry a_; 48 | ClientEntry phase_; 49 | ClientEntry phase_total_; 50 | ClientEntry amplitude_; 51 | ClientEntry max_harmonics_; 52 | 53 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 54 | { 55 | static const uint8_t kEntryLength = kSubMaxHarmonics+1; 56 | ClientEntryAbstract* entry_array[kEntryLength] = { 57 | &enabled_, // 0 58 | &tau_, // 1 59 | &num_harmonics_, // 2 60 | &voltage_, // 3 61 | &index_, // 4 62 | &harmonic_, // 5 63 | &a_, // 6 64 | &phase_, // 7 65 | &phase_total_, // 8 66 | &litude_, // 9 67 | &max_harmonics_ // 10 68 | }; 69 | 70 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 71 | } 72 | 73 | private: 74 | static const uint8_t kSubEnabled = 0; 75 | static const uint8_t kSubTau = 1; 76 | static const uint8_t kSubNumHarmonics = 2; 77 | static const uint8_t kSubVoltage = 3; 78 | static const uint8_t kSubIndex = 4; 79 | static const uint8_t kSubHarmonic = 5; 80 | static const uint8_t kSubA = 6; 81 | static const uint8_t kSubPhase = 7; 82 | static const uint8_t kSubPhaseTotal = 8; 83 | static const uint8_t kSubAmplitude = 9; 84 | static const uint8_t kSubMaxHarmonics = 10; 85 | }; 86 | 87 | #endif // ANTICOGGING_PRO_CLIENT_H 88 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/buzzer_control_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: buzzer_control_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef BUZZER_CONTROL_CLIENT_H 17 | #define BUZZER_CONTROL_CLIENT_H 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeBuzzerControl = 61; 22 | 23 | class BuzzerControlClient: public ClientAbstract{ 24 | public: 25 | BuzzerControlClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeBuzzerControl, obj_idn), 27 | ctrl_mode_( kTypeBuzzerControl, obj_idn, kSubCtrlMode), 28 | ctrl_brake_( kTypeBuzzerControl, obj_idn, kSubCtrlBrake), 29 | ctrl_coast_( kTypeBuzzerControl, obj_idn, kSubCtrlCoast), 30 | ctrl_note_( kTypeBuzzerControl, obj_idn, kSubCtrlNote), 31 | volume_max_( kTypeBuzzerControl, obj_idn, kSubVolumeMax), 32 | hz_( kTypeBuzzerControl, obj_idn, kSubHz), 33 | volume_( kTypeBuzzerControl, obj_idn, kSubVolume), 34 | duration_( kTypeBuzzerControl, obj_idn, kSubDuration) 35 | {}; 36 | 37 | // Client Entries 38 | ClientEntryVoid ctrl_mode_; 39 | ClientEntryVoid ctrl_brake_; 40 | ClientEntryVoid ctrl_coast_; 41 | ClientEntryVoid ctrl_note_; 42 | ClientEntry volume_max_; 43 | ClientEntry hz_; 44 | ClientEntry volume_; 45 | ClientEntry duration_; 46 | 47 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 48 | { 49 | static const uint8_t kEntryLength = kSubDuration+1; 50 | ClientEntryAbstract* entry_array[kEntryLength] = { 51 | &ctrl_mode_, // 0 52 | &ctrl_brake_, // 1 53 | &ctrl_coast_, // 2 54 | &ctrl_note_, // 3 55 | &volume_max_, // 4 56 | &hz_, // 5 57 | &volume_, // 6 58 | &duration_, // 7 59 | }; 60 | 61 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 62 | } 63 | 64 | private: 65 | static const uint8_t kSubCtrlMode = 0; 66 | static const uint8_t kSubCtrlBrake = 1; 67 | static const uint8_t kSubCtrlCoast = 2; 68 | static const uint8_t kSubCtrlNote = 3; 69 | static const uint8_t kSubVolumeMax = 4; 70 | static const uint8_t kSubHz = 5; 71 | static const uint8_t kSubVolume = 6; 72 | static const uint8_t kSubDuration = 7; 73 | }; 74 | 75 | #endif // BUZZER_CONTROL_CLIENT_H 76 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/byte_queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: byte_queue.h 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: James Paulos 13 | Contributors: Matthew Piccoli, Raphael Van Hoffelen 14 | */ 15 | 16 | /* A FIFO buffer for uint8 bytes implemented with a fixed size circular 17 | * buffer. A ByteQueue struct maintains the buffer data and state for one 18 | * buffer instance, and many simultaneous instances are supported. An operation 19 | * on one buffer must not be interrupted by another operation on that same 20 | * buffer (possibly via an interrupt). This restriction is not enforced and no 21 | * error code is generated. 22 | */ 23 | 24 | #ifndef BYTE_QUEUE_H 25 | #define BYTE_QUEUE_H 26 | 27 | #include 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /// ByteQueue instance state struct, voluntarily opaque. 34 | struct ByteQueue { 35 | uint8_t* data; // pointer to array allocated for data 36 | uint8_t *start; // points to first data byte 37 | uint8_t *end; // points to empty byte past last data byte 38 | uint16_t data_size; // size allocated for data 39 | uint16_t count; // current contained element count 40 | }; 41 | 42 | // initialize buffer as empty 43 | // must provide pointer to allocated array for buffer to use 44 | void InitBQ(struct ByteQueue *b, uint8_t* data, uint16_t data_size); 45 | 46 | // return 1 if buffer full, 0 else 47 | int8_t IsFullBQ(struct ByteQueue *b); 48 | 49 | // return 1 if buffer empty, 0 else 50 | int8_t IsEmptyBQ(struct ByteQueue *b); 51 | 52 | // return number elements in buffer 53 | uint16_t CountBQ(struct ByteQueue *p); 54 | 55 | // read and remove next character from buffer 56 | uint8_t GetByteBQ(struct ByteQueue *b); 57 | 58 | // read but don't remove next character from buffer 59 | uint8_t PeekByteBQ(struct ByteQueue *b); 60 | 61 | // add one character to buffer 62 | // return 1 for success, 0 for failure (buffer overflow) 63 | int8_t PutByteBQ(struct ByteQueue *b, uint8_t item); 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif // __cplusplus 68 | 69 | #endif // BYTE_QUEUE_H 70 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/client_communication.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: client_communication.cpp 11 | Last update: 4/12/2019 by Matthew Piccoli 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #include "client_communication.hpp" 17 | 18 | int8_t ParseMsg(uint8_t* rx_data, uint8_t rx_length, 19 | ClientEntryAbstract** entry_array, uint8_t entry_length) 20 | { 21 | uint8_t type_idn = rx_data[0]; 22 | uint8_t sub_idn = rx_data[1]; 23 | uint8_t obj_idn = rx_data[2] >> 2; // high 6 bits are obj_idn 24 | Access dir = static_cast(rx_data[2] & 0b00000011); // low two bits 25 | 26 | // if we have a reply (we only parse replies here) 27 | if(dir == kReply) 28 | { 29 | // if sub_idn is within array range (safe to access array at this location) 30 | if(sub_idn < entry_length) 31 | { 32 | // if there is a ClientEntry object at this sub_idn 33 | if(entry_array[sub_idn] != nullptr) 34 | { 35 | // if the type and obj identifiers match 36 | if(entry_array[sub_idn]->type_idn_ == type_idn && 37 | entry_array[sub_idn]->obj_idn_ == obj_idn) 38 | { 39 | // ... then we have a valid message 40 | entry_array[sub_idn]->Reply(&rx_data[3],rx_length-3); 41 | return 1; // I parsed something 42 | } 43 | } 44 | } 45 | } 46 | return 0; // I didn't parse anything 47 | } 48 | 49 | int8_t ParseMsg(uint8_t* rx_data, uint8_t rx_length, 50 | ClientEntryAbstract& entry) 51 | { 52 | uint8_t type_idn = rx_data[0]; 53 | uint8_t sub_idn = rx_data[1]; 54 | uint8_t obj_idn = rx_data[2] >> 2; // high 6 bits are obj_idn 55 | Access dir = static_cast(rx_data[2] & 0b00000011); // low two bits 56 | 57 | // if we have a reply (we only parse replies here) 58 | if(dir == kReply) 59 | { 60 | // if the type and obj identifiers match 61 | if(entry.type_idn_ == type_idn && 62 | entry.obj_idn_ == obj_idn && entry.sub_idn_ == sub_idn) 63 | { 64 | // ... then we have a valid message 65 | entry.Reply(&rx_data[3],rx_length-3); 66 | return 1; // I parsed something 67 | } 68 | } 69 | return 0; // I didn't parse anything 70 | } -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/crc_helper.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | IQ C++ API is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | IQ C++ API is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | /* 21 | Name: crc_helper.c 22 | Last update: 3/7/2019 by Raphael Van Hoffelen 23 | Author: James Paulos 24 | Contributors: Matthew Piccoli, Raphael Van Hoffelen 25 | */ 26 | 27 | #include "crc_helper.h" 28 | 29 | // Compute CRC word for a byte string. 30 | uint16_t MakeCrc(const uint8_t *data, uint16_t count) { 31 | 32 | uint16_t crc = 0xffff; 33 | 34 | uint16_t i; 35 | for(i = 0; i < count; i++) { 36 | crc = ByteUpdateCrc(crc, data[i]); 37 | } 38 | return crc; 39 | } 40 | 41 | // Update a CRC accumulation with one data byte. 42 | uint16_t ByteUpdateCrc(uint16_t crc, uint8_t data) { 43 | 44 | uint16_t x = (crc >> 8) ^ data; 45 | x ^= x >> 4; 46 | 47 | crc = (crc << 8) ^ (x << 12) ^ (x <<5) ^ x; 48 | return crc; 49 | } 50 | 51 | // Update a CRC accumulation with several data bytes. 52 | uint16_t ArrayUpdateCrc(uint16_t crc, const uint8_t *data, uint16_t count) { 53 | 54 | uint16_t i; 55 | for(i = 0; i < count; i++) { 56 | crc = ByteUpdateCrc(crc, data[i]); 57 | } 58 | return crc; 59 | } 60 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/crc_helper.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: crc_helper.h 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: James Paulos 13 | Contributors: Matthew Piccoli, Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef CRC_HELPER_H 17 | #define CRC_HELPER_H 18 | 19 | #include 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /* Compute CRC word for a byte string. 26 | */ 27 | uint16_t MakeCrc(const uint8_t *data, uint16_t count); 28 | 29 | /* Update a CRC accumulation with one data byte. 30 | */ 31 | uint16_t ByteUpdateCrc(uint16_t crc, uint8_t data); 32 | 33 | /* Update a CRC accumulation with several data bytes. 34 | */ 35 | uint16_t ArrayUpdateCrc(uint16_t crc, const uint8_t *data, uint16_t count); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif // __cplusplus 40 | 41 | #endif -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/hobby_input_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: hobby_input_client.hpp 11 | Last update: 09/16/2022 by Ben Quan 12 | Author: Matthew Piccoli 13 | Contributors: Ben Quan, Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef HOBBY_INPUT_CLIENT_HPP_ 17 | #define HOBBY_INPUT_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeHobbyInput = 76; 22 | 23 | class HobbyInputClient: public ClientAbstract{ 24 | public: 25 | HobbyInputClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeHobbyInput, obj_idn), 27 | allowed_protocols_( kTypeHobbyInput, obj_idn, kSubAllowedProtocols), 28 | protocol_( kTypeHobbyInput, obj_idn, kSubProtocol), 29 | calibrated_protocol_( kTypeHobbyInput, obj_idn, kSubCalibratedProtocol), 30 | calibrated_high_ticks_us_( kTypeHobbyInput, obj_idn, kSubCalibratedHighTicksUs), 31 | calibrated_low_ticks_us_( kTypeHobbyInput, obj_idn, kSubCalibratedLowTicksUs), 32 | reset_calibration_( kTypeHobbyInput, obj_idn, kSubResetCalibration) 33 | {}; 34 | 35 | // Client Entries 36 | // Control commands 37 | ClientEntry allowed_protocols_; 38 | ClientEntry protocol_; 39 | ClientEntry calibrated_protocol_; 40 | ClientEntry calibrated_high_ticks_us_; 41 | ClientEntry calibrated_low_ticks_us_; 42 | ClientEntryVoid reset_calibration_; 43 | 44 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 45 | { 46 | static const uint8_t kEntryLength = kSubResetCalibration+1; 47 | ClientEntryAbstract* entry_array[kEntryLength] = { 48 | &allowed_protocols_, // 0 49 | &protocol_, // 1 50 | &calibrated_protocol_, // 2 51 | &calibrated_high_ticks_us_, // 3 52 | &calibrated_low_ticks_us_, // 4 53 | &reset_calibration_ // 5 54 | }; 55 | 56 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 57 | } 58 | 59 | private: 60 | static const uint8_t kSubAllowedProtocols = 0; 61 | static const uint8_t kSubProtocol = 1; 62 | static const uint8_t kSubCalibratedProtocol = 2; 63 | static const uint8_t kSubCalibratedHighTicksUs = 3; 64 | static const uint8_t kSubCalibratedLowTicksUs = 4; 65 | static const uint8_t kSubResetCalibration = 5; 66 | }; 67 | 68 | #endif /* HOBBY_INPUT_CLIENT_HPP_ */ 69 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/iq_module_communication_local.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2025 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: iq_module_communication.hpp 11 | Last update: 2025/03/12 by Ben Quan 12 | Author: Ben Quan, Matthew Piccoli 13 | */ 14 | 15 | #include "adc_interface_client.hpp" 16 | #include "anticogging_client.hpp" 17 | #include "arming_handler_client.hpp" 18 | #include "brushless_drive_client.hpp" 19 | #include "buzzer_control_client.hpp" 20 | #include "coil_temperature_estimator_client.hpp" 21 | #include "esc_propeller_input_parser_client.hpp" 22 | #include "gpio_controller_client.hpp" 23 | #include "hobby_input_client.hpp" 24 | #include "iq_serial.hpp" 25 | #include "iquart_flight_controller_interface_client.hpp" 26 | #include "multi_turn_angle_control_client.hpp" 27 | #include "persistent_memory_client.hpp" 28 | #include "power_monitor_client.hpp" 29 | #include "power_safety_client.hpp" 30 | #include "propeller_motor_control_client.hpp" 31 | #include "pulsing_rectangular_input_parser_client.hpp" 32 | #include "pwm_interface_client.hpp" 33 | #include "serial_interface_client.hpp" 34 | #include "servo_input_parser_client.hpp" 35 | #include "step_direction_input_client.hpp" 36 | #include "stopping_handler_client.hpp" 37 | #include "stow_user_interface_client.hpp" 38 | #include "system_control_client.hpp" 39 | #include "temperature_estimator_client.hpp" 40 | #include "temperature_monitor_uc_client.hpp" 41 | #include "uavcan_node_client.hpp" 42 | #include "voltage_superposition_client.hpp" 43 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/mag_alpha_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 Vertiq support@vertiq.co 3 | 4 | This file is part of the Vertiq C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: mag_alpha_client.hpp 11 | Last update: 2023/07/14 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef MAG_ALPHA_CLIENT_HPP 17 | #define MAG_ALPHA_CLIENT_HPP 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeMagAlpha = 75; 22 | 23 | class MagAlphaClient: public ClientAbstract{ 24 | public: 25 | MagAlphaClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeMagAlpha, obj_idn), 27 | angle_raw_(kTypeMagAlpha, obj_idn, kSubAngleRaw), 28 | angle_rad_(kTypeMagAlpha, obj_idn, kSubAngleRad), 29 | alarm_(kTypeMagAlpha, obj_idn, kSubAlarm), 30 | mght_(kTypeMagAlpha, obj_idn, kSubMght), 31 | mglt_(kTypeMagAlpha, obj_idn, kSubMglt), 32 | reg_val_(kTypeMagAlpha, obj_idn, kSubRegVal), 33 | reg_adr_(kTypeMagAlpha, obj_idn, kSubRegAdr), 34 | reg_str_(kTypeMagAlpha, obj_idn, kSubRegStr) 35 | {}; 36 | 37 | // Client Entries 38 | ClientEntry angle_raw_; 39 | ClientEntry angle_rad_; 40 | ClientEntry alarm_; 41 | ClientEntry mght_; 42 | ClientEntry mglt_; 43 | ClientEntry reg_val_; 44 | ClientEntry reg_adr_; 45 | ClientEntryVoid reg_str_; 46 | 47 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 48 | { 49 | static const uint8_t kEntryLength = kSubRegStr+1; 50 | ClientEntryAbstract* entry_array[kEntryLength] = { 51 | &angle_raw_, // 0 52 | &angle_rad_, // 1 53 | &alarm_, // 2 54 | &mght_, // 3 55 | &mglt_, // 4 56 | ®_val_, // 5 57 | ®_adr_, // 6 58 | ®_str_ // 7 59 | }; 60 | 61 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 62 | } 63 | 64 | private: 65 | static const uint8_t kSubAngleRaw = 0; 66 | static const uint8_t kSubAngleRad = 1; 67 | static const uint8_t kSubAlarm = 2; 68 | static const uint8_t kSubMght = 3; 69 | static const uint8_t kSubMglt = 4; 70 | static const uint8_t kSubRegVal = 5; 71 | static const uint8_t kSubRegAdr = 6; 72 | static const uint8_t kSubRegStr = 7; 73 | }; 74 | 75 | #endif // MAG_ALPHA_CLIENT_H -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/persistent_memory_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: persistent_memory_client.hpp 11 | Last update: 10/31/2022 by Ben Quan 12 | Author: Matthew Piccoli 13 | Contributors: Ben Quan, Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef PERSISTENT_MEMORY_CLIENT_HPP_ 17 | #define PERSISTENT_MEMORY_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypePersistentMemory = 11; 22 | 23 | class PersistentMemoryClient: public ClientAbstract{ 24 | public: 25 | PersistentMemoryClient(uint8_t obj_idn): 26 | ClientAbstract( kTypePersistentMemory, obj_idn), 27 | erase_( kTypePersistentMemory, obj_idn, kSubErase), 28 | revert_to_default_( kTypePersistentMemory, obj_idn, kSubRevertToDefault), 29 | format_key_1_( kTypePersistentMemory, obj_idn, kSubFormatKey1), 30 | format_key_2_( kTypePersistentMemory, obj_idn, kSubFormatKey2) 31 | {}; 32 | 33 | // Client Entries 34 | // Control commands 35 | ClientEntryVoid erase_; 36 | ClientEntryVoid revert_to_default_; 37 | ClientEntry format_key_1_; 38 | ClientEntry format_key_2_; 39 | 40 | 41 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 42 | { 43 | static const uint8_t kEntryLength = kSubFormatKey2+1; 44 | ClientEntryAbstract* entry_array[kEntryLength] = { 45 | &erase_, // 0 46 | &revert_to_default_, // 1 47 | &format_key_1_, // 2 48 | &format_key_2_ // 3 49 | }; 50 | 51 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 52 | } 53 | 54 | private: 55 | static const uint8_t kSubErase = 0; 56 | static const uint8_t kSubRevertToDefault = 1; 57 | static const uint8_t kSubFormatKey1 = 2; 58 | static const uint8_t kSubFormatKey2 = 3; 59 | }; 60 | 61 | #endif /* PERSISTENT_MEMORY_CLIENT_HPP_ */ 62 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/pulsing_rectangular_input_parser_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: pulsing_rectangular_input_parser_client.hpp 11 | Last update: 2024/08/26 by Fred Kummer 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef PULSING_RECTANGULAR_INPUT_PARSER_CLIENT_HPP_ 17 | #define PULSING_RECTANGULAR_INPUT_PARSER_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypePulsingRectangularInputParser = 89; 22 | 23 | class PulsingRectangularInputParserClient : public ClientAbstract { 24 | public: 25 | PulsingRectangularInputParserClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypePulsingRectangularInputParser, obj_idn), 27 | pulsing_scaling_mode_(kTypePulsingRectangularInputParser, obj_idn, kSubPulsingScalingMode), 28 | pulsing_scaling_limit_(kTypePulsingRectangularInputParser, obj_idn, kSubPulsingScalingLimit){}; 29 | 30 | // Client Entries 31 | ClientEntry pulsing_scaling_mode_; 32 | ClientEntry pulsing_scaling_limit_; 33 | 34 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 35 | static const uint8_t kEntryLength = kSubPulsingScalingLimit + 1; 36 | ClientEntryAbstract* entry_array[kEntryLength] = { 37 | &pulsing_scaling_mode_, // 0 38 | &pulsing_scaling_limit_ // 1 39 | }; 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubPulsingScalingMode = 0; 45 | static const uint8_t kSubPulsingScalingLimit = 1; 46 | }; 47 | 48 | #endif /* PULSING_RECTANGULAR_INPUT_PARSER_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/pwm_interface_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: pwm_interface_client.hpp 11 | Last update: 2023/04/18 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef PWM_INTERFACE_CLIENT_HPP_ 17 | #define PWM_INTERFACE_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypePwmInterface = 92; 22 | 23 | class PwmInterfaceClient : public ClientAbstract { 24 | public: 25 | PwmInterfaceClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypePwmInterface, obj_idn), 27 | pwm_frequency_(kTypePwmInterface, obj_idn, kSubPwmFrequency), 28 | duty_cycle_(kTypePwmInterface, obj_idn, kSubDutyCycle), 29 | pwm_mode_(kTypePwmInterface, obj_idn, kSubPwmMode){}; 30 | 31 | // Client Entries 32 | ClientEntry pwm_frequency_; 33 | ClientEntry duty_cycle_; 34 | ClientEntry pwm_mode_; 35 | 36 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 37 | static const uint8_t kEntryLength = kSubPwmMode + 1; 38 | ClientEntryAbstract* entry_array[kEntryLength] = { 39 | &pwm_frequency_, // 0 40 | &duty_cycle_, // 1 41 | &pwm_mode_ // 2 42 | }; 43 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 44 | } 45 | 46 | private: 47 | static const uint8_t kSubPwmFrequency = 0; 48 | static const uint8_t kSubDutyCycle = 1; 49 | static const uint8_t kSubPwmMode = 2; 50 | }; 51 | 52 | #endif /* PWM_INTERFACE_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/rgb_led.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 Vertiq, Inc support@vertiq.co 3 | 4 | This file is part of the Vertiq C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | #ifndef RGB_LED_CLIENT_H 10 | #define RGB_LED_CLIENT_H 11 | 12 | #include "client_communication.hpp" 13 | 14 | const uint8_t kTypeRgbLed = 100; 15 | 16 | class RgbLedClient : public ClientAbstract { 17 | public: 18 | RgbLedClient(uint8_t obj_idn) 19 | : ClientAbstract(kTypeRgbLed, obj_idn), 20 | red_(kTypeRgbLed, obj_idn, kSubRed), 21 | green_(kTypeRgbLed, obj_idn, kSubGreen), 22 | blue_(kTypeRgbLed, obj_idn, kSubBlue), 23 | update_color_(kTypeRgbLed, obj_idn, kSubUpdateColor), 24 | strobe_active_(kTypeRgbLed, obj_idn, kSubStrobeActive), 25 | strobe_period_(kTypeRgbLed, obj_idn, kSubStrobePeriod), 26 | strobe_pattern_(kTypeRgbLed, obj_idn, kSubStrobePattern){}; 27 | 28 | // Client Entries 29 | ClientEntry red_; 30 | ClientEntry green_; 31 | ClientEntry blue_; 32 | ClientEntryVoid update_color_; 33 | ClientEntry strobe_active_; 34 | ClientEntry strobe_period_; 35 | ClientEntry strobe_pattern_; 36 | 37 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 38 | static const uint8_t kEntryLength = kSubStrobePattern + 1; 39 | ClientEntryAbstract* entry_array[kEntryLength] = { 40 | &red_, // 0 41 | &green_, // 1 42 | &blue_, // 2 43 | &update_color_, // 3 44 | &strobe_active_, // 4 45 | &strobe_period_, // 5 46 | &strobe_pattern_ // 6 47 | }; 48 | 49 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 50 | } 51 | 52 | private: 53 | static const uint8_t kSubRed = 0; 54 | static const uint8_t kSubGreen = 1; 55 | static const uint8_t kSubBlue = 2; 56 | static const uint8_t kSubUpdateColor = 3; 57 | static const uint8_t kSubStrobeActive = 4; 58 | static const uint8_t kSubStrobePeriod = 5; 59 | static const uint8_t kSubStrobePattern = 6; 60 | 61 | }; 62 | 63 | #endif // RGB_LED_CLIENT_H 64 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/serial_interface_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: serial_interface_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef SERIAL_INTERFACE_CLIENT_H 17 | #define SERIAL_INTERFACE_CLIENT_H 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeSerialInterface = 16; 22 | 23 | class SerialInterfaceClient: public ClientAbstract{ 24 | public: 25 | SerialInterfaceClient(uint8_t obj_idn): 26 | ClientAbstract(kTypeSerialInterface, obj_idn), 27 | baud_rate_( kTypeSerialInterface, obj_idn, kSubBaudRate) 28 | {}; 29 | 30 | // Client Entries 31 | ClientEntry baud_rate_; 32 | 33 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 34 | { 35 | static const uint8_t kEntryLength = kSubBaudRate+1; 36 | ClientEntryAbstract* entry_array[kEntryLength] = { 37 | &baud_rate_, // 0 38 | }; 39 | 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubBaudRate = 0; 45 | }; 46 | 47 | #endif // SERIAL_INTERFACE_CLIENT_H 48 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/servo_input_parser_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: servo_input_parser_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef SERVO_INPUT_PARSER_CLIENT_HPP_ 17 | #define SERVO_INPUT_PARSER_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeServoInputParser = 78; 22 | 23 | class ServoInputParserClient: public ClientAbstract{ 24 | public: 25 | ServoInputParserClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeServoInputParser, obj_idn), 27 | mode_( kTypeServoInputParser, obj_idn, kSubMode), 28 | unit_min_( kTypeServoInputParser, obj_idn, kSubUnitMin), 29 | unit_max_( kTypeServoInputParser, obj_idn, kSubUnitMax) 30 | {}; 31 | 32 | // Client Entries 33 | // Control commands 34 | ClientEntry mode_; 35 | ClientEntry unit_min_; 36 | ClientEntry unit_max_; 37 | 38 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 39 | { 40 | static const uint8_t kEntryLength = kSubUnitMax+1; 41 | ClientEntryAbstract* entry_array[kEntryLength] = { 42 | &mode_, // 0 43 | &unit_min_, // 1 44 | &unit_max_ // 2 45 | }; 46 | 47 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 48 | } 49 | 50 | private: 51 | static const uint8_t kSubMode = 0; 52 | static const uint8_t kSubUnitMin = 1; 53 | static const uint8_t kSubUnitMax = 2; 54 | }; 55 | 56 | #endif /* SERVO_INPUT_PARSER_CLIENT_HPP_ */ 57 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/step_direction_input_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: step_direction_input_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef STEP_DIRECTION_INPUT_CLIENT_HPP_ 17 | #define STEP_DIRECTION_INPUT_CLIENT_HPP_ 18 | 19 | 20 | #include "client_communication.hpp" 21 | 22 | const uint8_t kTypeStepDirInput = 58; 23 | 24 | class StepDirectionInputClient: public ClientAbstract{ 25 | public: 26 | StepDirectionInputClient(uint8_t obj_idn): 27 | ClientAbstract( kTypeStepDirInput, obj_idn), 28 | angle_( kTypeStepDirInput, obj_idn, kSubAngle), 29 | angle_step_( kTypeStepDirInput, obj_idn, kSubAngleStep) 30 | {}; 31 | 32 | // Client Entries 33 | ClientEntry angle_; 34 | ClientEntry angle_step_; 35 | 36 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 37 | { 38 | static const uint8_t kEntryLength = kSubAngleStep+1; 39 | ClientEntryAbstract* entry_array[kEntryLength] = { 40 | &angle_, // 0 41 | &angle_step_ // 1 42 | }; 43 | 44 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 45 | } 46 | 47 | private: 48 | static const uint8_t kSubAngle = 0; 49 | static const uint8_t kSubAngleStep = 1; 50 | }; 51 | 52 | #endif /* STEP_DIRECTION_INPUT_CLIENT_HPP_ */ 53 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/stopping_handler_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: stopping_handler_client.hpp 11 | Last update: 2023/04/12 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef STOPPING_HANDLER_CLIENT_HPP_ 17 | #define STOPPING_HANDLER_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeStoppingHandler = 87; 22 | 23 | class StoppingHandlerClient : public ClientAbstract { 24 | public: 25 | StoppingHandlerClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypeStoppingHandler, obj_idn), 27 | stopped_speed_(kTypeStoppingHandler, obj_idn, kSubStoppedSpeed), 28 | stopped_time_(kTypeStoppingHandler, obj_idn, kSubStoppedTime){}; 29 | 30 | // Client Entries 31 | ClientEntry stopped_speed_; 32 | ClientEntry stopped_time_; 33 | 34 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 35 | static const uint8_t kEntryLength = kSubStoppedTime + 1; 36 | ClientEntryAbstract* entry_array[kEntryLength] = { 37 | &stopped_speed_, // 0 38 | &stopped_time_ // 1 39 | }; 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubStoppedSpeed = 0; 45 | static const uint8_t kSubStoppedTime = 1; 46 | }; 47 | 48 | #endif /* STOPPING_HANDLER_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/temperature_estimator_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: temperature_estimator_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | 17 | #ifndef TEMPERATURE_ESTIMATOR_CLIENT_HPP_ 18 | #define TEMPERATURE_ESTIMATOR_CLIENT_HPP_ 19 | 20 | #include "client_communication.hpp" 21 | 22 | const uint8_t kTypeTemperatureEstimatorClient = 77; 23 | 24 | class TemperatureEstimatorClient: public ClientAbstract{ 25 | public: 26 | TemperatureEstimatorClient(uint8_t obj_idn): 27 | ClientAbstract( kTypeTemperatureEstimatorClient, obj_idn), 28 | temp_( kTypeTemperatureEstimatorClient, obj_idn, kSubTemp), 29 | otw_( kTypeTemperatureEstimatorClient, obj_idn, kSubOtw), 30 | otlo_( kTypeTemperatureEstimatorClient, obj_idn, kSubOtlo), 31 | thermal_resistance_( kTypeTemperatureEstimatorClient, obj_idn, kSubThermalResistance), 32 | thermal_capacitance_( kTypeTemperatureEstimatorClient, obj_idn, kSubThermalCapacitance), 33 | derate_( kTypeTemperatureEstimatorClient, obj_idn, kSubDerate) 34 | {}; 35 | 36 | // Client Entries 37 | // Control commands 38 | ClientEntry temp_; 39 | ClientEntry otw_; 40 | ClientEntry otlo_; 41 | ClientEntry thermal_resistance_; 42 | ClientEntry thermal_capacitance_; 43 | ClientEntry derate_; 44 | 45 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 46 | { 47 | static const uint8_t kEntryLength = kSubDerate+1; 48 | ClientEntryAbstract* entry_array[kEntryLength] = { 49 | &temp_, // 0 50 | &otw_, // 1 51 | &otlo_, // 2 52 | &thermal_resistance_, // 3 53 | &thermal_capacitance_,// 4 54 | &derate_ // 5 55 | }; 56 | 57 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 58 | } 59 | 60 | private: 61 | static const uint8_t kSubTemp = 0; 62 | static const uint8_t kSubOtw = 1; 63 | static const uint8_t kSubOtlo = 2; 64 | static const uint8_t kSubThermalResistance = 3; 65 | static const uint8_t kSubThermalCapacitance = 4; 66 | static const uint8_t kSubDerate = 5; 67 | }; 68 | 69 | #endif /* TEMPERATURE_ESTIMATOR_CLIENT_HPP_ */ 70 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/temperature_monitor_uc_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: temperature_monitor_uc_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef TEMPERATURE_MONITOR_UC_CLIENT_HPP_ 17 | #define TEMPERATURE_MONITOR_UC_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeTemperatureMonitorUcClient = 73; 22 | 23 | class TemperatureMonitorUcClient: public ClientAbstract{ 24 | public: 25 | TemperatureMonitorUcClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeTemperatureMonitorUcClient, obj_idn), 27 | uc_temp_( kTypeTemperatureMonitorUcClient, obj_idn, kSubUcTemp), 28 | filter_fs_( kTypeTemperatureMonitorUcClient, obj_idn, kSubFilterFs), 29 | filter_fc_( kTypeTemperatureMonitorUcClient, obj_idn, kSubFilterFc), 30 | otw_( kTypeTemperatureMonitorUcClient, obj_idn, kSubOtw), 31 | otlo_( kTypeTemperatureMonitorUcClient, obj_idn, kSubOtlo), 32 | derate_( kTypeTemperatureMonitorUcClient, obj_idn, kSubDerate) 33 | {}; 34 | 35 | // Client Entries 36 | // Control commands 37 | ClientEntry uc_temp_; 38 | ClientEntry filter_fs_; 39 | ClientEntry filter_fc_; 40 | ClientEntry otw_; 41 | ClientEntry otlo_; 42 | ClientEntry derate_; 43 | 44 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 45 | { 46 | static const uint8_t kEntryLength = kSubDerate+1; 47 | ClientEntryAbstract* entry_array[kEntryLength] = { 48 | &uc_temp_, // 0 49 | &filter_fs_, // 1 50 | &filter_fc_, // 2 51 | &otw_, // 3 52 | &otlo_, // 4 53 | &derate_ // 5 54 | }; 55 | 56 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 57 | } 58 | 59 | private: 60 | static const uint8_t kSubUcTemp = 0; 61 | static const uint8_t kSubFilterFs = 1; 62 | static const uint8_t kSubFilterFc = 2; 63 | static const uint8_t kSubOtw = 3; 64 | static const uint8_t kSubOtlo = 4; 65 | static const uint8_t kSubDerate = 5; 66 | }; 67 | 68 | #endif /* TEMPERATURE_MONITOR_UC_CLIENT_HPP_ */ 69 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/test_api_8108_speed.ino: -------------------------------------------------------------------------------- 1 | #include "iq_module_communication_local.hpp" 2 | 3 | IqSerial ser(Serial1); // Use the hardware serial port on arduino board 4 | PowerMonitorClient power(0); 5 | SystemControlClient sysctrl(0); 6 | CoilTemperatureEstimatorClient coilTemperatureEstimator(0); 7 | PowerMonitorClient powerMonitorClient(0); // Initialize Power Monitor Client 8 | EscPropellerInputParserClient escPropellerInputParser(0); 9 | 10 | void setup() { 11 | // put your setup code here, to run once: 12 | uint32_t uids[] = {0, 0, 0}; 13 | float voltage = 0.0; 14 | float amps = 0.0; 15 | float t_coil = 0.0; 16 | uint32_t controlFlags = 0; 17 | float volts_cascaded = 0.0; 18 | uint32_t volts_cascaded_filter_fc = 0; 19 | uint8_t report_telemetry_as_speed = 0; 20 | 21 | // Set up serial port 22 | ser.begin(115200); 23 | Serial.begin(115200); // This is used to print to the Serial Monitor 24 | Serial.println("Starting script"); 25 | 26 | // Get motor id 27 | ser.get(sysctrl.uid1_, uids[0]); 28 | ser.get(sysctrl.uid2_, uids[1]); 29 | ser.get(sysctrl.uid3_, uids[2]); 30 | Serial.print("Motor id: "); 31 | for (int i = 0; i < 3; i++) { 32 | Serial.print(uids[i]); 33 | if (i < 2) Serial.print("_"); 34 | } 35 | Serial.println(); 36 | 37 | //Get voltage 38 | if (ser.get(power.volts_, voltage)) { 39 | Serial.print("voltage: "); 40 | Serial.print(voltage); 41 | Serial.println(); 42 | } 43 | 44 | // Get amps 45 | if (ser.get(power.amps_, amps)) { 46 | Serial.print("amps: "); 47 | Serial.print(amps); 48 | Serial.println(); 49 | } 50 | 51 | // Get t_coil 52 | if (ser.get(coilTemperatureEstimator.t_coil_, t_coil)) { 53 | Serial.print("t_coil: "); 54 | Serial.print(t_coil); 55 | Serial.println(); 56 | } 57 | 58 | // Get control flags 59 | if (ser.get(sysctrl.control_flags_, controlFlags)) { 60 | Serial.print("control flags: "); 61 | Serial.print(controlFlags); 62 | Serial.println(); 63 | } 64 | 65 | 66 | if (ser.get(powerMonitorClient.volts_cascaded_, volts_cascaded)){ 67 | Serial.print("volts cascaded: "); 68 | Serial.print(volts_cascaded); 69 | Serial.println(); 70 | } 71 | 72 | if (ser.get(powerMonitorClient.volts_cascaded_filter_fc_, volts_cascaded_filter_fc)){ 73 | Serial.print("volts cascaded filter fc: "); 74 | Serial.print(volts_cascaded_filter_fc); 75 | Serial.println(); 76 | } 77 | 78 | if (ser.get(escPropellerInputParser.report_telemetry_as_speed_, report_telemetry_as_speed)){ 79 | Serial.print("report telemetry as speed: "); 80 | Serial.print(report_telemetry_as_speed); 81 | Serial.println(); 82 | } 83 | 84 | } 85 | 86 | void loop() { 87 | // put your main code here, to run repeatedly: 88 | } 89 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/throttle_source_manager_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 Vertiq, Inc support@vertiq.co 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: throttle_source_manager_client.hpp 11 | Last update: 2024/01/30 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef THROTTLE_SOURCE_MANAGER_CLIENT_HPP_ 17 | #define THROTTLE_SOURCE_MANAGER_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeThrottleSourceManager = 104; 22 | 23 | class ThrottleSourceManagerClient : public ClientAbstract { 24 | public: 25 | ThrottleSourceManagerClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypeThrottleSourceManager, obj_idn), 27 | throttle_timeout_(kTypeThrottleSourceManager, obj_idn, kSubThrottleTimeout), 28 | dronecan_priority_(kTypeThrottleSourceManager, obj_idn, kSubDronecanPriority), 29 | hobby_priority_(kTypeThrottleSourceManager, obj_idn, kSubHobbyPriority), 30 | iquart_priority_(kTypeThrottleSourceManager, obj_idn, kSubIquartPriority) 31 | {}; 32 | 33 | // Client Entries 34 | ClientEntry throttle_timeout_; 35 | ClientEntry dronecan_priority_; 36 | ClientEntry hobby_priority_; 37 | ClientEntry iquart_priority_; 38 | 39 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 40 | static const uint8_t kEntryLength = kSubIquartPriority + 1; 41 | ClientEntryAbstract* entry_array[kEntryLength] = { 42 | &throttle_timeout_, // 0 43 | &dronecan_priority_, // 1 44 | &hobby_priority_, // 2 45 | &iquart_priority_, // 3 46 | }; 47 | 48 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 49 | } 50 | 51 | private: 52 | static const uint8_t kSubThrottleTimeout = 0; 53 | static const uint8_t kSubDronecanPriority = 1; 54 | static const uint8_t kSubHobbyPriority = 2; 55 | static const uint8_t kSubIquartPriority = 3; 56 | }; 57 | 58 | #endif /* THROTTLE_SOURCE_MANAGER_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed/white_led.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 Vertiq, Inc support@vertiq.co 3 | 4 | This file is part of the Vertiq C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | #ifndef WHITE_LED_CLIENT_H 10 | #define WHITE_LED_CLIENT_H 11 | 12 | #include "client_communication.hpp" 13 | 14 | const uint8_t kTypeWhiteLed = 101; 15 | 16 | class WhiteLedClient : public ClientAbstract { 17 | public: 18 | WhiteLedClient(uint8_t obj_idn) 19 | : ClientAbstract(kTypeWhiteLed, obj_idn), 20 | intensity_(kTypeWhiteLed, obj_idn, kSubIntensity), 21 | strobe_active_(kTypeWhiteLed, obj_idn, kSubStrobeActive), 22 | strobe_period_(kTypeWhiteLed, obj_idn, kSubStrobePeriod), 23 | strobe_pattern_(kTypeWhiteLed, obj_idn, kSubStrobePattern){}; 24 | 25 | // Client Entries 26 | ClientEntry intensity_; 27 | ClientEntry strobe_active_; 28 | ClientEntry strobe_period_; 29 | ClientEntry strobe_pattern_; 30 | 31 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 32 | static const uint8_t kEntryLength = kSubStrobePattern + 1; 33 | ClientEntryAbstract* entry_array[kEntryLength] = { 34 | &intensity_, // 0 35 | &strobe_active_, // 1 36 | &strobe_period_, // 2 37 | &strobe_pattern_ // 3 38 | }; 39 | 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubIntensity = 0; 45 | static const uint8_t kSubStrobeActive = 1; 46 | static const uint8_t kSubStrobePeriod = 2; 47 | static const uint8_t kSubStrobePattern = 3; 48 | 49 | }; 50 | 51 | #endif // WHITE_LED_CLIENT_H 52 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/adc_interface_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: adc_interface_client.hpp 11 | Last update: 2023/04/18 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef ADC_INTERFACE_CLIENT_HPP_ 17 | #define ADC_INTERFACE_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeAdcInterface = 91; 22 | 23 | class AdcInterfaceClient : public ClientAbstract { 24 | public: 25 | AdcInterfaceClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypeAdcInterface, obj_idn), 27 | adc_voltage_(kTypeAdcInterface, obj_idn, kSubAdcVoltage), 28 | raw_value_(kTypeAdcInterface, obj_idn, kSubRawValue){}; 29 | 30 | // Client Entries 31 | ClientEntry adc_voltage_; 32 | ClientEntry raw_value_; 33 | 34 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 35 | static const uint8_t kEntryLength = kSubRawValue + 1; 36 | ClientEntryAbstract* entry_array[kEntryLength] = { 37 | &adc_voltage_, // 0 38 | &raw_value_ // 1 39 | }; 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubAdcVoltage = 0; 45 | static const uint8_t kSubRawValue = 1; 46 | }; 47 | 48 | #endif /* ADC_INTERFACE_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/anticogging_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: anticogging_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef ANTICOGGING_CLIENT_H 17 | #define ANTICOGGING_CLIENT_H 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeAnticogging = 71; 22 | 23 | class AnticoggingClient: public ClientAbstract{ 24 | public: 25 | AnticoggingClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeAnticogging, obj_idn), 27 | table_size_( kTypeAnticogging, obj_idn, kSubTableSize), 28 | is_data_valid_( kTypeAnticogging, obj_idn, kSubIsDataValid), 29 | is_enabled_( kTypeAnticogging, obj_idn, kSubIsEnabled), 30 | erase_( kTypeAnticogging, obj_idn, kSubErase), 31 | left_shift_( kTypeAnticogging, obj_idn, kSubLeftShift) 32 | {}; 33 | 34 | // Client Entries 35 | ClientEntry table_size_; 36 | ClientEntry is_data_valid_; 37 | ClientEntry is_enabled_; 38 | ClientEntryVoid erase_; 39 | ClientEntry left_shift_; 40 | 41 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 42 | { 43 | static const uint8_t kEntryLength = kSubLeftShift+1; 44 | ClientEntryAbstract* entry_array[kEntryLength] = { 45 | &table_size_, // 0 46 | &is_data_valid_, // 1 47 | &is_enabled_, // 2 48 | &erase_, // 3 49 | &left_shift_ // 4 50 | }; 51 | 52 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 53 | } 54 | 55 | private: 56 | static const uint8_t kSubTableSize = 0; 57 | static const uint8_t kSubIsDataValid = 1; 58 | static const uint8_t kSubIsEnabled = 2; 59 | static const uint8_t kSubErase = 3; 60 | static const uint8_t kSubLeftShift = 4; 61 | }; 62 | 63 | #endif // ANTICOGGING_CLIENT_H 64 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/anticogging_pro_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 Vertiq support@vertiq.co 3 | 4 | This file is part of the Vertiq C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: anticogging_pro_client.hpp 11 | Last update: 2023/07/14 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef ANTICOGGING_PRO_CLIENT_HPP 17 | #define ANTICOGGING_PRO_CLIENT_HPP 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeAnticoggingPro = 79; 22 | 23 | class AnticoggingProClient: public ClientAbstract{ 24 | public: 25 | AnticoggingProClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeAnticoggingPro, obj_idn), 27 | enabled_(kTypeAnticoggingPro, obj_idn, kSubEnabled), 28 | tau_(kTypeAnticoggingPro, obj_idn, kSubTau), 29 | num_harmonics_(kTypeAnticoggingPro, obj_idn, kSubNumHarmonics), 30 | voltage_(kTypeAnticoggingPro, obj_idn, kSubVoltage), 31 | index_(kTypeAnticoggingPro, obj_idn, kSubIndex), 32 | harmonic_(kTypeAnticoggingPro, obj_idn, kSubHarmonic), 33 | a_(kTypeAnticoggingPro, obj_idn, kSubA), 34 | phase_(kTypeAnticoggingPro, obj_idn, kSubPhase), 35 | phase_total_(kTypeAnticoggingPro, obj_idn, kSubPhaseTotal), 36 | amplitude_(kTypeAnticoggingPro, obj_idn, kSubAmplitude), 37 | max_harmonics_(kTypeAnticoggingPro, obj_idn, kSubMaxHarmonics) 38 | {}; 39 | 40 | // Client Entries 41 | ClientEntry enabled_; 42 | ClientEntry tau_; 43 | ClientEntry num_harmonics_; 44 | ClientEntry voltage_; 45 | ClientEntry index_; 46 | ClientEntry harmonic_; 47 | ClientEntry a_; 48 | ClientEntry phase_; 49 | ClientEntry phase_total_; 50 | ClientEntry amplitude_; 51 | ClientEntry max_harmonics_; 52 | 53 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 54 | { 55 | static const uint8_t kEntryLength = kSubMaxHarmonics+1; 56 | ClientEntryAbstract* entry_array[kEntryLength] = { 57 | &enabled_, // 0 58 | &tau_, // 1 59 | &num_harmonics_, // 2 60 | &voltage_, // 3 61 | &index_, // 4 62 | &harmonic_, // 5 63 | &a_, // 6 64 | &phase_, // 7 65 | &phase_total_, // 8 66 | &litude_, // 9 67 | &max_harmonics_ // 10 68 | }; 69 | 70 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 71 | } 72 | 73 | private: 74 | static const uint8_t kSubEnabled = 0; 75 | static const uint8_t kSubTau = 1; 76 | static const uint8_t kSubNumHarmonics = 2; 77 | static const uint8_t kSubVoltage = 3; 78 | static const uint8_t kSubIndex = 4; 79 | static const uint8_t kSubHarmonic = 5; 80 | static const uint8_t kSubA = 6; 81 | static const uint8_t kSubPhase = 7; 82 | static const uint8_t kSubPhaseTotal = 8; 83 | static const uint8_t kSubAmplitude = 9; 84 | static const uint8_t kSubMaxHarmonics = 10; 85 | }; 86 | 87 | #endif // ANTICOGGING_PRO_CLIENT_H 88 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/buzzer_control_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: buzzer_control_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef BUZZER_CONTROL_CLIENT_H 17 | #define BUZZER_CONTROL_CLIENT_H 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeBuzzerControl = 61; 22 | 23 | class BuzzerControlClient: public ClientAbstract{ 24 | public: 25 | BuzzerControlClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeBuzzerControl, obj_idn), 27 | ctrl_mode_( kTypeBuzzerControl, obj_idn, kSubCtrlMode), 28 | ctrl_brake_( kTypeBuzzerControl, obj_idn, kSubCtrlBrake), 29 | ctrl_coast_( kTypeBuzzerControl, obj_idn, kSubCtrlCoast), 30 | ctrl_note_( kTypeBuzzerControl, obj_idn, kSubCtrlNote), 31 | volume_max_( kTypeBuzzerControl, obj_idn, kSubVolumeMax), 32 | hz_( kTypeBuzzerControl, obj_idn, kSubHz), 33 | volume_( kTypeBuzzerControl, obj_idn, kSubVolume), 34 | duration_( kTypeBuzzerControl, obj_idn, kSubDuration) 35 | {}; 36 | 37 | // Client Entries 38 | ClientEntryVoid ctrl_mode_; 39 | ClientEntryVoid ctrl_brake_; 40 | ClientEntryVoid ctrl_coast_; 41 | ClientEntryVoid ctrl_note_; 42 | ClientEntry volume_max_; 43 | ClientEntry hz_; 44 | ClientEntry volume_; 45 | ClientEntry duration_; 46 | 47 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 48 | { 49 | static const uint8_t kEntryLength = kSubDuration+1; 50 | ClientEntryAbstract* entry_array[kEntryLength] = { 51 | &ctrl_mode_, // 0 52 | &ctrl_brake_, // 1 53 | &ctrl_coast_, // 2 54 | &ctrl_note_, // 3 55 | &volume_max_, // 4 56 | &hz_, // 5 57 | &volume_, // 6 58 | &duration_, // 7 59 | }; 60 | 61 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 62 | } 63 | 64 | private: 65 | static const uint8_t kSubCtrlMode = 0; 66 | static const uint8_t kSubCtrlBrake = 1; 67 | static const uint8_t kSubCtrlCoast = 2; 68 | static const uint8_t kSubCtrlNote = 3; 69 | static const uint8_t kSubVolumeMax = 4; 70 | static const uint8_t kSubHz = 5; 71 | static const uint8_t kSubVolume = 6; 72 | static const uint8_t kSubDuration = 7; 73 | }; 74 | 75 | #endif // BUZZER_CONTROL_CLIENT_H 76 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/byte_queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: byte_queue.h 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: James Paulos 13 | Contributors: Matthew Piccoli, Raphael Van Hoffelen 14 | */ 15 | 16 | /* A FIFO buffer for uint8 bytes implemented with a fixed size circular 17 | * buffer. A ByteQueue struct maintains the buffer data and state for one 18 | * buffer instance, and many simultaneous instances are supported. An operation 19 | * on one buffer must not be interrupted by another operation on that same 20 | * buffer (possibly via an interrupt). This restriction is not enforced and no 21 | * error code is generated. 22 | */ 23 | 24 | #ifndef BYTE_QUEUE_H 25 | #define BYTE_QUEUE_H 26 | 27 | #include 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /// ByteQueue instance state struct, voluntarily opaque. 34 | struct ByteQueue { 35 | uint8_t* data; // pointer to array allocated for data 36 | uint8_t *start; // points to first data byte 37 | uint8_t *end; // points to empty byte past last data byte 38 | uint16_t data_size; // size allocated for data 39 | uint16_t count; // current contained element count 40 | }; 41 | 42 | // initialize buffer as empty 43 | // must provide pointer to allocated array for buffer to use 44 | void InitBQ(struct ByteQueue *b, uint8_t* data, uint16_t data_size); 45 | 46 | // return 1 if buffer full, 0 else 47 | int8_t IsFullBQ(struct ByteQueue *b); 48 | 49 | // return 1 if buffer empty, 0 else 50 | int8_t IsEmptyBQ(struct ByteQueue *b); 51 | 52 | // return number elements in buffer 53 | uint16_t CountBQ(struct ByteQueue *p); 54 | 55 | // read and remove next character from buffer 56 | uint8_t GetByteBQ(struct ByteQueue *b); 57 | 58 | // read but don't remove next character from buffer 59 | uint8_t PeekByteBQ(struct ByteQueue *b); 60 | 61 | // add one character to buffer 62 | // return 1 for success, 0 for failure (buffer overflow) 63 | int8_t PutByteBQ(struct ByteQueue *b, uint8_t item); 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif // __cplusplus 68 | 69 | #endif // BYTE_QUEUE_H 70 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/client_communication.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: client_communication.cpp 11 | Last update: 4/12/2019 by Matthew Piccoli 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #include "client_communication.hpp" 17 | 18 | int8_t ParseMsg(uint8_t* rx_data, uint8_t rx_length, 19 | ClientEntryAbstract** entry_array, uint8_t entry_length) 20 | { 21 | uint8_t type_idn = rx_data[0]; 22 | uint8_t sub_idn = rx_data[1]; 23 | uint8_t obj_idn = rx_data[2] >> 2; // high 6 bits are obj_idn 24 | Access dir = static_cast(rx_data[2] & 0b00000011); // low two bits 25 | 26 | // if we have a reply (we only parse replies here) 27 | if(dir == kReply) 28 | { 29 | // if sub_idn is within array range (safe to access array at this location) 30 | if(sub_idn < entry_length) 31 | { 32 | // if there is a ClientEntry object at this sub_idn 33 | if(entry_array[sub_idn] != nullptr) 34 | { 35 | // if the type and obj identifiers match 36 | if(entry_array[sub_idn]->type_idn_ == type_idn && 37 | entry_array[sub_idn]->obj_idn_ == obj_idn) 38 | { 39 | // ... then we have a valid message 40 | entry_array[sub_idn]->Reply(&rx_data[3],rx_length-3); 41 | return 1; // I parsed something 42 | } 43 | } 44 | } 45 | } 46 | return 0; // I didn't parse anything 47 | } 48 | 49 | int8_t ParseMsg(uint8_t* rx_data, uint8_t rx_length, 50 | ClientEntryAbstract& entry) 51 | { 52 | uint8_t type_idn = rx_data[0]; 53 | uint8_t sub_idn = rx_data[1]; 54 | uint8_t obj_idn = rx_data[2] >> 2; // high 6 bits are obj_idn 55 | Access dir = static_cast(rx_data[2] & 0b00000011); // low two bits 56 | 57 | // if we have a reply (we only parse replies here) 58 | if(dir == kReply) 59 | { 60 | // if the type and obj identifiers match 61 | if(entry.type_idn_ == type_idn && 62 | entry.obj_idn_ == obj_idn && entry.sub_idn_ == sub_idn) 63 | { 64 | // ... then we have a valid message 65 | entry.Reply(&rx_data[3],rx_length-3); 66 | return 1; // I parsed something 67 | } 68 | } 69 | return 0; // I didn't parse anything 70 | } -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/crc_helper.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | IQ C++ API is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | IQ C++ API is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | /* 21 | Name: crc_helper.c 22 | Last update: 3/7/2019 by Raphael Van Hoffelen 23 | Author: James Paulos 24 | Contributors: Matthew Piccoli, Raphael Van Hoffelen 25 | */ 26 | 27 | #include "crc_helper.h" 28 | 29 | // Compute CRC word for a byte string. 30 | uint16_t MakeCrc(const uint8_t *data, uint16_t count) { 31 | 32 | uint16_t crc = 0xffff; 33 | 34 | uint16_t i; 35 | for(i = 0; i < count; i++) { 36 | crc = ByteUpdateCrc(crc, data[i]); 37 | } 38 | return crc; 39 | } 40 | 41 | // Update a CRC accumulation with one data byte. 42 | uint16_t ByteUpdateCrc(uint16_t crc, uint8_t data) { 43 | 44 | uint16_t x = (crc >> 8) ^ data; 45 | x ^= x >> 4; 46 | 47 | crc = (crc << 8) ^ (x << 12) ^ (x <<5) ^ x; 48 | return crc; 49 | } 50 | 51 | // Update a CRC accumulation with several data bytes. 52 | uint16_t ArrayUpdateCrc(uint16_t crc, const uint8_t *data, uint16_t count) { 53 | 54 | uint16_t i; 55 | for(i = 0; i < count; i++) { 56 | crc = ByteUpdateCrc(crc, data[i]); 57 | } 58 | return crc; 59 | } 60 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/crc_helper.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: crc_helper.h 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: James Paulos 13 | Contributors: Matthew Piccoli, Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef CRC_HELPER_H 17 | #define CRC_HELPER_H 18 | 19 | #include 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /* Compute CRC word for a byte string. 26 | */ 27 | uint16_t MakeCrc(const uint8_t *data, uint16_t count); 28 | 29 | /* Update a CRC accumulation with one data byte. 30 | */ 31 | uint16_t ByteUpdateCrc(uint16_t crc, uint8_t data); 32 | 33 | /* Update a CRC accumulation with several data bytes. 34 | */ 35 | uint16_t ArrayUpdateCrc(uint16_t crc, const uint8_t *data, uint16_t count); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif // __cplusplus 40 | 41 | #endif -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/drive_control_interface_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2025 Vertiq, Inc support@vertiq.co 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: drive_control_interface_client.hpp 11 | Last update: 2025-03-12 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef DRIVE_CONTROL_INTERFACE_CLIENT_HPP_ 17 | #define DRIVE_CONTROL_INTERFACE_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeDriveControlInterface = 97; 22 | 23 | class DriveControlInterfaceClient : public ClientAbstract { 24 | public: 25 | DriveControlInterfaceClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypeDriveControlInterface, obj_idn), 27 | voltage_target_(kTypeDriveControlInterface, obj_idn, kSubVoltageTarget), 28 | pwm_target_(kTypeDriveControlInterface, obj_idn, kSubPwmTarget), 29 | torque_target_(kTypeDriveControlInterface, obj_idn, kSubTorqueTarget), 30 | q_current_target_(kTypeDriveControlInterface, obj_idn, kSubQCurrentTarget), 31 | d_current_target_(kTypeDriveControlInterface, obj_idn, kSubDCurrentTarget), 32 | coast_(kTypeDriveControlInterface, obj_idn, kSubCoast), 33 | brake_(kTypeDriveControlInterface, obj_idn, kSubBrake), 34 | mode_(kTypeDriveControlInterface, obj_idn, kSubMode) 35 | {}; 36 | 37 | // Client Entries 38 | ClientEntry voltage_target_; 39 | ClientEntry pwm_target_; 40 | ClientEntry torque_target_; 41 | ClientEntry q_current_target_; 42 | ClientEntry d_current_target_; 43 | ClientEntryVoid coast_; 44 | ClientEntryVoid brake_; 45 | ClientEntry mode_; 46 | 47 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 48 | static const uint8_t kEntryLength = kSubMode + 1; 49 | ClientEntryAbstract* entry_array[kEntryLength] = { 50 | &voltage_target_, // 0 51 | &pwm_target_, // 1 52 | &torque_target_, // 2 53 | &q_current_target_, // 3 54 | &d_current_target_, // 4 55 | &coast_, // 5 56 | &brake_, // 6 57 | &mode_ // 7 58 | }; 59 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 60 | } 61 | 62 | private: 63 | static const uint8_t kSubVoltageTarget = 0; 64 | static const uint8_t kSubPwmTarget = 1; 65 | static const uint8_t kSubTorqueTarget = 2; 66 | static const uint8_t kSubQCurrentTarget = 3; 67 | static const uint8_t kSubDCurrentTarget = 4; 68 | static const uint8_t kSubCoast = 5; 69 | static const uint8_t kSubBrake = 6; 70 | static const uint8_t kSubMode = 7; 71 | 72 | }; 73 | 74 | #endif /* DRIVE_CONTROL_INTERFACE_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/hobby_input_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: hobby_input_client.hpp 11 | Last update: 09/16/2022 by Ben Quan 12 | Author: Matthew Piccoli 13 | Contributors: Ben Quan, Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef HOBBY_INPUT_CLIENT_HPP_ 17 | #define HOBBY_INPUT_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeHobbyInput = 76; 22 | 23 | class HobbyInputClient: public ClientAbstract{ 24 | public: 25 | HobbyInputClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeHobbyInput, obj_idn), 27 | allowed_protocols_( kTypeHobbyInput, obj_idn, kSubAllowedProtocols), 28 | protocol_( kTypeHobbyInput, obj_idn, kSubProtocol), 29 | calibrated_protocol_( kTypeHobbyInput, obj_idn, kSubCalibratedProtocol), 30 | calibrated_high_ticks_us_( kTypeHobbyInput, obj_idn, kSubCalibratedHighTicksUs), 31 | calibrated_low_ticks_us_( kTypeHobbyInput, obj_idn, kSubCalibratedLowTicksUs), 32 | reset_calibration_( kTypeHobbyInput, obj_idn, kSubResetCalibration) 33 | {}; 34 | 35 | // Client Entries 36 | // Control commands 37 | ClientEntry allowed_protocols_; 38 | ClientEntry protocol_; 39 | ClientEntry calibrated_protocol_; 40 | ClientEntry calibrated_high_ticks_us_; 41 | ClientEntry calibrated_low_ticks_us_; 42 | ClientEntryVoid reset_calibration_; 43 | 44 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 45 | { 46 | static const uint8_t kEntryLength = kSubResetCalibration+1; 47 | ClientEntryAbstract* entry_array[kEntryLength] = { 48 | &allowed_protocols_, // 0 49 | &protocol_, // 1 50 | &calibrated_protocol_, // 2 51 | &calibrated_high_ticks_us_, // 3 52 | &calibrated_low_ticks_us_, // 4 53 | &reset_calibration_ // 5 54 | }; 55 | 56 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 57 | } 58 | 59 | private: 60 | static const uint8_t kSubAllowedProtocols = 0; 61 | static const uint8_t kSubProtocol = 1; 62 | static const uint8_t kSubCalibratedProtocol = 2; 63 | static const uint8_t kSubCalibratedHighTicksUs = 3; 64 | static const uint8_t kSubCalibratedLowTicksUs = 4; 65 | static const uint8_t kSubResetCalibration = 5; 66 | }; 67 | 68 | #endif /* HOBBY_INPUT_CLIENT_HPP_ */ 69 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/iq_module_communication_local.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2025 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: iq_module_communication.hpp 11 | Last update: 2025/03/12 by Ben Quan 12 | Author: Ben Quan, Matthew Piccoli 13 | */ 14 | 15 | #include "adc_interface_client.hpp" 16 | #include "anticogging_client.hpp" 17 | #include "arming_handler_client.hpp" 18 | #include "brushless_drive_client.hpp" 19 | #include "buzzer_control_client.hpp" 20 | #include "coil_temperature_estimator_client.hpp" 21 | #include "current_safeties_client.hpp" 22 | #include "drive_control_interface_client.hpp" 23 | #include "esc_propeller_input_parser_client.hpp" 24 | #include "gpio_controller_client.hpp" 25 | #include "hobby_input_client.hpp" 26 | #include "iq_serial.hpp" 27 | #include "iquart_flight_controller_interface_client.hpp" 28 | #include "motor_driver_client.hpp" 29 | #include "motor_model_client.hpp" 30 | #include "multi_turn_angle_control_client.hpp" 31 | #include "persistent_memory_client.hpp" 32 | #include "power_monitor_client.hpp" 33 | #include "power_safety_client.hpp" 34 | #include "propeller_motor_control_client.hpp" 35 | #include "pulsing_rectangular_input_parser_client.hpp" 36 | #include "pwm_interface_client.hpp" 37 | #include "rotor_angle_generator_client.hpp" 38 | #include "serial_interface_client.hpp" 39 | #include "servo_input_parser_client.hpp" 40 | #include "step_direction_input_client.hpp" 41 | #include "stopping_handler_client.hpp" 42 | #include "stow_user_interface_client.hpp" 43 | #include "system_control_client.hpp" 44 | #include "temperature_estimator_client.hpp" 45 | #include "temperature_monitor_uc_client.hpp" 46 | #include "uavcan_node_client.hpp" 47 | #include "voltage_superposition_client.hpp" 48 | #include "voltage_target_generator_client.hpp" 49 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/mag_alpha_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 Vertiq support@vertiq.co 3 | 4 | This file is part of the Vertiq C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: mag_alpha_client.hpp 11 | Last update: 2023/07/14 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef MAG_ALPHA_CLIENT_HPP 17 | #define MAG_ALPHA_CLIENT_HPP 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeMagAlpha = 75; 22 | 23 | class MagAlphaClient: public ClientAbstract{ 24 | public: 25 | MagAlphaClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeMagAlpha, obj_idn), 27 | angle_raw_(kTypeMagAlpha, obj_idn, kSubAngleRaw), 28 | angle_rad_(kTypeMagAlpha, obj_idn, kSubAngleRad), 29 | alarm_(kTypeMagAlpha, obj_idn, kSubAlarm), 30 | mght_(kTypeMagAlpha, obj_idn, kSubMght), 31 | mglt_(kTypeMagAlpha, obj_idn, kSubMglt), 32 | reg_val_(kTypeMagAlpha, obj_idn, kSubRegVal), 33 | reg_adr_(kTypeMagAlpha, obj_idn, kSubRegAdr), 34 | reg_str_(kTypeMagAlpha, obj_idn, kSubRegStr) 35 | {}; 36 | 37 | // Client Entries 38 | ClientEntry angle_raw_; 39 | ClientEntry angle_rad_; 40 | ClientEntry alarm_; 41 | ClientEntry mght_; 42 | ClientEntry mglt_; 43 | ClientEntry reg_val_; 44 | ClientEntry reg_adr_; 45 | ClientEntryVoid reg_str_; 46 | 47 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 48 | { 49 | static const uint8_t kEntryLength = kSubRegStr+1; 50 | ClientEntryAbstract* entry_array[kEntryLength] = { 51 | &angle_raw_, // 0 52 | &angle_rad_, // 1 53 | &alarm_, // 2 54 | &mght_, // 3 55 | &mglt_, // 4 56 | ®_val_, // 5 57 | ®_adr_, // 6 58 | ®_str_ // 7 59 | }; 60 | 61 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 62 | } 63 | 64 | private: 65 | static const uint8_t kSubAngleRaw = 0; 66 | static const uint8_t kSubAngleRad = 1; 67 | static const uint8_t kSubAlarm = 2; 68 | static const uint8_t kSubMght = 3; 69 | static const uint8_t kSubMglt = 4; 70 | static const uint8_t kSubRegVal = 5; 71 | static const uint8_t kSubRegAdr = 6; 72 | static const uint8_t kSubRegStr = 7; 73 | }; 74 | 75 | #endif // MAG_ALPHA_CLIENT_H -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/persistent_memory_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: persistent_memory_client.hpp 11 | Last update: 10/31/2022 by Ben Quan 12 | Author: Matthew Piccoli 13 | Contributors: Ben Quan, Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef PERSISTENT_MEMORY_CLIENT_HPP_ 17 | #define PERSISTENT_MEMORY_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypePersistentMemory = 11; 22 | 23 | class PersistentMemoryClient: public ClientAbstract{ 24 | public: 25 | PersistentMemoryClient(uint8_t obj_idn): 26 | ClientAbstract( kTypePersistentMemory, obj_idn), 27 | erase_( kTypePersistentMemory, obj_idn, kSubErase), 28 | revert_to_default_( kTypePersistentMemory, obj_idn, kSubRevertToDefault), 29 | format_key_1_( kTypePersistentMemory, obj_idn, kSubFormatKey1), 30 | format_key_2_( kTypePersistentMemory, obj_idn, kSubFormatKey2) 31 | {}; 32 | 33 | // Client Entries 34 | // Control commands 35 | ClientEntryVoid erase_; 36 | ClientEntryVoid revert_to_default_; 37 | ClientEntry format_key_1_; 38 | ClientEntry format_key_2_; 39 | 40 | 41 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 42 | { 43 | static const uint8_t kEntryLength = kSubFormatKey2+1; 44 | ClientEntryAbstract* entry_array[kEntryLength] = { 45 | &erase_, // 0 46 | &revert_to_default_, // 1 47 | &format_key_1_, // 2 48 | &format_key_2_ // 3 49 | }; 50 | 51 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 52 | } 53 | 54 | private: 55 | static const uint8_t kSubErase = 0; 56 | static const uint8_t kSubRevertToDefault = 1; 57 | static const uint8_t kSubFormatKey1 = 2; 58 | static const uint8_t kSubFormatKey2 = 3; 59 | }; 60 | 61 | #endif /* PERSISTENT_MEMORY_CLIENT_HPP_ */ 62 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/pulsing_rectangular_input_parser_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: pulsing_rectangular_input_parser_client.hpp 11 | Last update: 2024/08/26 by Fred Kummer 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef PULSING_RECTANGULAR_INPUT_PARSER_CLIENT_HPP_ 17 | #define PULSING_RECTANGULAR_INPUT_PARSER_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypePulsingRectangularInputParser = 89; 22 | 23 | class PulsingRectangularInputParserClient : public ClientAbstract { 24 | public: 25 | PulsingRectangularInputParserClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypePulsingRectangularInputParser, obj_idn), 27 | pulsing_scaling_mode_(kTypePulsingRectangularInputParser, obj_idn, kSubPulsingScalingMode), 28 | pulsing_scaling_limit_(kTypePulsingRectangularInputParser, obj_idn, kSubPulsingScalingLimit){}; 29 | 30 | // Client Entries 31 | ClientEntry pulsing_scaling_mode_; 32 | ClientEntry pulsing_scaling_limit_; 33 | 34 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 35 | static const uint8_t kEntryLength = kSubPulsingScalingLimit + 1; 36 | ClientEntryAbstract* entry_array[kEntryLength] = { 37 | &pulsing_scaling_mode_, // 0 38 | &pulsing_scaling_limit_ // 1 39 | }; 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubPulsingScalingMode = 0; 45 | static const uint8_t kSubPulsingScalingLimit = 1; 46 | }; 47 | 48 | #endif /* PULSING_RECTANGULAR_INPUT_PARSER_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/pwm_interface_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: pwm_interface_client.hpp 11 | Last update: 2023/04/18 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef PWM_INTERFACE_CLIENT_HPP_ 17 | #define PWM_INTERFACE_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypePwmInterface = 92; 22 | 23 | class PwmInterfaceClient : public ClientAbstract { 24 | public: 25 | PwmInterfaceClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypePwmInterface, obj_idn), 27 | pwm_frequency_(kTypePwmInterface, obj_idn, kSubPwmFrequency), 28 | duty_cycle_(kTypePwmInterface, obj_idn, kSubDutyCycle), 29 | pwm_mode_(kTypePwmInterface, obj_idn, kSubPwmMode){}; 30 | 31 | // Client Entries 32 | ClientEntry pwm_frequency_; 33 | ClientEntry duty_cycle_; 34 | ClientEntry pwm_mode_; 35 | 36 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 37 | static const uint8_t kEntryLength = kSubPwmMode + 1; 38 | ClientEntryAbstract* entry_array[kEntryLength] = { 39 | &pwm_frequency_, // 0 40 | &duty_cycle_, // 1 41 | &pwm_mode_ // 2 42 | }; 43 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 44 | } 45 | 46 | private: 47 | static const uint8_t kSubPwmFrequency = 0; 48 | static const uint8_t kSubDutyCycle = 1; 49 | static const uint8_t kSubPwmMode = 2; 50 | }; 51 | 52 | #endif /* PWM_INTERFACE_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/rgb_led.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 Vertiq, Inc support@vertiq.co 3 | 4 | This file is part of the Vertiq C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | #ifndef RGB_LED_CLIENT_H 10 | #define RGB_LED_CLIENT_H 11 | 12 | #include "client_communication.hpp" 13 | 14 | const uint8_t kTypeRgbLed = 100; 15 | 16 | class RgbLedClient : public ClientAbstract { 17 | public: 18 | RgbLedClient(uint8_t obj_idn) 19 | : ClientAbstract(kTypeRgbLed, obj_idn), 20 | red_(kTypeRgbLed, obj_idn, kSubRed), 21 | green_(kTypeRgbLed, obj_idn, kSubGreen), 22 | blue_(kTypeRgbLed, obj_idn, kSubBlue), 23 | update_color_(kTypeRgbLed, obj_idn, kSubUpdateColor), 24 | strobe_active_(kTypeRgbLed, obj_idn, kSubStrobeActive), 25 | strobe_period_(kTypeRgbLed, obj_idn, kSubStrobePeriod), 26 | strobe_pattern_(kTypeRgbLed, obj_idn, kSubStrobePattern){}; 27 | 28 | // Client Entries 29 | ClientEntry red_; 30 | ClientEntry green_; 31 | ClientEntry blue_; 32 | ClientEntryVoid update_color_; 33 | ClientEntry strobe_active_; 34 | ClientEntry strobe_period_; 35 | ClientEntry strobe_pattern_; 36 | 37 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 38 | static const uint8_t kEntryLength = kSubStrobePattern + 1; 39 | ClientEntryAbstract* entry_array[kEntryLength] = { 40 | &red_, // 0 41 | &green_, // 1 42 | &blue_, // 2 43 | &update_color_, // 3 44 | &strobe_active_, // 4 45 | &strobe_period_, // 5 46 | &strobe_pattern_ // 6 47 | }; 48 | 49 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 50 | } 51 | 52 | private: 53 | static const uint8_t kSubRed = 0; 54 | static const uint8_t kSubGreen = 1; 55 | static const uint8_t kSubBlue = 2; 56 | static const uint8_t kSubUpdateColor = 3; 57 | static const uint8_t kSubStrobeActive = 4; 58 | static const uint8_t kSubStrobePeriod = 5; 59 | static const uint8_t kSubStrobePattern = 6; 60 | 61 | }; 62 | 63 | #endif // RGB_LED_CLIENT_H 64 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/rotor_angle_generator_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2025 Vertiq, Inc support@vertiq.co 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: rotor_angle_generator_client.hpp 11 | Last update: 2025-03-11 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef ROTOR_ANGLE_GENERATOR_CLIENT_HPP_ 17 | #define ROTOR_ANGLE_GENERATOR_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeRotorAngleGenerator = 95; 22 | 23 | class RotorAngleGeneratorClient : public ClientAbstract { 24 | public: 25 | RotorAngleGeneratorClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypeRotorAngleGenerator, obj_idn), 27 | rotor_angle_(kTypeRotorAngleGenerator, obj_idn, kSubRotorAngle), 28 | manual_angle_(kTypeRotorAngleGenerator, obj_idn, kSubManualAngle), 29 | use_manual_angle_(kTypeRotorAngleGenerator, obj_idn, kSubUseManualAngle) 30 | {}; 31 | 32 | // Client Entries 33 | ClientEntry rotor_angle_; 34 | ClientEntry manual_angle_; 35 | ClientEntry use_manual_angle_; 36 | 37 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 38 | static const uint8_t kEntryLength = kSubUseManualAngle + 1; 39 | ClientEntryAbstract* entry_array[kEntryLength] = { 40 | &rotor_angle_, // 0 41 | &manual_angle_, // 1 42 | &use_manual_angle_, // 2 43 | }; 44 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 45 | } 46 | 47 | private: 48 | static const uint8_t kSubRotorAngle = 0; 49 | static const uint8_t kSubManualAngle = 1; 50 | static const uint8_t kSubUseManualAngle = 2; 51 | 52 | }; 53 | 54 | #endif /* ROTOR_ANGLE_GENERATOR_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/serial_interface_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: serial_interface_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef SERIAL_INTERFACE_CLIENT_H 17 | #define SERIAL_INTERFACE_CLIENT_H 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeSerialInterface = 16; 22 | 23 | class SerialInterfaceClient: public ClientAbstract{ 24 | public: 25 | SerialInterfaceClient(uint8_t obj_idn): 26 | ClientAbstract(kTypeSerialInterface, obj_idn), 27 | baud_rate_( kTypeSerialInterface, obj_idn, kSubBaudRate) 28 | {}; 29 | 30 | // Client Entries 31 | ClientEntry baud_rate_; 32 | 33 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 34 | { 35 | static const uint8_t kEntryLength = kSubBaudRate+1; 36 | ClientEntryAbstract* entry_array[kEntryLength] = { 37 | &baud_rate_, // 0 38 | }; 39 | 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubBaudRate = 0; 45 | }; 46 | 47 | #endif // SERIAL_INTERFACE_CLIENT_H 48 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/servo_input_parser_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: servo_input_parser_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef SERVO_INPUT_PARSER_CLIENT_HPP_ 17 | #define SERVO_INPUT_PARSER_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeServoInputParser = 78; 22 | 23 | class ServoInputParserClient: public ClientAbstract{ 24 | public: 25 | ServoInputParserClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeServoInputParser, obj_idn), 27 | mode_( kTypeServoInputParser, obj_idn, kSubMode), 28 | unit_min_( kTypeServoInputParser, obj_idn, kSubUnitMin), 29 | unit_max_( kTypeServoInputParser, obj_idn, kSubUnitMax) 30 | {}; 31 | 32 | // Client Entries 33 | // Control commands 34 | ClientEntry mode_; 35 | ClientEntry unit_min_; 36 | ClientEntry unit_max_; 37 | 38 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 39 | { 40 | static const uint8_t kEntryLength = kSubUnitMax+1; 41 | ClientEntryAbstract* entry_array[kEntryLength] = { 42 | &mode_, // 0 43 | &unit_min_, // 1 44 | &unit_max_ // 2 45 | }; 46 | 47 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 48 | } 49 | 50 | private: 51 | static const uint8_t kSubMode = 0; 52 | static const uint8_t kSubUnitMin = 1; 53 | static const uint8_t kSubUnitMax = 2; 54 | }; 55 | 56 | #endif /* SERVO_INPUT_PARSER_CLIENT_HPP_ */ 57 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/step_direction_input_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: step_direction_input_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef STEP_DIRECTION_INPUT_CLIENT_HPP_ 17 | #define STEP_DIRECTION_INPUT_CLIENT_HPP_ 18 | 19 | 20 | #include "client_communication.hpp" 21 | 22 | const uint8_t kTypeStepDirInput = 58; 23 | 24 | class StepDirectionInputClient: public ClientAbstract{ 25 | public: 26 | StepDirectionInputClient(uint8_t obj_idn): 27 | ClientAbstract( kTypeStepDirInput, obj_idn), 28 | angle_( kTypeStepDirInput, obj_idn, kSubAngle), 29 | angle_step_( kTypeStepDirInput, obj_idn, kSubAngleStep) 30 | {}; 31 | 32 | // Client Entries 33 | ClientEntry angle_; 34 | ClientEntry angle_step_; 35 | 36 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 37 | { 38 | static const uint8_t kEntryLength = kSubAngleStep+1; 39 | ClientEntryAbstract* entry_array[kEntryLength] = { 40 | &angle_, // 0 41 | &angle_step_ // 1 42 | }; 43 | 44 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 45 | } 46 | 47 | private: 48 | static const uint8_t kSubAngle = 0; 49 | static const uint8_t kSubAngleStep = 1; 50 | }; 51 | 52 | #endif /* STEP_DIRECTION_INPUT_CLIENT_HPP_ */ 53 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/stopping_handler_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: stopping_handler_client.hpp 11 | Last update: 2023/04/12 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef STOPPING_HANDLER_CLIENT_HPP_ 17 | #define STOPPING_HANDLER_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeStoppingHandler = 87; 22 | 23 | class StoppingHandlerClient : public ClientAbstract { 24 | public: 25 | StoppingHandlerClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypeStoppingHandler, obj_idn), 27 | stopped_speed_(kTypeStoppingHandler, obj_idn, kSubStoppedSpeed), 28 | stopped_time_(kTypeStoppingHandler, obj_idn, kSubStoppedTime){}; 29 | 30 | // Client Entries 31 | ClientEntry stopped_speed_; 32 | ClientEntry stopped_time_; 33 | 34 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 35 | static const uint8_t kEntryLength = kSubStoppedTime + 1; 36 | ClientEntryAbstract* entry_array[kEntryLength] = { 37 | &stopped_speed_, // 0 38 | &stopped_time_ // 1 39 | }; 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubStoppedSpeed = 0; 45 | static const uint8_t kSubStoppedTime = 1; 46 | }; 47 | 48 | #endif /* STOPPING_HANDLER_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/temperature_estimator_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: temperature_estimator_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | 17 | #ifndef TEMPERATURE_ESTIMATOR_CLIENT_HPP_ 18 | #define TEMPERATURE_ESTIMATOR_CLIENT_HPP_ 19 | 20 | #include "client_communication.hpp" 21 | 22 | const uint8_t kTypeTemperatureEstimatorClient = 77; 23 | 24 | class TemperatureEstimatorClient: public ClientAbstract{ 25 | public: 26 | TemperatureEstimatorClient(uint8_t obj_idn): 27 | ClientAbstract( kTypeTemperatureEstimatorClient, obj_idn), 28 | temp_( kTypeTemperatureEstimatorClient, obj_idn, kSubTemp), 29 | otw_( kTypeTemperatureEstimatorClient, obj_idn, kSubOtw), 30 | otlo_( kTypeTemperatureEstimatorClient, obj_idn, kSubOtlo), 31 | thermal_resistance_( kTypeTemperatureEstimatorClient, obj_idn, kSubThermalResistance), 32 | thermal_capacitance_( kTypeTemperatureEstimatorClient, obj_idn, kSubThermalCapacitance), 33 | derate_( kTypeTemperatureEstimatorClient, obj_idn, kSubDerate) 34 | {}; 35 | 36 | // Client Entries 37 | // Control commands 38 | ClientEntry temp_; 39 | ClientEntry otw_; 40 | ClientEntry otlo_; 41 | ClientEntry thermal_resistance_; 42 | ClientEntry thermal_capacitance_; 43 | ClientEntry derate_; 44 | 45 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 46 | { 47 | static const uint8_t kEntryLength = kSubDerate+1; 48 | ClientEntryAbstract* entry_array[kEntryLength] = { 49 | &temp_, // 0 50 | &otw_, // 1 51 | &otlo_, // 2 52 | &thermal_resistance_, // 3 53 | &thermal_capacitance_,// 4 54 | &derate_ // 5 55 | }; 56 | 57 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 58 | } 59 | 60 | private: 61 | static const uint8_t kSubTemp = 0; 62 | static const uint8_t kSubOtw = 1; 63 | static const uint8_t kSubOtlo = 2; 64 | static const uint8_t kSubThermalResistance = 3; 65 | static const uint8_t kSubThermalCapacitance = 4; 66 | static const uint8_t kSubDerate = 5; 67 | }; 68 | 69 | #endif /* TEMPERATURE_ESTIMATOR_CLIENT_HPP_ */ 70 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/temperature_monitor_uc_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: temperature_monitor_uc_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef TEMPERATURE_MONITOR_UC_CLIENT_HPP_ 17 | #define TEMPERATURE_MONITOR_UC_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeTemperatureMonitorUcClient = 73; 22 | 23 | class TemperatureMonitorUcClient: public ClientAbstract{ 24 | public: 25 | TemperatureMonitorUcClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeTemperatureMonitorUcClient, obj_idn), 27 | uc_temp_( kTypeTemperatureMonitorUcClient, obj_idn, kSubUcTemp), 28 | filter_fs_( kTypeTemperatureMonitorUcClient, obj_idn, kSubFilterFs), 29 | filter_fc_( kTypeTemperatureMonitorUcClient, obj_idn, kSubFilterFc), 30 | otw_( kTypeTemperatureMonitorUcClient, obj_idn, kSubOtw), 31 | otlo_( kTypeTemperatureMonitorUcClient, obj_idn, kSubOtlo), 32 | derate_( kTypeTemperatureMonitorUcClient, obj_idn, kSubDerate) 33 | {}; 34 | 35 | // Client Entries 36 | // Control commands 37 | ClientEntry uc_temp_; 38 | ClientEntry filter_fs_; 39 | ClientEntry filter_fc_; 40 | ClientEntry otw_; 41 | ClientEntry otlo_; 42 | ClientEntry derate_; 43 | 44 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 45 | { 46 | static const uint8_t kEntryLength = kSubDerate+1; 47 | ClientEntryAbstract* entry_array[kEntryLength] = { 48 | &uc_temp_, // 0 49 | &filter_fs_, // 1 50 | &filter_fc_, // 2 51 | &otw_, // 3 52 | &otlo_, // 4 53 | &derate_ // 5 54 | }; 55 | 56 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 57 | } 58 | 59 | private: 60 | static const uint8_t kSubUcTemp = 0; 61 | static const uint8_t kSubFilterFs = 1; 62 | static const uint8_t kSubFilterFc = 2; 63 | static const uint8_t kSubOtw = 3; 64 | static const uint8_t kSubOtlo = 4; 65 | static const uint8_t kSubDerate = 5; 66 | }; 67 | 68 | #endif /* TEMPERATURE_MONITOR_UC_CLIENT_HPP_ */ 69 | -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/throttle_source_manager_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 Vertiq, Inc support@vertiq.co 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: throttle_source_manager_client.hpp 11 | Last update: 2024/01/30 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef THROTTLE_SOURCE_MANAGER_CLIENT_HPP_ 17 | #define THROTTLE_SOURCE_MANAGER_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeThrottleSourceManager = 104; 22 | 23 | class ThrottleSourceManagerClient : public ClientAbstract { 24 | public: 25 | ThrottleSourceManagerClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypeThrottleSourceManager, obj_idn), 27 | throttle_timeout_(kTypeThrottleSourceManager, obj_idn, kSubThrottleTimeout), 28 | dronecan_priority_(kTypeThrottleSourceManager, obj_idn, kSubDronecanPriority), 29 | hobby_priority_(kTypeThrottleSourceManager, obj_idn, kSubHobbyPriority), 30 | iquart_priority_(kTypeThrottleSourceManager, obj_idn, kSubIquartPriority) 31 | {}; 32 | 33 | // Client Entries 34 | ClientEntry throttle_timeout_; 35 | ClientEntry dronecan_priority_; 36 | ClientEntry hobby_priority_; 37 | ClientEntry iquart_priority_; 38 | 39 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 40 | static const uint8_t kEntryLength = kSubIquartPriority + 1; 41 | ClientEntryAbstract* entry_array[kEntryLength] = { 42 | &throttle_timeout_, // 0 43 | &dronecan_priority_, // 1 44 | &hobby_priority_, // 2 45 | &iquart_priority_, // 3 46 | }; 47 | 48 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 49 | } 50 | 51 | private: 52 | static const uint8_t kSubThrottleTimeout = 0; 53 | static const uint8_t kSubDronecanPriority = 1; 54 | static const uint8_t kSubHobbyPriority = 2; 55 | static const uint8_t kSubIquartPriority = 3; 56 | }; 57 | 58 | #endif /* THROTTLE_SOURCE_MANAGER_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/voltage_target_generator_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2025 Vertiq, Inc support@vertiq.co 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: voltage_target_generator_client.hpp 11 | Last update: 2025-03-11 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef VOLTAGE_TARGET_GENERATOR_CLIENT_HPP_ 17 | #define VOLTAGE_TARGET_GENERATOR_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeVoltageTargetGenerator = 94; 22 | 23 | class VoltageTargetGeneratorClient : public ClientAbstract { 24 | public: 25 | VoltageTargetGeneratorClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypeVoltageTargetGenerator, obj_idn), 27 | q_current_(kTypeVoltageTargetGenerator, obj_idn, kSubQCurrent), 28 | d_current_(kTypeVoltageTargetGenerator, obj_idn, kSubDCurrent), 29 | q_voltage_(kTypeVoltageTargetGenerator, obj_idn, kSubQVoltage), 30 | d_voltage_(kTypeVoltageTargetGenerator, obj_idn, kSubDVoltage) 31 | {}; 32 | 33 | // Client Entries 34 | ClientEntry q_current_; 35 | ClientEntry d_current_; 36 | ClientEntry q_voltage_; 37 | ClientEntry d_voltage_; 38 | 39 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 40 | static const uint8_t kEntryLength = kSubDVoltage + 1; 41 | ClientEntryAbstract* entry_array[kEntryLength] = { 42 | &q_current_, // 0 43 | &d_current_, // 1 44 | &q_voltage_, // 2 45 | &d_voltage_, // 3 46 | }; 47 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 48 | } 49 | 50 | private: 51 | static const uint8_t kSubQCurrent = 0; 52 | static const uint8_t kSubDCurrent = 1; 53 | static const uint8_t kSubQVoltage = 2; 54 | static const uint8_t kSubDVoltage = 3; 55 | 56 | }; 57 | 58 | #endif /* VOLTAGE_TARGET_GENERATOR_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /examples/tests/test_api_8108_speed_hyperdrive/white_led.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 Vertiq, Inc support@vertiq.co 3 | 4 | This file is part of the Vertiq C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | #ifndef WHITE_LED_CLIENT_H 10 | #define WHITE_LED_CLIENT_H 11 | 12 | #include "client_communication.hpp" 13 | 14 | const uint8_t kTypeWhiteLed = 101; 15 | 16 | class WhiteLedClient : public ClientAbstract { 17 | public: 18 | WhiteLedClient(uint8_t obj_idn) 19 | : ClientAbstract(kTypeWhiteLed, obj_idn), 20 | intensity_(kTypeWhiteLed, obj_idn, kSubIntensity), 21 | strobe_active_(kTypeWhiteLed, obj_idn, kSubStrobeActive), 22 | strobe_period_(kTypeWhiteLed, obj_idn, kSubStrobePeriod), 23 | strobe_pattern_(kTypeWhiteLed, obj_idn, kSubStrobePattern){}; 24 | 25 | // Client Entries 26 | ClientEntry intensity_; 27 | ClientEntry strobe_active_; 28 | ClientEntry strobe_period_; 29 | ClientEntry strobe_pattern_; 30 | 31 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 32 | static const uint8_t kEntryLength = kSubStrobePattern + 1; 33 | ClientEntryAbstract* entry_array[kEntryLength] = { 34 | &intensity_, // 0 35 | &strobe_active_, // 1 36 | &strobe_period_, // 2 37 | &strobe_pattern_ // 3 38 | }; 39 | 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubIntensity = 0; 45 | static const uint8_t kSubStrobeActive = 1; 46 | static const uint8_t kSubStrobePeriod = 2; 47 | static const uint8_t kSubStrobePattern = 3; 48 | 49 | }; 50 | 51 | #endif // WHITE_LED_CLIENT_H 52 | -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | # Syntax Coloring Map For IQ motion control arduino API 2 | 3 | # Datatypes (KEYWORD1) 4 | IqSerial KEYWORD1 5 | 6 | # Methods and Functions (KEYWORD2) 7 | begin KEYWORD2 8 | set KEYWORD2 9 | get KEYWORD2 10 | save KEYWORD2 11 | 12 | # Instances (KEYWORD2) 13 | 14 | # Constants (LITERAL1) 15 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=IQ Module Communication 2 | version=1.7.0 3 | author=Matthew Piccoli , Raphael Van Hoffelen 4 | maintainer=Matthew Piccoli , Ben Quan 5 | sentence=A library for communicating with and controlling IQ motor modules. 6 | paragraph=This uses a Serial port to control the motor modules and get/set/save values to on the module. 7 | category=Device Control 8 | url=https://github.com/iq-motion-control/iq-module-communication-arduino 9 | architectures=* 10 | includes=iq_module_communication.hpp 11 | -------------------------------------------------------------------------------- /src/adc_interface_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: adc_interface_client.hpp 11 | Last update: 2023/04/18 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef ADC_INTERFACE_CLIENT_HPP_ 17 | #define ADC_INTERFACE_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeAdcInterface = 91; 22 | 23 | class AdcInterfaceClient : public ClientAbstract { 24 | public: 25 | AdcInterfaceClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypeAdcInterface, obj_idn), 27 | adc_voltage_(kTypeAdcInterface, obj_idn, kSubAdcVoltage), 28 | raw_value_(kTypeAdcInterface, obj_idn, kSubRawValue){}; 29 | 30 | // Client Entries 31 | ClientEntry adc_voltage_; 32 | ClientEntry raw_value_; 33 | 34 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 35 | static const uint8_t kEntryLength = kSubRawValue + 1; 36 | ClientEntryAbstract* entry_array[kEntryLength] = { 37 | &adc_voltage_, // 0 38 | &raw_value_ // 1 39 | }; 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubAdcVoltage = 0; 45 | static const uint8_t kSubRawValue = 1; 46 | }; 47 | 48 | #endif /* ADC_INTERFACE_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /src/anticogging_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: anticogging_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef ANTICOGGING_CLIENT_H 17 | #define ANTICOGGING_CLIENT_H 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeAnticogging = 71; 22 | 23 | class AnticoggingClient: public ClientAbstract{ 24 | public: 25 | AnticoggingClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeAnticogging, obj_idn), 27 | table_size_( kTypeAnticogging, obj_idn, kSubTableSize), 28 | is_data_valid_( kTypeAnticogging, obj_idn, kSubIsDataValid), 29 | is_enabled_( kTypeAnticogging, obj_idn, kSubIsEnabled), 30 | erase_( kTypeAnticogging, obj_idn, kSubErase), 31 | left_shift_( kTypeAnticogging, obj_idn, kSubLeftShift) 32 | {}; 33 | 34 | // Client Entries 35 | ClientEntry table_size_; 36 | ClientEntry is_data_valid_; 37 | ClientEntry is_enabled_; 38 | ClientEntryVoid erase_; 39 | ClientEntry left_shift_; 40 | 41 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 42 | { 43 | static const uint8_t kEntryLength = kSubLeftShift+1; 44 | ClientEntryAbstract* entry_array[kEntryLength] = { 45 | &table_size_, // 0 46 | &is_data_valid_, // 1 47 | &is_enabled_, // 2 48 | &erase_, // 3 49 | &left_shift_ // 4 50 | }; 51 | 52 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 53 | } 54 | 55 | private: 56 | static const uint8_t kSubTableSize = 0; 57 | static const uint8_t kSubIsDataValid = 1; 58 | static const uint8_t kSubIsEnabled = 2; 59 | static const uint8_t kSubErase = 3; 60 | static const uint8_t kSubLeftShift = 4; 61 | }; 62 | 63 | #endif // ANTICOGGING_CLIENT_H 64 | -------------------------------------------------------------------------------- /src/anticogging_pro_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 Vertiq support@vertiq.co 3 | 4 | This file is part of the Vertiq C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: anticogging_pro_client.hpp 11 | Last update: 2023/07/14 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef ANTICOGGING_PRO_CLIENT_HPP 17 | #define ANTICOGGING_PRO_CLIENT_HPP 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeAnticoggingPro = 79; 22 | 23 | class AnticoggingProClient: public ClientAbstract{ 24 | public: 25 | AnticoggingProClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeAnticoggingPro, obj_idn), 27 | enabled_(kTypeAnticoggingPro, obj_idn, kSubEnabled), 28 | tau_(kTypeAnticoggingPro, obj_idn, kSubTau), 29 | num_harmonics_(kTypeAnticoggingPro, obj_idn, kSubNumHarmonics), 30 | voltage_(kTypeAnticoggingPro, obj_idn, kSubVoltage), 31 | index_(kTypeAnticoggingPro, obj_idn, kSubIndex), 32 | harmonic_(kTypeAnticoggingPro, obj_idn, kSubHarmonic), 33 | a_(kTypeAnticoggingPro, obj_idn, kSubA), 34 | phase_(kTypeAnticoggingPro, obj_idn, kSubPhase), 35 | phase_total_(kTypeAnticoggingPro, obj_idn, kSubPhaseTotal), 36 | amplitude_(kTypeAnticoggingPro, obj_idn, kSubAmplitude), 37 | max_harmonics_(kTypeAnticoggingPro, obj_idn, kSubMaxHarmonics) 38 | {}; 39 | 40 | // Client Entries 41 | ClientEntry enabled_; 42 | ClientEntry tau_; 43 | ClientEntry num_harmonics_; 44 | ClientEntry voltage_; 45 | ClientEntry index_; 46 | ClientEntry harmonic_; 47 | ClientEntry a_; 48 | ClientEntry phase_; 49 | ClientEntry phase_total_; 50 | ClientEntry amplitude_; 51 | ClientEntry max_harmonics_; 52 | 53 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 54 | { 55 | static const uint8_t kEntryLength = kSubMaxHarmonics+1; 56 | ClientEntryAbstract* entry_array[kEntryLength] = { 57 | &enabled_, // 0 58 | &tau_, // 1 59 | &num_harmonics_, // 2 60 | &voltage_, // 3 61 | &index_, // 4 62 | &harmonic_, // 5 63 | &a_, // 6 64 | &phase_, // 7 65 | &phase_total_, // 8 66 | &litude_, // 9 67 | &max_harmonics_ // 10 68 | }; 69 | 70 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 71 | } 72 | 73 | private: 74 | static const uint8_t kSubEnabled = 0; 75 | static const uint8_t kSubTau = 1; 76 | static const uint8_t kSubNumHarmonics = 2; 77 | static const uint8_t kSubVoltage = 3; 78 | static const uint8_t kSubIndex = 4; 79 | static const uint8_t kSubHarmonic = 5; 80 | static const uint8_t kSubA = 6; 81 | static const uint8_t kSubPhase = 7; 82 | static const uint8_t kSubPhaseTotal = 8; 83 | static const uint8_t kSubAmplitude = 9; 84 | static const uint8_t kSubMaxHarmonics = 10; 85 | }; 86 | 87 | #endif // ANTICOGGING_PRO_CLIENT_H 88 | -------------------------------------------------------------------------------- /src/buzzer_control_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: buzzer_control_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef BUZZER_CONTROL_CLIENT_H 17 | #define BUZZER_CONTROL_CLIENT_H 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeBuzzerControl = 61; 22 | 23 | class BuzzerControlClient: public ClientAbstract{ 24 | public: 25 | BuzzerControlClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeBuzzerControl, obj_idn), 27 | ctrl_mode_( kTypeBuzzerControl, obj_idn, kSubCtrlMode), 28 | ctrl_brake_( kTypeBuzzerControl, obj_idn, kSubCtrlBrake), 29 | ctrl_coast_( kTypeBuzzerControl, obj_idn, kSubCtrlCoast), 30 | ctrl_note_( kTypeBuzzerControl, obj_idn, kSubCtrlNote), 31 | volume_max_( kTypeBuzzerControl, obj_idn, kSubVolumeMax), 32 | hz_( kTypeBuzzerControl, obj_idn, kSubHz), 33 | volume_( kTypeBuzzerControl, obj_idn, kSubVolume), 34 | duration_( kTypeBuzzerControl, obj_idn, kSubDuration) 35 | {}; 36 | 37 | // Client Entries 38 | ClientEntryVoid ctrl_mode_; 39 | ClientEntryVoid ctrl_brake_; 40 | ClientEntryVoid ctrl_coast_; 41 | ClientEntryVoid ctrl_note_; 42 | ClientEntry volume_max_; 43 | ClientEntry hz_; 44 | ClientEntry volume_; 45 | ClientEntry duration_; 46 | 47 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 48 | { 49 | static const uint8_t kEntryLength = kSubDuration+1; 50 | ClientEntryAbstract* entry_array[kEntryLength] = { 51 | &ctrl_mode_, // 0 52 | &ctrl_brake_, // 1 53 | &ctrl_coast_, // 2 54 | &ctrl_note_, // 3 55 | &volume_max_, // 4 56 | &hz_, // 5 57 | &volume_, // 6 58 | &duration_, // 7 59 | }; 60 | 61 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 62 | } 63 | 64 | private: 65 | static const uint8_t kSubCtrlMode = 0; 66 | static const uint8_t kSubCtrlBrake = 1; 67 | static const uint8_t kSubCtrlCoast = 2; 68 | static const uint8_t kSubCtrlNote = 3; 69 | static const uint8_t kSubVolumeMax = 4; 70 | static const uint8_t kSubHz = 5; 71 | static const uint8_t kSubVolume = 6; 72 | static const uint8_t kSubDuration = 7; 73 | }; 74 | 75 | #endif // BUZZER_CONTROL_CLIENT_H 76 | -------------------------------------------------------------------------------- /src/byte_queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: byte_queue.h 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: James Paulos 13 | Contributors: Matthew Piccoli, Raphael Van Hoffelen 14 | */ 15 | 16 | /* A FIFO buffer for uint8 bytes implemented with a fixed size circular 17 | * buffer. A ByteQueue struct maintains the buffer data and state for one 18 | * buffer instance, and many simultaneous instances are supported. An operation 19 | * on one buffer must not be interrupted by another operation on that same 20 | * buffer (possibly via an interrupt). This restriction is not enforced and no 21 | * error code is generated. 22 | */ 23 | 24 | #ifndef BYTE_QUEUE_H 25 | #define BYTE_QUEUE_H 26 | 27 | #include 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /// ByteQueue instance state struct, voluntarily opaque. 34 | struct ByteQueue { 35 | uint8_t* data; // pointer to array allocated for data 36 | uint8_t *start; // points to first data byte 37 | uint8_t *end; // points to empty byte past last data byte 38 | uint16_t data_size; // size allocated for data 39 | uint16_t count; // current contained element count 40 | }; 41 | 42 | // initialize buffer as empty 43 | // must provide pointer to allocated array for buffer to use 44 | void InitBQ(struct ByteQueue *b, uint8_t* data, uint16_t data_size); 45 | 46 | // return 1 if buffer full, 0 else 47 | int8_t IsFullBQ(struct ByteQueue *b); 48 | 49 | // return 1 if buffer empty, 0 else 50 | int8_t IsEmptyBQ(struct ByteQueue *b); 51 | 52 | // return number elements in buffer 53 | uint16_t CountBQ(struct ByteQueue *p); 54 | 55 | // read and remove next character from buffer 56 | uint8_t GetByteBQ(struct ByteQueue *b); 57 | 58 | // read but don't remove next character from buffer 59 | uint8_t PeekByteBQ(struct ByteQueue *b); 60 | 61 | // add one character to buffer 62 | // return 1 for success, 0 for failure (buffer overflow) 63 | int8_t PutByteBQ(struct ByteQueue *b, uint8_t item); 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif // __cplusplus 68 | 69 | #endif // BYTE_QUEUE_H 70 | -------------------------------------------------------------------------------- /src/client_communication.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: client_communication.cpp 11 | Last update: 4/12/2019 by Matthew Piccoli 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #include "client_communication.hpp" 17 | 18 | int8_t ParseMsg(uint8_t* rx_data, uint8_t rx_length, 19 | ClientEntryAbstract** entry_array, uint8_t entry_length) 20 | { 21 | uint8_t type_idn = rx_data[0]; 22 | uint8_t sub_idn = rx_data[1]; 23 | uint8_t obj_idn = rx_data[2] >> 2; // high 6 bits are obj_idn 24 | Access dir = static_cast(rx_data[2] & 0b00000011); // low two bits 25 | 26 | // if we have a reply (we only parse replies here) 27 | if(dir == kReply) 28 | { 29 | // if sub_idn is within array range (safe to access array at this location) 30 | if(sub_idn < entry_length) 31 | { 32 | // if there is a ClientEntry object at this sub_idn 33 | if(entry_array[sub_idn] != nullptr) 34 | { 35 | // if the type and obj identifiers match 36 | if(entry_array[sub_idn]->type_idn_ == type_idn && 37 | entry_array[sub_idn]->obj_idn_ == obj_idn) 38 | { 39 | // ... then we have a valid message 40 | entry_array[sub_idn]->Reply(&rx_data[3],rx_length-3); 41 | return 1; // I parsed something 42 | } 43 | } 44 | } 45 | } 46 | return 0; // I didn't parse anything 47 | } 48 | 49 | int8_t ParseMsg(uint8_t* rx_data, uint8_t rx_length, 50 | ClientEntryAbstract& entry) 51 | { 52 | uint8_t type_idn = rx_data[0]; 53 | uint8_t sub_idn = rx_data[1]; 54 | uint8_t obj_idn = rx_data[2] >> 2; // high 6 bits are obj_idn 55 | Access dir = static_cast(rx_data[2] & 0b00000011); // low two bits 56 | 57 | // if we have a reply (we only parse replies here) 58 | if(dir == kReply) 59 | { 60 | // if the type and obj identifiers match 61 | if(entry.type_idn_ == type_idn && 62 | entry.obj_idn_ == obj_idn && entry.sub_idn_ == sub_idn) 63 | { 64 | // ... then we have a valid message 65 | entry.Reply(&rx_data[3],rx_length-3); 66 | return 1; // I parsed something 67 | } 68 | } 69 | return 0; // I didn't parse anything 70 | } -------------------------------------------------------------------------------- /src/crc_helper.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | IQ C++ API is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | IQ C++ API is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | /* 21 | Name: crc_helper.c 22 | Last update: 3/7/2019 by Raphael Van Hoffelen 23 | Author: James Paulos 24 | Contributors: Matthew Piccoli, Raphael Van Hoffelen 25 | */ 26 | 27 | #include "crc_helper.h" 28 | 29 | // Compute CRC word for a byte string. 30 | uint16_t MakeCrc(const uint8_t *data, uint16_t count) { 31 | 32 | uint16_t crc = 0xffff; 33 | 34 | uint16_t i; 35 | for(i = 0; i < count; i++) { 36 | crc = ByteUpdateCrc(crc, data[i]); 37 | } 38 | return crc; 39 | } 40 | 41 | // Update a CRC accumulation with one data byte. 42 | uint16_t ByteUpdateCrc(uint16_t crc, uint8_t data) { 43 | 44 | uint16_t x = (crc >> 8) ^ data; 45 | x ^= x >> 4; 46 | 47 | crc = (crc << 8) ^ (x << 12) ^ (x <<5) ^ x; 48 | return crc; 49 | } 50 | 51 | // Update a CRC accumulation with several data bytes. 52 | uint16_t ArrayUpdateCrc(uint16_t crc, const uint8_t *data, uint16_t count) { 53 | 54 | uint16_t i; 55 | for(i = 0; i < count; i++) { 56 | crc = ByteUpdateCrc(crc, data[i]); 57 | } 58 | return crc; 59 | } 60 | -------------------------------------------------------------------------------- /src/crc_helper.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: crc_helper.h 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: James Paulos 13 | Contributors: Matthew Piccoli, Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef CRC_HELPER_H 17 | #define CRC_HELPER_H 18 | 19 | #include 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /* Compute CRC word for a byte string. 26 | */ 27 | uint16_t MakeCrc(const uint8_t *data, uint16_t count); 28 | 29 | /* Update a CRC accumulation with one data byte. 30 | */ 31 | uint16_t ByteUpdateCrc(uint16_t crc, uint8_t data); 32 | 33 | /* Update a CRC accumulation with several data bytes. 34 | */ 35 | uint16_t ArrayUpdateCrc(uint16_t crc, const uint8_t *data, uint16_t count); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif // __cplusplus 40 | 41 | #endif -------------------------------------------------------------------------------- /src/drive_control_interface_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2025 Vertiq, Inc support@vertiq.co 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: drive_control_interface_client.hpp 11 | Last update: 2025-03-12 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef DRIVE_CONTROL_INTERFACE_CLIENT_HPP_ 17 | #define DRIVE_CONTROL_INTERFACE_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeDriveControlInterface = 97; 22 | 23 | class DriveControlInterfaceClient : public ClientAbstract { 24 | public: 25 | DriveControlInterfaceClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypeDriveControlInterface, obj_idn), 27 | voltage_target_(kTypeDriveControlInterface, obj_idn, kSubVoltageTarget), 28 | pwm_target_(kTypeDriveControlInterface, obj_idn, kSubPwmTarget), 29 | torque_target_(kTypeDriveControlInterface, obj_idn, kSubTorqueTarget), 30 | q_current_target_(kTypeDriveControlInterface, obj_idn, kSubQCurrentTarget), 31 | d_current_target_(kTypeDriveControlInterface, obj_idn, kSubDCurrentTarget), 32 | coast_(kTypeDriveControlInterface, obj_idn, kSubCoast), 33 | brake_(kTypeDriveControlInterface, obj_idn, kSubBrake), 34 | mode_(kTypeDriveControlInterface, obj_idn, kSubMode) 35 | {}; 36 | 37 | // Client Entries 38 | ClientEntry voltage_target_; 39 | ClientEntry pwm_target_; 40 | ClientEntry torque_target_; 41 | ClientEntry q_current_target_; 42 | ClientEntry d_current_target_; 43 | ClientEntryVoid coast_; 44 | ClientEntryVoid brake_; 45 | ClientEntry mode_; 46 | 47 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 48 | static const uint8_t kEntryLength = kSubMode + 1; 49 | ClientEntryAbstract* entry_array[kEntryLength] = { 50 | &voltage_target_, // 0 51 | &pwm_target_, // 1 52 | &torque_target_, // 2 53 | &q_current_target_, // 3 54 | &d_current_target_, // 4 55 | &coast_, // 5 56 | &brake_, // 6 57 | &mode_ // 7 58 | }; 59 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 60 | } 61 | 62 | private: 63 | static const uint8_t kSubVoltageTarget = 0; 64 | static const uint8_t kSubPwmTarget = 1; 65 | static const uint8_t kSubTorqueTarget = 2; 66 | static const uint8_t kSubQCurrentTarget = 3; 67 | static const uint8_t kSubDCurrentTarget = 4; 68 | static const uint8_t kSubCoast = 5; 69 | static const uint8_t kSubBrake = 6; 70 | static const uint8_t kSubMode = 7; 71 | 72 | }; 73 | 74 | #endif /* DRIVE_CONTROL_INTERFACE_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /src/hobby_input_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: hobby_input_client.hpp 11 | Last update: 09/16/2022 by Ben Quan 12 | Author: Matthew Piccoli 13 | Contributors: Ben Quan, Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef HOBBY_INPUT_CLIENT_HPP_ 17 | #define HOBBY_INPUT_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeHobbyInput = 76; 22 | 23 | class HobbyInputClient: public ClientAbstract{ 24 | public: 25 | HobbyInputClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeHobbyInput, obj_idn), 27 | allowed_protocols_( kTypeHobbyInput, obj_idn, kSubAllowedProtocols), 28 | protocol_( kTypeHobbyInput, obj_idn, kSubProtocol), 29 | calibrated_protocol_( kTypeHobbyInput, obj_idn, kSubCalibratedProtocol), 30 | calibrated_high_ticks_us_( kTypeHobbyInput, obj_idn, kSubCalibratedHighTicksUs), 31 | calibrated_low_ticks_us_( kTypeHobbyInput, obj_idn, kSubCalibratedLowTicksUs), 32 | reset_calibration_( kTypeHobbyInput, obj_idn, kSubResetCalibration) 33 | {}; 34 | 35 | // Client Entries 36 | // Control commands 37 | ClientEntry allowed_protocols_; 38 | ClientEntry protocol_; 39 | ClientEntry calibrated_protocol_; 40 | ClientEntry calibrated_high_ticks_us_; 41 | ClientEntry calibrated_low_ticks_us_; 42 | ClientEntryVoid reset_calibration_; 43 | 44 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 45 | { 46 | static const uint8_t kEntryLength = kSubResetCalibration+1; 47 | ClientEntryAbstract* entry_array[kEntryLength] = { 48 | &allowed_protocols_, // 0 49 | &protocol_, // 1 50 | &calibrated_protocol_, // 2 51 | &calibrated_high_ticks_us_, // 3 52 | &calibrated_low_ticks_us_, // 4 53 | &reset_calibration_ // 5 54 | }; 55 | 56 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 57 | } 58 | 59 | private: 60 | static const uint8_t kSubAllowedProtocols = 0; 61 | static const uint8_t kSubProtocol = 1; 62 | static const uint8_t kSubCalibratedProtocol = 2; 63 | static const uint8_t kSubCalibratedHighTicksUs = 3; 64 | static const uint8_t kSubCalibratedLowTicksUs = 4; 65 | static const uint8_t kSubResetCalibration = 5; 66 | }; 67 | 68 | #endif /* HOBBY_INPUT_CLIENT_HPP_ */ 69 | -------------------------------------------------------------------------------- /src/iq_module_communication.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2025 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: iq_module_communication.hpp 11 | Last update: 2025/03/12 by Ben Quan 12 | Author: Ben Quan, Matthew Piccoli 13 | */ 14 | 15 | #include "adc_interface_client.hpp" 16 | #include "anticogging_client.hpp" 17 | #include "arming_handler_client.hpp" 18 | #include "brushless_drive_client.hpp" 19 | #include "buzzer_control_client.hpp" 20 | #include "coil_temperature_estimator_client.hpp" 21 | #include "current_safeties_client.hpp" 22 | #include "drive_control_interface_client.hpp" 23 | #include "esc_propeller_input_parser_client.hpp" 24 | #include "gpio_controller_client.hpp" 25 | #include "hobby_input_client.hpp" 26 | #include "iq_serial.hpp" 27 | #include "iquart_flight_controller_interface_client.hpp" 28 | #include "motor_driver_client.hpp" 29 | #include "motor_model_client.hpp" 30 | #include "multi_turn_angle_control_client.hpp" 31 | #include "persistent_memory_client.hpp" 32 | #include "power_monitor_client.hpp" 33 | #include "power_safety_client.hpp" 34 | #include "propeller_motor_control_client.hpp" 35 | #include "pulsing_rectangular_input_parser_client.hpp" 36 | #include "pwm_interface_client.hpp" 37 | #include "rotor_angle_generator_client.hpp" 38 | #include "serial_interface_client.hpp" 39 | #include "servo_input_parser_client.hpp" 40 | #include "step_direction_input_client.hpp" 41 | #include "stopping_handler_client.hpp" 42 | #include "stow_user_interface_client.hpp" 43 | #include "system_control_client.hpp" 44 | #include "temperature_estimator_client.hpp" 45 | #include "temperature_monitor_uc_client.hpp" 46 | #include "uavcan_node_client.hpp" 47 | #include "voltage_superposition_client.hpp" 48 | #include "voltage_target_generator_client.hpp" 49 | -------------------------------------------------------------------------------- /src/mag_alpha_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 Vertiq support@vertiq.co 3 | 4 | This file is part of the Vertiq C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: mag_alpha_client.hpp 11 | Last update: 2023/07/14 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef MAG_ALPHA_CLIENT_HPP 17 | #define MAG_ALPHA_CLIENT_HPP 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeMagAlpha = 75; 22 | 23 | class MagAlphaClient: public ClientAbstract{ 24 | public: 25 | MagAlphaClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeMagAlpha, obj_idn), 27 | angle_raw_(kTypeMagAlpha, obj_idn, kSubAngleRaw), 28 | angle_rad_(kTypeMagAlpha, obj_idn, kSubAngleRad), 29 | alarm_(kTypeMagAlpha, obj_idn, kSubAlarm), 30 | mght_(kTypeMagAlpha, obj_idn, kSubMght), 31 | mglt_(kTypeMagAlpha, obj_idn, kSubMglt), 32 | reg_val_(kTypeMagAlpha, obj_idn, kSubRegVal), 33 | reg_adr_(kTypeMagAlpha, obj_idn, kSubRegAdr), 34 | reg_str_(kTypeMagAlpha, obj_idn, kSubRegStr) 35 | {}; 36 | 37 | // Client Entries 38 | ClientEntry angle_raw_; 39 | ClientEntry angle_rad_; 40 | ClientEntry alarm_; 41 | ClientEntry mght_; 42 | ClientEntry mglt_; 43 | ClientEntry reg_val_; 44 | ClientEntry reg_adr_; 45 | ClientEntryVoid reg_str_; 46 | 47 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 48 | { 49 | static const uint8_t kEntryLength = kSubRegStr+1; 50 | ClientEntryAbstract* entry_array[kEntryLength] = { 51 | &angle_raw_, // 0 52 | &angle_rad_, // 1 53 | &alarm_, // 2 54 | &mght_, // 3 55 | &mglt_, // 4 56 | ®_val_, // 5 57 | ®_adr_, // 6 58 | ®_str_ // 7 59 | }; 60 | 61 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 62 | } 63 | 64 | private: 65 | static const uint8_t kSubAngleRaw = 0; 66 | static const uint8_t kSubAngleRad = 1; 67 | static const uint8_t kSubAlarm = 2; 68 | static const uint8_t kSubMght = 3; 69 | static const uint8_t kSubMglt = 4; 70 | static const uint8_t kSubRegVal = 5; 71 | static const uint8_t kSubRegAdr = 6; 72 | static const uint8_t kSubRegStr = 7; 73 | }; 74 | 75 | #endif // MAG_ALPHA_CLIENT_H -------------------------------------------------------------------------------- /src/persistent_memory_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: persistent_memory_client.hpp 11 | Last update: 10/31/2022 by Ben Quan 12 | Author: Matthew Piccoli 13 | Contributors: Ben Quan, Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef PERSISTENT_MEMORY_CLIENT_HPP_ 17 | #define PERSISTENT_MEMORY_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypePersistentMemory = 11; 22 | 23 | class PersistentMemoryClient: public ClientAbstract{ 24 | public: 25 | PersistentMemoryClient(uint8_t obj_idn): 26 | ClientAbstract( kTypePersistentMemory, obj_idn), 27 | erase_( kTypePersistentMemory, obj_idn, kSubErase), 28 | revert_to_default_( kTypePersistentMemory, obj_idn, kSubRevertToDefault), 29 | format_key_1_( kTypePersistentMemory, obj_idn, kSubFormatKey1), 30 | format_key_2_( kTypePersistentMemory, obj_idn, kSubFormatKey2) 31 | {}; 32 | 33 | // Client Entries 34 | // Control commands 35 | ClientEntryVoid erase_; 36 | ClientEntryVoid revert_to_default_; 37 | ClientEntry format_key_1_; 38 | ClientEntry format_key_2_; 39 | 40 | 41 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 42 | { 43 | static const uint8_t kEntryLength = kSubFormatKey2+1; 44 | ClientEntryAbstract* entry_array[kEntryLength] = { 45 | &erase_, // 0 46 | &revert_to_default_, // 1 47 | &format_key_1_, // 2 48 | &format_key_2_ // 3 49 | }; 50 | 51 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 52 | } 53 | 54 | private: 55 | static const uint8_t kSubErase = 0; 56 | static const uint8_t kSubRevertToDefault = 1; 57 | static const uint8_t kSubFormatKey1 = 2; 58 | static const uint8_t kSubFormatKey2 = 3; 59 | }; 60 | 61 | #endif /* PERSISTENT_MEMORY_CLIENT_HPP_ */ 62 | -------------------------------------------------------------------------------- /src/pulsing_rectangular_input_parser_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: pulsing_rectangular_input_parser_client.hpp 11 | Last update: 2024/08/26 by Fred Kummer 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef PULSING_RECTANGULAR_INPUT_PARSER_CLIENT_HPP_ 17 | #define PULSING_RECTANGULAR_INPUT_PARSER_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypePulsingRectangularInputParser = 89; 22 | 23 | class PulsingRectangularInputParserClient : public ClientAbstract { 24 | public: 25 | PulsingRectangularInputParserClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypePulsingRectangularInputParser, obj_idn), 27 | pulsing_scaling_mode_(kTypePulsingRectangularInputParser, obj_idn, kSubPulsingScalingMode), 28 | pulsing_scaling_limit_(kTypePulsingRectangularInputParser, obj_idn, kSubPulsingScalingLimit){}; 29 | 30 | // Client Entries 31 | ClientEntry pulsing_scaling_mode_; 32 | ClientEntry pulsing_scaling_limit_; 33 | 34 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 35 | static const uint8_t kEntryLength = kSubPulsingScalingLimit + 1; 36 | ClientEntryAbstract* entry_array[kEntryLength] = { 37 | &pulsing_scaling_mode_, // 0 38 | &pulsing_scaling_limit_ // 1 39 | }; 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubPulsingScalingMode = 0; 45 | static const uint8_t kSubPulsingScalingLimit = 1; 46 | }; 47 | 48 | #endif /* PULSING_RECTANGULAR_INPUT_PARSER_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /src/pwm_interface_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: pwm_interface_client.hpp 11 | Last update: 2023/04/18 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef PWM_INTERFACE_CLIENT_HPP_ 17 | #define PWM_INTERFACE_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypePwmInterface = 92; 22 | 23 | class PwmInterfaceClient : public ClientAbstract { 24 | public: 25 | PwmInterfaceClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypePwmInterface, obj_idn), 27 | pwm_frequency_(kTypePwmInterface, obj_idn, kSubPwmFrequency), 28 | duty_cycle_(kTypePwmInterface, obj_idn, kSubDutyCycle), 29 | pwm_mode_(kTypePwmInterface, obj_idn, kSubPwmMode){}; 30 | 31 | // Client Entries 32 | ClientEntry pwm_frequency_; 33 | ClientEntry duty_cycle_; 34 | ClientEntry pwm_mode_; 35 | 36 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 37 | static const uint8_t kEntryLength = kSubPwmMode + 1; 38 | ClientEntryAbstract* entry_array[kEntryLength] = { 39 | &pwm_frequency_, // 0 40 | &duty_cycle_, // 1 41 | &pwm_mode_ // 2 42 | }; 43 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 44 | } 45 | 46 | private: 47 | static const uint8_t kSubPwmFrequency = 0; 48 | static const uint8_t kSubDutyCycle = 1; 49 | static const uint8_t kSubPwmMode = 2; 50 | }; 51 | 52 | #endif /* PWM_INTERFACE_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /src/rgb_led.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 Vertiq, Inc support@vertiq.co 3 | 4 | This file is part of the Vertiq C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | #ifndef RGB_LED_CLIENT_H 10 | #define RGB_LED_CLIENT_H 11 | 12 | #include "client_communication.hpp" 13 | 14 | const uint8_t kTypeRgbLed = 100; 15 | 16 | class RgbLedClient : public ClientAbstract { 17 | public: 18 | RgbLedClient(uint8_t obj_idn) 19 | : ClientAbstract(kTypeRgbLed, obj_idn), 20 | red_(kTypeRgbLed, obj_idn, kSubRed), 21 | green_(kTypeRgbLed, obj_idn, kSubGreen), 22 | blue_(kTypeRgbLed, obj_idn, kSubBlue), 23 | update_color_(kTypeRgbLed, obj_idn, kSubUpdateColor), 24 | strobe_active_(kTypeRgbLed, obj_idn, kSubStrobeActive), 25 | strobe_period_(kTypeRgbLed, obj_idn, kSubStrobePeriod), 26 | strobe_pattern_(kTypeRgbLed, obj_idn, kSubStrobePattern){}; 27 | 28 | // Client Entries 29 | ClientEntry red_; 30 | ClientEntry green_; 31 | ClientEntry blue_; 32 | ClientEntryVoid update_color_; 33 | ClientEntry strobe_active_; 34 | ClientEntry strobe_period_; 35 | ClientEntry strobe_pattern_; 36 | 37 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 38 | static const uint8_t kEntryLength = kSubStrobePattern + 1; 39 | ClientEntryAbstract* entry_array[kEntryLength] = { 40 | &red_, // 0 41 | &green_, // 1 42 | &blue_, // 2 43 | &update_color_, // 3 44 | &strobe_active_, // 4 45 | &strobe_period_, // 5 46 | &strobe_pattern_ // 6 47 | }; 48 | 49 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 50 | } 51 | 52 | private: 53 | static const uint8_t kSubRed = 0; 54 | static const uint8_t kSubGreen = 1; 55 | static const uint8_t kSubBlue = 2; 56 | static const uint8_t kSubUpdateColor = 3; 57 | static const uint8_t kSubStrobeActive = 4; 58 | static const uint8_t kSubStrobePeriod = 5; 59 | static const uint8_t kSubStrobePattern = 6; 60 | 61 | }; 62 | 63 | #endif // RGB_LED_CLIENT_H 64 | -------------------------------------------------------------------------------- /src/rotor_angle_generator_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2025 Vertiq, Inc support@vertiq.co 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: rotor_angle_generator_client.hpp 11 | Last update: 2025-03-11 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef ROTOR_ANGLE_GENERATOR_CLIENT_HPP_ 17 | #define ROTOR_ANGLE_GENERATOR_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeRotorAngleGenerator = 95; 22 | 23 | class RotorAngleGeneratorClient : public ClientAbstract { 24 | public: 25 | RotorAngleGeneratorClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypeRotorAngleGenerator, obj_idn), 27 | rotor_angle_(kTypeRotorAngleGenerator, obj_idn, kSubRotorAngle), 28 | manual_angle_(kTypeRotorAngleGenerator, obj_idn, kSubManualAngle), 29 | use_manual_angle_(kTypeRotorAngleGenerator, obj_idn, kSubUseManualAngle) 30 | {}; 31 | 32 | // Client Entries 33 | ClientEntry rotor_angle_; 34 | ClientEntry manual_angle_; 35 | ClientEntry use_manual_angle_; 36 | 37 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 38 | static const uint8_t kEntryLength = kSubUseManualAngle + 1; 39 | ClientEntryAbstract* entry_array[kEntryLength] = { 40 | &rotor_angle_, // 0 41 | &manual_angle_, // 1 42 | &use_manual_angle_, // 2 43 | }; 44 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 45 | } 46 | 47 | private: 48 | static const uint8_t kSubRotorAngle = 0; 49 | static const uint8_t kSubManualAngle = 1; 50 | static const uint8_t kSubUseManualAngle = 2; 51 | 52 | }; 53 | 54 | #endif /* ROTOR_ANGLE_GENERATOR_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /src/serial_interface_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: serial_interface_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef SERIAL_INTERFACE_CLIENT_H 17 | #define SERIAL_INTERFACE_CLIENT_H 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeSerialInterface = 16; 22 | 23 | class SerialInterfaceClient: public ClientAbstract{ 24 | public: 25 | SerialInterfaceClient(uint8_t obj_idn): 26 | ClientAbstract(kTypeSerialInterface, obj_idn), 27 | baud_rate_( kTypeSerialInterface, obj_idn, kSubBaudRate) 28 | {}; 29 | 30 | // Client Entries 31 | ClientEntry baud_rate_; 32 | 33 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 34 | { 35 | static const uint8_t kEntryLength = kSubBaudRate+1; 36 | ClientEntryAbstract* entry_array[kEntryLength] = { 37 | &baud_rate_, // 0 38 | }; 39 | 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubBaudRate = 0; 45 | }; 46 | 47 | #endif // SERIAL_INTERFACE_CLIENT_H 48 | -------------------------------------------------------------------------------- /src/servo_input_parser_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: servo_input_parser_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef SERVO_INPUT_PARSER_CLIENT_HPP_ 17 | #define SERVO_INPUT_PARSER_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeServoInputParser = 78; 22 | 23 | class ServoInputParserClient: public ClientAbstract{ 24 | public: 25 | ServoInputParserClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeServoInputParser, obj_idn), 27 | mode_( kTypeServoInputParser, obj_idn, kSubMode), 28 | unit_min_( kTypeServoInputParser, obj_idn, kSubUnitMin), 29 | unit_max_( kTypeServoInputParser, obj_idn, kSubUnitMax) 30 | {}; 31 | 32 | // Client Entries 33 | // Control commands 34 | ClientEntry mode_; 35 | ClientEntry unit_min_; 36 | ClientEntry unit_max_; 37 | 38 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 39 | { 40 | static const uint8_t kEntryLength = kSubUnitMax+1; 41 | ClientEntryAbstract* entry_array[kEntryLength] = { 42 | &mode_, // 0 43 | &unit_min_, // 1 44 | &unit_max_ // 2 45 | }; 46 | 47 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 48 | } 49 | 50 | private: 51 | static const uint8_t kSubMode = 0; 52 | static const uint8_t kSubUnitMin = 1; 53 | static const uint8_t kSubUnitMax = 2; 54 | }; 55 | 56 | #endif /* SERVO_INPUT_PARSER_CLIENT_HPP_ */ 57 | -------------------------------------------------------------------------------- /src/step_direction_input_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: step_direction_input_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef STEP_DIRECTION_INPUT_CLIENT_HPP_ 17 | #define STEP_DIRECTION_INPUT_CLIENT_HPP_ 18 | 19 | 20 | #include "client_communication.hpp" 21 | 22 | const uint8_t kTypeStepDirInput = 58; 23 | 24 | class StepDirectionInputClient: public ClientAbstract{ 25 | public: 26 | StepDirectionInputClient(uint8_t obj_idn): 27 | ClientAbstract( kTypeStepDirInput, obj_idn), 28 | angle_( kTypeStepDirInput, obj_idn, kSubAngle), 29 | angle_step_( kTypeStepDirInput, obj_idn, kSubAngleStep) 30 | {}; 31 | 32 | // Client Entries 33 | ClientEntry angle_; 34 | ClientEntry angle_step_; 35 | 36 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 37 | { 38 | static const uint8_t kEntryLength = kSubAngleStep+1; 39 | ClientEntryAbstract* entry_array[kEntryLength] = { 40 | &angle_, // 0 41 | &angle_step_ // 1 42 | }; 43 | 44 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 45 | } 46 | 47 | private: 48 | static const uint8_t kSubAngle = 0; 49 | static const uint8_t kSubAngleStep = 1; 50 | }; 51 | 52 | #endif /* STEP_DIRECTION_INPUT_CLIENT_HPP_ */ 53 | -------------------------------------------------------------------------------- /src/stopping_handler_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: stopping_handler_client.hpp 11 | Last update: 2023/04/12 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef STOPPING_HANDLER_CLIENT_HPP_ 17 | #define STOPPING_HANDLER_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeStoppingHandler = 87; 22 | 23 | class StoppingHandlerClient : public ClientAbstract { 24 | public: 25 | StoppingHandlerClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypeStoppingHandler, obj_idn), 27 | stopped_speed_(kTypeStoppingHandler, obj_idn, kSubStoppedSpeed), 28 | stopped_time_(kTypeStoppingHandler, obj_idn, kSubStoppedTime){}; 29 | 30 | // Client Entries 31 | ClientEntry stopped_speed_; 32 | ClientEntry stopped_time_; 33 | 34 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 35 | static const uint8_t kEntryLength = kSubStoppedTime + 1; 36 | ClientEntryAbstract* entry_array[kEntryLength] = { 37 | &stopped_speed_, // 0 38 | &stopped_time_ // 1 39 | }; 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubStoppedSpeed = 0; 45 | static const uint8_t kSubStoppedTime = 1; 46 | }; 47 | 48 | #endif /* STOPPING_HANDLER_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /src/temperature_estimator_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: temperature_estimator_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | 17 | #ifndef TEMPERATURE_ESTIMATOR_CLIENT_HPP_ 18 | #define TEMPERATURE_ESTIMATOR_CLIENT_HPP_ 19 | 20 | #include "client_communication.hpp" 21 | 22 | const uint8_t kTypeTemperatureEstimatorClient = 77; 23 | 24 | class TemperatureEstimatorClient: public ClientAbstract{ 25 | public: 26 | TemperatureEstimatorClient(uint8_t obj_idn): 27 | ClientAbstract( kTypeTemperatureEstimatorClient, obj_idn), 28 | temp_( kTypeTemperatureEstimatorClient, obj_idn, kSubTemp), 29 | otw_( kTypeTemperatureEstimatorClient, obj_idn, kSubOtw), 30 | otlo_( kTypeTemperatureEstimatorClient, obj_idn, kSubOtlo), 31 | thermal_resistance_( kTypeTemperatureEstimatorClient, obj_idn, kSubThermalResistance), 32 | thermal_capacitance_( kTypeTemperatureEstimatorClient, obj_idn, kSubThermalCapacitance), 33 | derate_( kTypeTemperatureEstimatorClient, obj_idn, kSubDerate) 34 | {}; 35 | 36 | // Client Entries 37 | // Control commands 38 | ClientEntry temp_; 39 | ClientEntry otw_; 40 | ClientEntry otlo_; 41 | ClientEntry thermal_resistance_; 42 | ClientEntry thermal_capacitance_; 43 | ClientEntry derate_; 44 | 45 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 46 | { 47 | static const uint8_t kEntryLength = kSubDerate+1; 48 | ClientEntryAbstract* entry_array[kEntryLength] = { 49 | &temp_, // 0 50 | &otw_, // 1 51 | &otlo_, // 2 52 | &thermal_resistance_, // 3 53 | &thermal_capacitance_,// 4 54 | &derate_ // 5 55 | }; 56 | 57 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 58 | } 59 | 60 | private: 61 | static const uint8_t kSubTemp = 0; 62 | static const uint8_t kSubOtw = 1; 63 | static const uint8_t kSubOtlo = 2; 64 | static const uint8_t kSubThermalResistance = 3; 65 | static const uint8_t kSubThermalCapacitance = 4; 66 | static const uint8_t kSubDerate = 5; 67 | }; 68 | 69 | #endif /* TEMPERATURE_ESTIMATOR_CLIENT_HPP_ */ 70 | -------------------------------------------------------------------------------- /src/temperature_monitor_uc_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 IQinetics Technologies, Inc support@iq-control.com 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: temperature_monitor_uc_client.hpp 11 | Last update: 3/7/2019 by Raphael Van Hoffelen 12 | Author: Matthew Piccoli 13 | Contributors: Raphael Van Hoffelen 14 | */ 15 | 16 | #ifndef TEMPERATURE_MONITOR_UC_CLIENT_HPP_ 17 | #define TEMPERATURE_MONITOR_UC_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeTemperatureMonitorUcClient = 73; 22 | 23 | class TemperatureMonitorUcClient: public ClientAbstract{ 24 | public: 25 | TemperatureMonitorUcClient(uint8_t obj_idn): 26 | ClientAbstract( kTypeTemperatureMonitorUcClient, obj_idn), 27 | uc_temp_( kTypeTemperatureMonitorUcClient, obj_idn, kSubUcTemp), 28 | filter_fs_( kTypeTemperatureMonitorUcClient, obj_idn, kSubFilterFs), 29 | filter_fc_( kTypeTemperatureMonitorUcClient, obj_idn, kSubFilterFc), 30 | otw_( kTypeTemperatureMonitorUcClient, obj_idn, kSubOtw), 31 | otlo_( kTypeTemperatureMonitorUcClient, obj_idn, kSubOtlo), 32 | derate_( kTypeTemperatureMonitorUcClient, obj_idn, kSubDerate) 33 | {}; 34 | 35 | // Client Entries 36 | // Control commands 37 | ClientEntry uc_temp_; 38 | ClientEntry filter_fs_; 39 | ClientEntry filter_fc_; 40 | ClientEntry otw_; 41 | ClientEntry otlo_; 42 | ClientEntry derate_; 43 | 44 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) 45 | { 46 | static const uint8_t kEntryLength = kSubDerate+1; 47 | ClientEntryAbstract* entry_array[kEntryLength] = { 48 | &uc_temp_, // 0 49 | &filter_fs_, // 1 50 | &filter_fc_, // 2 51 | &otw_, // 3 52 | &otlo_, // 4 53 | &derate_ // 5 54 | }; 55 | 56 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 57 | } 58 | 59 | private: 60 | static const uint8_t kSubUcTemp = 0; 61 | static const uint8_t kSubFilterFs = 1; 62 | static const uint8_t kSubFilterFc = 2; 63 | static const uint8_t kSubOtw = 3; 64 | static const uint8_t kSubOtlo = 4; 65 | static const uint8_t kSubDerate = 5; 66 | }; 67 | 68 | #endif /* TEMPERATURE_MONITOR_UC_CLIENT_HPP_ */ 69 | -------------------------------------------------------------------------------- /src/throttle_source_manager_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 Vertiq, Inc support@vertiq.co 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: throttle_source_manager_client.hpp 11 | Last update: 2024/01/30 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef THROTTLE_SOURCE_MANAGER_CLIENT_HPP_ 17 | #define THROTTLE_SOURCE_MANAGER_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeThrottleSourceManager = 104; 22 | 23 | class ThrottleSourceManagerClient : public ClientAbstract { 24 | public: 25 | ThrottleSourceManagerClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypeThrottleSourceManager, obj_idn), 27 | throttle_timeout_(kTypeThrottleSourceManager, obj_idn, kSubThrottleTimeout), 28 | dronecan_priority_(kTypeThrottleSourceManager, obj_idn, kSubDronecanPriority), 29 | hobby_priority_(kTypeThrottleSourceManager, obj_idn, kSubHobbyPriority), 30 | iquart_priority_(kTypeThrottleSourceManager, obj_idn, kSubIquartPriority) 31 | {}; 32 | 33 | // Client Entries 34 | ClientEntry throttle_timeout_; 35 | ClientEntry dronecan_priority_; 36 | ClientEntry hobby_priority_; 37 | ClientEntry iquart_priority_; 38 | 39 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 40 | static const uint8_t kEntryLength = kSubIquartPriority + 1; 41 | ClientEntryAbstract* entry_array[kEntryLength] = { 42 | &throttle_timeout_, // 0 43 | &dronecan_priority_, // 1 44 | &hobby_priority_, // 2 45 | &iquart_priority_, // 3 46 | }; 47 | 48 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 49 | } 50 | 51 | private: 52 | static const uint8_t kSubThrottleTimeout = 0; 53 | static const uint8_t kSubDronecanPriority = 1; 54 | static const uint8_t kSubHobbyPriority = 2; 55 | static const uint8_t kSubIquartPriority = 3; 56 | }; 57 | 58 | #endif /* THROTTLE_SOURCE_MANAGER_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /src/voltage_target_generator_client.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2025 Vertiq, Inc support@vertiq.co 3 | 4 | This file is part of the IQ C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | /* 10 | Name: voltage_target_generator_client.hpp 11 | Last update: 2025-03-11 by Ben Quan 12 | Author: Ben Quan 13 | Contributors: 14 | */ 15 | 16 | #ifndef VOLTAGE_TARGET_GENERATOR_CLIENT_HPP_ 17 | #define VOLTAGE_TARGET_GENERATOR_CLIENT_HPP_ 18 | 19 | #include "client_communication.hpp" 20 | 21 | const uint8_t kTypeVoltageTargetGenerator = 94; 22 | 23 | class VoltageTargetGeneratorClient : public ClientAbstract { 24 | public: 25 | VoltageTargetGeneratorClient(uint8_t obj_idn) 26 | : ClientAbstract(kTypeVoltageTargetGenerator, obj_idn), 27 | q_current_(kTypeVoltageTargetGenerator, obj_idn, kSubQCurrent), 28 | d_current_(kTypeVoltageTargetGenerator, obj_idn, kSubDCurrent), 29 | q_voltage_(kTypeVoltageTargetGenerator, obj_idn, kSubQVoltage), 30 | d_voltage_(kTypeVoltageTargetGenerator, obj_idn, kSubDVoltage) 31 | {}; 32 | 33 | // Client Entries 34 | ClientEntry q_current_; 35 | ClientEntry d_current_; 36 | ClientEntry q_voltage_; 37 | ClientEntry d_voltage_; 38 | 39 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 40 | static const uint8_t kEntryLength = kSubDVoltage + 1; 41 | ClientEntryAbstract* entry_array[kEntryLength] = { 42 | &q_current_, // 0 43 | &d_current_, // 1 44 | &q_voltage_, // 2 45 | &d_voltage_, // 3 46 | }; 47 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 48 | } 49 | 50 | private: 51 | static const uint8_t kSubQCurrent = 0; 52 | static const uint8_t kSubDCurrent = 1; 53 | static const uint8_t kSubQVoltage = 2; 54 | static const uint8_t kSubDVoltage = 3; 55 | 56 | }; 57 | 58 | #endif /* VOLTAGE_TARGET_GENERATOR_CLIENT_HPP_ */ -------------------------------------------------------------------------------- /src/white_led.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2024 Vertiq, Inc support@vertiq.co 3 | 4 | This file is part of the Vertiq C++ API. 5 | 6 | This code is licensed under the MIT license (see LICENSE or https://opensource.org/licenses/MIT for details) 7 | */ 8 | 9 | #ifndef WHITE_LED_CLIENT_H 10 | #define WHITE_LED_CLIENT_H 11 | 12 | #include "client_communication.hpp" 13 | 14 | const uint8_t kTypeWhiteLed = 101; 15 | 16 | class WhiteLedClient : public ClientAbstract { 17 | public: 18 | WhiteLedClient(uint8_t obj_idn) 19 | : ClientAbstract(kTypeWhiteLed, obj_idn), 20 | intensity_(kTypeWhiteLed, obj_idn, kSubIntensity), 21 | strobe_active_(kTypeWhiteLed, obj_idn, kSubStrobeActive), 22 | strobe_period_(kTypeWhiteLed, obj_idn, kSubStrobePeriod), 23 | strobe_pattern_(kTypeWhiteLed, obj_idn, kSubStrobePattern){}; 24 | 25 | // Client Entries 26 | ClientEntry intensity_; 27 | ClientEntry strobe_active_; 28 | ClientEntry strobe_period_; 29 | ClientEntry strobe_pattern_; 30 | 31 | void ReadMsg(uint8_t* rx_data, uint8_t rx_length) { 32 | static const uint8_t kEntryLength = kSubStrobePattern + 1; 33 | ClientEntryAbstract* entry_array[kEntryLength] = { 34 | &intensity_, // 0 35 | &strobe_active_, // 1 36 | &strobe_period_, // 2 37 | &strobe_pattern_ // 3 38 | }; 39 | 40 | ParseMsg(rx_data, rx_length, entry_array, kEntryLength); 41 | } 42 | 43 | private: 44 | static const uint8_t kSubIntensity = 0; 45 | static const uint8_t kSubStrobeActive = 1; 46 | static const uint8_t kSubStrobePeriod = 2; 47 | static const uint8_t kSubStrobePattern = 3; 48 | 49 | }; 50 | 51 | #endif // WHITE_LED_CLIENT_H 52 | --------------------------------------------------------------------------------