diff options
| author | Aditya Naik | 2020-04-07 02:47:09 -0400 |
|---|---|---|
| committer | Aditya Naik | 2020-04-07 02:47:09 -0400 |
| commit | ed665c2a448aa8b9087bb020a18e9f6bee631e6e (patch) | |
| tree | 1555d3f5caf9a4bcde8851af58eed39e781940d4 | |
| parent | c6b5ecbe11526904922dad94c9ae663d26b30a97 (diff) | |
MDR decode works with pointer
| -rw-r--r-- | Src/main-hs.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/Src/main-hs.c b/Src/main-hs.c index 6fb51bc..75de218 100644 --- a/Src/main-hs.c +++ b/Src/main-hs.c @@ -64,7 +64,6 @@ UART_HandleTypeDef huart1; device_info_t *device_info[BUS_DEVICE_LIMIT] = {NULL}; subscription_info_t* subs_info[BUS_DEVICE_LIMIT]; uint32_t allocated[4]={0}; -_subscriptions gsubs[10]; /* uint8_t dev_sts[128] = {OFFLINE}; */ /* USER CODE END PV */ @@ -526,10 +525,8 @@ int handshake(uint32_t i2c_addr) memset(debug_buf, 0, 128); goto __HS_MDR_MDR_TESTING_END; __MDR_DEC_TESTING: - sprintf((char*)debug_buf, "MDR Decode success\n\tFirst subscibed module: %d\r\n", - subs_info[dev_idx]->i2c_address[0]); - sprintf((char*)debug_buf, "MDR Decode success\r\n\tFirst subscibed module: %ld\r\n", - gsubs[0].module_id); + sprintf((char*)debug_buf, "MDR Decode success\r\n\tFirst subscibed module: %d\r\n\tSubs size: %d\r\n", + subs_info[dev_idx]->module_ids[1], sizeof(subscription_info_t)); HAL_UART_Transmit(&huart1, debug_buf, sizeof(debug_buf), 100); memset(debug_buf, 0, 128); goto __MDR_DEC_TESTING_END; @@ -599,17 +596,17 @@ bool decode_subscriptions_callback(pb_istream_t *istream, const pb_field_t *fiel if ((GET_BIT_FROM_IDX(allocated, *subs_idx)) == 0) { subs_info[*subs_idx] = (subscription_info_t*)malloc(sizeof(subscription_info_t)); SET_BIT_FROM_IDX(allocated, *subs_idx); + subs_info[*subs_idx]->mod_idx = subs_info[*subs_idx]->entity_idx = + subs_info[*subs_idx]->class_idx = subs_info[*subs_idx]->i2c_idx = 0; } if(!pb_decode(istream, _subscriptions_fields, &subs)) return false; /* Parse all fields if they're included */ - if (subs.has_module_id) { + if (subs.has_module_id) subs_info[*subs_idx]->module_ids[subs_info[*subs_idx]->mod_idx++] = subs.module_id; - gsubs[0].module_id = subs.module_id; - } if (subs.has_entity_id) subs_info[*subs_idx]->entity_ids[subs_info[*subs_idx]->entity_idx++] = subs.entity_id; |
