Skip to content

Instantly share code, notes, and snippets.

@bullheadandplato
Created November 16, 2020 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bullheadandplato/4eb890a3d04789a66c4523b650486f8a to your computer and use it in GitHub Desktop.
Save bullheadandplato/4eb890a3d04789a66c4523b650486f8a to your computer and use it in GitHub Desktop.
#include<stdlib.h>
#include<strings.h>
#include<stdio.h>
int main() {
char *sRaw = "02010606FFCDAB641001565";
printf("All [%s]\n", sRaw);
char at17 = sRaw[17];
printf("17 is [%c]\n", at17);
char at16 = sRaw[16];
printf("16 is [%c]\n", at16);
char battery[5] = {'0', 'x', sRaw[14], sRaw[15], '\0'};
printf("Battery hex is [%s]\n", battery);
int batteryDecimal = strtol(battery, NULL, 16);
printf("Battery decimal is [%d]\n", batteryDecimal);
return 0;
}
@bullheadandplato
Copy link
Author

Screenshot from 2020-11-16 23-53-09

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment