You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, I have an array of board_discovery_temp_sensor_device which utilizes the following structures:
typedef struct board_discovery_device_handle
{
const char *device_description;
uint32_t device_id;
uintptr_t device;
} board_discovery_device_handle_t;
typedef struct health_monitor_configurations_temp_sensor
{
int32_t over_temperature_limit;
int32_t under_temperature_limit;
} health_monitor_configurations_temp_sensor_t;
typedef struct board_discovery_temp_sensor_channel
{
const char *channel_name;
uint32_t channel_id;
health_monitor_configurations_temp_sensor_t channel_monitoring_params;
} board_discovery_temp_sensor_channel_t;
typedef struct board_discovery_temp_sensor_device
{
board_discovery_device_handle_t device_handle;
/* In case temp_sensor has channels, temp_sensor_monitoring_params will be unused because we should have controling params per channel. */
health_monitor_configurations_temp_sensor_t temp_sensor_monitoring_params;
/* In case temp_sensor has no channels, channels_arr_len will be assigned to 0 and channels_arr will be unused. */
board_discovery_temp_sensor_channel_t channels_arr[BOARD_DISCOVERY_TEMP_SENSOR_MAX_CHANNELS];
uint32_t channels_arr_len;
} board_discovery_temp_sensor_device_t;
The array initialization (I have only two devices):
.temp_sensor_devices_arr = {
[0] = {
.device_handle = {
.device_description = "MAX31730 Temperature Sensor",
.device_id = 25,
//.device = (uint32_t)DEVICE_DT_GET(DT_ALIAS(temp_sensor_0)),
.device = (uint32_t)NULL,
},
/* temp_sensor_monitoring_params variable is unused for this device because it has channels. */
While debugging, I observed that after finishing the encoding of temp_sensor_devices_arr[0], the val pointer in the encode function advanced to the offset of the channels_arr_len field. This explains why, when inspecting the json_escape_internal() function in the debugger, the value of the str pointer is 0x3. I also verified against the actual array, and it corresponds to the address of channels_arr_len from element 0. However, it should actually be the start address of temp_sensor_devices_arr[1]. The channels_arr_len field should be encapsulated within the call to JSON_OBJ_DESCR_OBJ_ARRAY, and it should be taken into account when calculating the offset of each object.
I would greatly appreciate any assistance that can be provided.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey, I have an array of board_discovery_temp_sensor_device which utilizes the following structures:
The board_discovery_temp_sensor_device array is a part of a larger structure, and here is its declaration:
and it's correspond json description:
/* Temperature Sensor Devices */
The array initialization (I have only two devices):
.temp_sensor_devices_arr = {
[0] = {
.device_handle = {
.device_description = "MAX31730 Temperature Sensor",
.device_id = 25,
//.device = (uint32_t)DEVICE_DT_GET(DT_ALIAS(temp_sensor_0)),
.device = (uint32_t)NULL,
},
/* temp_sensor_monitoring_params variable is unused for this device because it has channels. */
When I print the output json of this array it looks like this:
While debugging, I observed that after finishing the encoding of temp_sensor_devices_arr[0], the val pointer in the encode function advanced to the offset of the channels_arr_len field. This explains why, when inspecting the json_escape_internal() function in the debugger, the value of the str pointer is 0x3. I also verified against the actual array, and it corresponds to the address of channels_arr_len from element 0. However, it should actually be the start address of temp_sensor_devices_arr[1]. The channels_arr_len field should be encapsulated within the call to JSON_OBJ_DESCR_OBJ_ARRAY, and it should be taken into account when calculating the offset of each object.

I would greatly appreciate any assistance that can be provided.
Thanks,
Ofir.
Beta Was this translation helpful? Give feedback.
All reactions