Hello,
I’m using the Arduino Portenta Machine Control Board (H7 M7) with the Arduino IDE and the Arduino mbed OS Portenta Boards (Version 4.0.10). The Mbed OS version is 6.17.0.
I want to use the KV_Store global static API to store some values.
However, when I try to use the KV_Store global static API, my board crashes. The serial port disappears from the serial monitor and I have to reset the serial port (clicking the board reset button twice) in order to upload another program. Here is the code I’m using.
Any help would be appreciated.
#include <Arduino.h>
#include "mbed.h"
#include "KVStore.h"
#include "kvstore_global_api.h"
#include <string>
char str[5];
char kv_key[] = {"/kv/key"};
char kv_value[5];
kv_info_t info;
void KV_Store_Init()
{
Serial.begin(9600);
Serial.print("Hello from Mbed OS version ");
Serial.print(MBED_MAJOR_VERSION);
Serial.print(" ");
Serial.print(MBED_MINOR_VERSION);
Serial.print(" ");
Serial.println(MBED_PATCH_VERSION);
}
void KV_Store_Run()
{
Serial.println("KV_Store_Run()..");
strcpy(str, "05206");
Serial.print("Your value is ");
Serial.println(str);
kv_get_info(kv_key, &info);
kv_get(kv_key, kv_value, info.size, 0);
Serial.println("Saving value");
kv_set(kv_key, str, strlen(str), 0);
}
void setup()
{
Serial.begin(9600);
KV_Store_Init();
}
void loop()
{
KV_Store_Run();
// KV_Store_Init();
delay(2000);
}
The crashes take place when I call any of the KV_Store global API functions:
kv_get_info(kv_key, &info);
kv_get(kv_key, kv_value, info.size, 0);
kv_set(kv_key, str, strlen(str), 0);