Rate and give feedback:
Huawei uses machine translation combined with human proofreading to translate this document to different languages in order to help you better understand the content of this document.
Note: Even the most advanced machine translation cannot match the quality of professional translators.
Huawei shall not bear any responsibility for translation accuracy and it is recommended that you refer to the English document (a link for which has been provided).
Obtaining the Temperature Data of the Atlas 300 Card
The temperature data of the Atlas 300 card is greater than 32 bytes. You need to obtain the data for multiple times. The sample code is as follows:
int dcmi_mcu_get_info_dynamic(char *dev_name, int item_type, int opcode, int total_len, char *req_data, int req_data_len, char *data_info, int *len) { int ret; int offset; int len_curr = 0; int len_total = 0; int len_msg_curr = 0; int len_msg_total = 0; int count; int num_id; char buffer[DCMI_MCU_MSG_MAX_TOTAL_LEN] = {0}; char *point = NULL; int len_total_true; point = &buffer[0]; ret = dcmi_mcu_get_info(dev_name, item_type, opcode, 0, total_len, req_data, req_data_len, point, &len_curr, &len_total); len_total_true = len_total; if (ret != DCMI_OK) { printf("call dcmi_mcu_get_info fail.ret(%d)\n", ret); return DCMI_ERR; } if ((len_total <= len_curr) && (len_total < DCMI_MCU_MSG_MAX_TOTAL_LEN) && (len_total > 0)) { memcpy(data_info, buffer, len_total); *len = len_total; return DCMI_OK; } if (len_total > DCMI_MCU_MSG_MAX_TOTAL_LEN) { printf("total=%d bigger tran 256.\n", len_total); return DCMI_ERR; } len_total -= len_curr; offset = len_curr; point += len_curr; count = len_total / DCMI_MCU_MSG_DATA_LEN; if (len_total % DCMI_MCU_MSG_DATA_LEN != 0) { count++; } for (num_id = 0; num_id < count; num_id++) { if (offset + DCMI_MCU_MSG_DATA_LEN > len_total) { len_curr = len_total - offset; } else { len_curr = DCMI_MCU_MSG_DATA_LEN; } ret = dcmi_mcu_get_info(dev_name, 0, opcode, offset, DCMI_MCU_MSG_DATA_LEN, req_data, req_data_len, point, &len_msg_curr, &len_msg_total); if (ret != DCMI_OK) { printf("call dcmi_mcu_get_info fail.ret(%d)\n", ret); return DCMI_ERR; } offset += len_curr; point += len_curr; } if (len_total_true < DCMI_MCU_MSG_MAX_TOTAL_LEN) { memcpy(data_info, buffer, len_total_true); *len = len_total + len_curr; } else { return DCMI_ERR; } return DCMI_OK; } int show_chip_temp_info(char *dev_name, int opcode) { char data_info[256] = { 0 }; // Returned data char tmp_data[9] = { 0 }; /* Temporary storage temperature */ int req_data = 0; int len = 0; // Return the length of the current data. int temp_index, temp_num, temp_get; dcmi_mcu_get_info_dynamic(dev_name, 0, opcode, DCMI_MCU_MSG_DATA_LEN, (char *)&req_data, 0, data_info, &len); temp_num = (int)data_info[0]; for (temp_index = 0; temp_index < temp_num; temp_index++) { temp_get = *(INT16 *)(data_info + (temp_index * 10 + 9)); /* PCIe out-of-band management specifications. The temperature name contains 8 characters (excluding the end character). */ strncpy(tmp_data, data_info + temp_index * 10 + 1, 8); printf("\t%-8s%-22s :", tmp_data, " (C)"); if (temp_get == 0x7fff) { printf(" %s\n", "Failed"); } else if (temp_get == 0x7ffd) { printf(" %s\n", "NA"); } else { printf(" %d\n", temp_get); } } return 0; }