created separate function for hex to char
Dependencies: SDFileSystem ds3231 eeprom_Nikita mbed testUniGraphic_150217
Fork of SS_SensePOC2P0_11Dec2017_USERPID by
Diff: main.cpp
- Revision:
- 69:128e3b467820
- Parent:
- 68:41da0a3ba038
- Child:
- 70:f2e544a5645b
--- a/main.cpp Tue Nov 21 12:47:03 2017 +0000 +++ b/main.cpp Thu Nov 23 12:11:46 2017 +0000 @@ -105,9 +105,9 @@ void debug_status_monitoring(); // debug status monitoring static uint32_t pid = 0; // patient ID static uint8_t state_touch = 1; //added on 16-NOV rashmi -uint8_t buffer_pointer = 0x00u; +uint8_t buffer_pointer = 0x00u; +static char user_pid[10]; - int main() { static DEVICE_MAIN_STATE main_state = GET_TOUCH_DISP_STATE; @@ -377,6 +377,7 @@ static uint8_t ecg_flag=0; // ecg_flag to indicate the ecg test is already done for the same pid static uint8_t glc_flag=0; // glc_flag to indicate the glc test is already done for the same pid //uint16_t heart_rate=0; + switch(state1) // state for display screens { @@ -414,7 +415,7 @@ set_userpid(user_pid); gc.printf("User pid = %s\n",user_pid); - + gc.printf("pidinit=%d",pid); screen_main_2(user_pid); state1=0; @@ -766,9 +767,18 @@ // patient ID if (curr_touch_state == TOUCH_STATE_TEST_SCREEN) { - get_userpid(poc2p0_device_heartbeat_res.pid,user_pid); + memcpy(poc2p0_device_heartbeat_res.pid,get_userpid(),sizeof(poc2p0_device_heartbeat_res.pid)); gc.printf("poc2p0_device_heartbeat_res.pid = %s\n",poc2p0_device_heartbeat_res.pid); - ascii_to_hex((const char *)poc2p0_device_heartbeat_res.pid, strlen(poc2p0_device_heartbeat_res.pid)); + + ascii_to_hex((const char *)poc2p0_device_heartbeat_res.pid, sizeof(poc2p0_device_heartbeat_res.pid)); + //gc.printf("poc2p0_device_heartbeat_res.pid = %2x\n",poc2p0_device_heartbeat_res.pid); + gc.printf("\n"); + + for (uint8_t i = 0; i < sizeof(poc2p0_device_heartbeat_res.pid); i++) + { + gc.printf("%02x",poc2p0_device_heartbeat_res.pid[i]); + } + gc.printf("\n"); //poc2p0_device_heartbeat_res.pid = pid; } else @@ -865,13 +875,20 @@ } } -void get_userpid(char *output_pid,char input_pid[]) +/*void get_userpid(char *output_pid,char input_pid[]) { strcpy(output_pid,input_pid); gc.printf("Temp User pid = %s\n",output_pid); //return user_pid; +}*/ + +char* get_userpid(void) +{ + return user_pid; } + + void ascii_to_hex(const char *input_buf, uint8_t len) { uint8_t i = 0; @@ -879,16 +896,25 @@ uint8_t temp_ms_nibble = 0; uint8_t temp_ls_nibble = 0; uint8_t temp_buf[len]; - - for (i = 0,j = 0; i < len; i+=2, ++j) + gc.printf("\n\r len = %d", len); + for (i = 0,j = 0; i < len; i+=1, ++j) { temp_ms_nibble = input_buf[i] > '9' ? (input_buf[i]|32) - 'a' + 10 : input_buf[i] - '0'; - temp_ls_nibble = input_buf[i+1] > '9' ? (input_buf[i+1]|32) - 'a' + 10 : input_buf[i+1] - '0'; - temp_buf[j] = (temp_ms_nibble << 4) | temp_ls_nibble; - //mc.printf("\n\r msg_SOS = %2x", temp_buf[j]); + + gc.printf("\n\r temp_ms_nibble = %2x", temp_ms_nibble); + + //temp_ls_nibble = input_buf[i+1] > '9' ? (input_buf[i+1]|32) - 'a' + 10 : input_buf[i+1] - '0'; + //gc.printf("\n\r temp_ls_nibble = %2x", temp_ls_nibble); + + //temp_buf[j] = ((temp_ms_nibble << 4)) | temp_ls_nibble; + temp_buf[j] = temp_ms_nibble ; + gc.printf("\n\r msg_SOS = %02x", temp_buf[j]); } memcpy((void *)input_buf,&temp_buf, len); + return; } + +