From 084e0b53266f6c0d0794b48e7c704a4c03185031 Mon Sep 17 00:00:00 2001 From: Mark Zakharyan Date: Mon, 23 Sep 2024 19:24:26 -0700 Subject: [PATCH 1/2] changed voltage data transfer for LabRAD --- m4/.vscode/c_cpp_properties.json | 202 +++++++++++++++---------------- m4/.vscode/launch.json | 12 +- m7/src/main.cpp | 89 +++++++++----- 3 files changed, 168 insertions(+), 135 deletions(-) diff --git a/m4/.vscode/c_cpp_properties.json b/m4/.vscode/c_cpp_properties.json index 8b536ca..03bcffe 100644 --- a/m4/.vscode/c_cpp_properties.json +++ b/m4/.vscode/c_cpp_properties.json @@ -8,107 +8,107 @@ { "name": "PlatformIO", "includePath": [ - "/Users/space/Desktop/dual_firmware/m4/include", - "/Users/space/Desktop/dual_firmware/m4/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/SPI", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Portenta_SDRAM/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/ea_malloc", - "/Users/space/.platformio/packages/framework-arduino-mbed/cores/arduino", - "/Users/space/.platformio/packages/framework-arduino-mbed/cores/arduino/api/deprecated", - "/Users/space/.platformio/packages/framework-arduino-mbed/cores/arduino/api/deprecated-avr-comp", - "/Users/space/.platformio/packages/framework-arduino-mbed/variants/GENERIC_STM32H747_M4", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Arduino_CAN/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Arduino_H7_Video/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Camera/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Ethernet/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/GC2145", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/GPS/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/GSM/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Himax_HM01B0", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Himax_HM0360", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/KernelDebug/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/MCUboot/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/MLC/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/MRI/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/NDP/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Nano33BLE_System/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Nicla_System/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/OV7670", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/PDM/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Portenta_Audio/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Portenta_SDCARD/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/RPC/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/SE05X/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/SFU/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/STM32H747_System/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Scheduler/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/SocketWrapper/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/ThreadDebug/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/USBAudio", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/USBHID/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/USBHOST/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/USBMIDI", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/USBMSD/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/WiFi/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Wire", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/doom/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/mbed-memory-status", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/openamp_arduino/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/rpclib/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/syntiant_ilib/src", + "c:/Users/lab/Desktop/dac-adc-firmware-dual-core/m4/include", + "c:/Users/lab/Desktop/dac-adc-firmware-dual-core/m4/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/SPI", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Portenta_SDRAM/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/ea_malloc", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/cores/arduino", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/cores/arduino/api/deprecated", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/cores/arduino/api/deprecated-avr-comp", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/variants/GENERIC_STM32H747_M4", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Arduino_CAN/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Arduino_H7_Video/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Camera/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Ethernet/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/GC2145", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/GPS/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/GSM/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Himax_HM01B0", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Himax_HM0360", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/KernelDebug/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/MCUboot/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/MLC/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/MRI/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/NDP/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Nano33BLE_System/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Nicla_System/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/OV7670", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/PDM/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Portenta_Audio/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Portenta_SDCARD/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/RPC/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/SE05X/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/SFU/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/STM32H747_System/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Scheduler/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/SocketWrapper/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/ThreadDebug/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/USBAudio", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/USBHID/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/USBHOST/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/USBMIDI", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/USBMSD/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/WiFi/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Wire", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/doom/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/mbed-memory-status", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/openamp_arduino/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/rpclib/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/syntiant_ilib/src", "" ], "browse": { "limitSymbolsToIncludedHeaders": true, "path": [ - "/Users/space/Desktop/dual_firmware/m4/include", - "/Users/space/Desktop/dual_firmware/m4/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/SPI", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Portenta_SDRAM/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/ea_malloc", - "/Users/space/.platformio/packages/framework-arduino-mbed/cores/arduino", - "/Users/space/.platformio/packages/framework-arduino-mbed/cores/arduino/api/deprecated", - "/Users/space/.platformio/packages/framework-arduino-mbed/cores/arduino/api/deprecated-avr-comp", - "/Users/space/.platformio/packages/framework-arduino-mbed/variants/GENERIC_STM32H747_M4", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Arduino_CAN/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Arduino_H7_Video/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Camera/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Ethernet/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/GC2145", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/GPS/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/GSM/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Himax_HM01B0", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Himax_HM0360", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/KernelDebug/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/MCUboot/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/MLC/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/MRI/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/NDP/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Nano33BLE_System/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Nicla_System/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/OV7670", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/PDM/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Portenta_Audio/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Portenta_SDCARD/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/RPC/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/SE05X/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/SFU/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/STM32H747_System/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Scheduler/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/SocketWrapper/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/ThreadDebug/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/USBAudio", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/USBHID/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/USBHOST/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/USBMIDI", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/USBMSD/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/WiFi/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/Wire", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/doom/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/mbed-memory-status", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/openamp_arduino/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/rpclib/src", - "/Users/space/.platformio/packages/framework-arduino-mbed/libraries/syntiant_ilib/src", + "c:/Users/lab/Desktop/dac-adc-firmware-dual-core/m4/include", + "c:/Users/lab/Desktop/dac-adc-firmware-dual-core/m4/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/SPI", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Portenta_SDRAM/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/ea_malloc", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/cores/arduino", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/cores/arduino/api/deprecated", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/cores/arduino/api/deprecated-avr-comp", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/variants/GENERIC_STM32H747_M4", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Arduino_CAN/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Arduino_H7_Video/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Camera/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Ethernet/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/GC2145", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/GPS/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/GSM/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Himax_HM01B0", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Himax_HM0360", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/KernelDebug/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/MCUboot/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/MLC/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/MRI/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/NDP/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Nano33BLE_System/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Nicla_System/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/OV7670", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/PDM/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Portenta_Audio/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Portenta_SDCARD/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/RPC/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/SE05X/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/SFU/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/STM32H747_System/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Scheduler/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/SocketWrapper/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/ThreadDebug/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/USBAudio", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/USBHID/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/USBHOST/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/USBMIDI", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/USBMSD/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/WiFi/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/Wire", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/doom/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/mbed-memory-status", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/openamp_arduino/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/rpclib/src", + "C:/Users/lab/.platformio/packages/framework-arduino-mbed/libraries/syntiant_ilib/src", "" ] }, @@ -160,7 +160,7 @@ "FEATURE_BLE=1", "__FPU_PRESENT=1", "__MBED__=1", - "MBED_BUILD_TIMESTAMP=1714459159.841316", + "MBED_BUILD_TIMESTAMP=1720438822.17746", "__MBED_CMSIS_RTOS_CM", "MBED_MPU_CUSTOM", "MBED_TICKLESS", @@ -199,7 +199,7 @@ "MBED_NO_GLOBAL_USING_DIRECTIVE=1", "CORE_MAJOR=4", "CORE_MINOR=1", - "CORE_PATCH=3", + "CORE_PATCH=5", "USE_ARDUINO_PINOUT", "ARDUINO=10810", "ARDUINO_ARCH_MBED", @@ -209,14 +209,14 @@ ], "cStandard": "gnu11", "cppStandard": "gnu++14", - "compilerPath": "/Users/space/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc", + "compilerPath": "C:/Users/lab/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc.exe", "compilerArgs": [ "-mcpu=cortex-m4", "-mfloat-abi=softfp", "-mfpu=fpv4-sp-d16", "-mthumb", - "-iprefix/Users/space/.platformio/packages/framework-arduino-mbed/cores/arduino", - "@/Users/space/.platformio/packages/framework-arduino-mbed/variants/GENERIC_STM32H747_M4/includes.txt", + "-iprefixC:/Users/lab/.platformio/packages/framework-arduino-mbed/cores/arduino", + "@C:/Users/lab/.platformio/packages/framework-arduino-mbed/variants/GENERIC_STM32H747_M4/includes.txt", "-mfloat-abi=soft", "-mfpu=fpv4-sp-d16", "" diff --git a/m4/.vscode/launch.json b/m4/.vscode/launch.json index 94b8f11..ddfa9eb 100644 --- a/m4/.vscode/launch.json +++ b/m4/.vscode/launch.json @@ -12,9 +12,9 @@ "type": "platformio-debug", "request": "launch", "name": "PIO Debug", - "executable": "/Users/space/Desktop/dual_firmware/m4/.pio/build/giga_r1_m4/firmware.elf", + "executable": "c:/Users/lab/Desktop/dac-adc-firmware-dual-core/m4/.pio/build/giga_r1_m4/firmware.elf", "projectEnvName": "giga_r1_m4", - "toolchainBinDir": "/Users/space/.platformio/packages/toolchain-gccarmnoneeabi/bin", + "toolchainBinDir": "C:/Users/lab/.platformio/packages/toolchain-gccarmnoneeabi/bin", "internalConsoleOptions": "openOnSessionStart", "preLaunchTask": { "type": "PlatformIO", @@ -25,18 +25,18 @@ "type": "platformio-debug", "request": "launch", "name": "PIO Debug (skip Pre-Debug)", - "executable": "/Users/space/Desktop/dual_firmware/m4/.pio/build/giga_r1_m4/firmware.elf", + "executable": "c:/Users/lab/Desktop/dac-adc-firmware-dual-core/m4/.pio/build/giga_r1_m4/firmware.elf", "projectEnvName": "giga_r1_m4", - "toolchainBinDir": "/Users/space/.platformio/packages/toolchain-gccarmnoneeabi/bin", + "toolchainBinDir": "C:/Users/lab/.platformio/packages/toolchain-gccarmnoneeabi/bin", "internalConsoleOptions": "openOnSessionStart" }, { "type": "platformio-debug", "request": "launch", "name": "PIO Debug (without uploading)", - "executable": "/Users/space/Desktop/dual_firmware/m4/.pio/build/giga_r1_m4/firmware.elf", + "executable": "c:/Users/lab/Desktop/dac-adc-firmware-dual-core/m4/.pio/build/giga_r1_m4/firmware.elf", "projectEnvName": "giga_r1_m4", - "toolchainBinDir": "/Users/space/.platformio/packages/toolchain-gccarmnoneeabi/bin", + "toolchainBinDir": "C:/Users/lab/.platformio/packages/toolchain-gccarmnoneeabi/bin", "internalConsoleOptions": "openOnSessionStart", "loadMode": "manual" } diff --git a/m7/src/main.cpp b/m7/src/main.cpp index 229d1a5..2be6d1f 100644 --- a/m7/src/main.cpp +++ b/m7/src/main.cpp @@ -2,13 +2,16 @@ #include "Utils/shared_memory.h" -#define return_if_not_ok(x) \ - do { \ - int ret = x; \ - if (ret != HAL_OK) return; \ +#define return_if_not_ok(x) \ + do \ + { \ + int ret = x; \ + if (ret != HAL_OK) \ + return; \ } while (0); -void enableM4() { +void enableM4() +{ HAL_MPU_Disable(); // Disable caching for the shared memory region. @@ -33,7 +36,8 @@ void enableM4() { OBInit.Banks = FLASH_BANK_1; HAL_FLASHEx_OBGetConfig(&OBInit); - if (OBInit.USERConfig & FLASH_OPTSR_BCM4) { + if (OBInit.USERConfig & FLASH_OPTSR_BCM4) + { OBInit.OptionType = OPTIONBYTE_USER; OBInit.USERType = OB_USER_BCM4; OBInit.USERConfig = 0; @@ -53,60 +57,89 @@ void enableM4() { LL_RCC_ForceCM4Boot(); } -void setup() { + +typedef union { + float floatingPoint; + byte binary[4]; +} binaryFloat; + +void setup() +{ enableM4(); - if (!initSharedMemory()) { - while (1) { + if (!initSharedMemory()) + { + while (1) + { Serial.println("Failed to initialize shared memory"); delay(1000); } } } -void loop() { - if (Serial.available()) { +void loop() +{ + if (Serial.available()) + { String command = Serial.readStringUntil('\n'); command.trim(); String command_lower = command; command_lower.toLowerCase(); - if (command_lower == "stop") { + if (command_lower == "stop") + { setStopFlag(true); - } else { + } + else + { m7SendChar(command.c_str(), command.length()); } } - if (m7HasCharMessage()) { + if (m7HasCharMessage()) + { char response[CHAR_BUFFER_SIZE]; size_t size; - if (m7ReceiveChar(response, size)) { + if (m7ReceiveChar(response, size)) + { + if (size > 0) + { + size--; // Decrease size to exclude the last character + } Serial.write(response, size); Serial.println(); } } - if (m7HasFloatMessage()) { + if (m7HasFloatMessage()) + { float response[FLOAT_BUFFER_SIZE]; size_t size; - if (m7ReceiveFloat(response, size)) { - for (size_t i = 0; i < size; ++i) { + if (m7ReceiveFloat(response, size)) + { + for (size_t i = 0; i < size; ++i) + { Serial.print(response[i], 8); Serial.print(" "); } Serial.println(); } } - if (m7HasVoltageMessage()) { + if (m7HasVoltageMessage()) + { VoltagePacket response[VOLTAGE_BUFFER_SIZE]; size_t size; - if (m7ReceiveVoltage(response, size)) { - for (size_t i = 0; i < size; ++i) { - Serial.print("ADC ID: "); - Serial.print(response[i].adc_id); - Serial.print(", Setnum: "); - Serial.print(response[i].setnum); - Serial.print(", "); - Serial.print(response[i].voltage, 8); - Serial.println("V"); + if (m7ReceiveVoltage(response, size)) + { + for (size_t i = 0; i < size; ++i) + { + // Serial.print("ADC ID: "); + // Serial.print(response[i].adc_id); + // Serial.print(", Setnum: "); + // Serial.print(response[i].setnum); + // Serial.print(", "); + // Serial.print(response[i].voltage, 8); + binaryFloat send; + send.floatingPoint = response[i].voltage; + Serial.write(send.binary, 4); + // Serial.println("V"); } } } From d8466ba6e0db1813c9f99329c98a39fdf2f5e2c7 Mon Sep 17 00:00:00 2001 From: Mark Zakharyan Date: Mon, 23 Sep 2024 20:45:28 -0700 Subject: [PATCH 2/2] error handling for LabRAD detection --- m4/src/Peripherals/OperationResult.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/m4/src/Peripherals/OperationResult.h b/m4/src/Peripherals/OperationResult.h index aa3997d..e23d30f 100644 --- a/m4/src/Peripherals/OperationResult.h +++ b/m4/src/Peripherals/OperationResult.h @@ -18,11 +18,11 @@ class OperationResult { } static OperationResult Failure(const String& message) { - return OperationResult(Status::Failure, message); + return OperationResult(Status::Failure, String("FAILURE: ") + message + "\x00"); } static OperationResult Failure() { - return OperationResult(Status::Failure, String("Something went wrong!")); + return OperationResult(Status::Failure, String("FAILURE: Something went wrong!\x00")); } // Check if the operation was successful