Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
Revision 17:7acb89d71f48, committed 2019-06-27
- Comitter:
- andrewboyson
- Date:
- Thu Jun 27 21:19:33 2019 +0000
- Parent:
- 16:5c41b457c7f3
- Child:
- 18:617791ed3d8e
- Commit message:
- Added functions to log hex bytes
Changed in this revision
| log.c | Show annotated file Show diff for this revision Revisions of this file |
| log.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/log.c Mon Feb 04 15:26:50 2019 +0000
+++ b/log.c Thu Jun 27 21:19:33 2019 +0000
@@ -201,3 +201,31 @@
va_end(argptr);
return size;
}
+
+void LogNibbleAsHex(int nibble)
+{
+ nibble &= 0x0F;
+ char c;
+ if (nibble < 0x0A) c = nibble + '0';
+ else if (nibble < 0x10) c = nibble - 0xA + 'A';
+ else c = '0';
+ LogChar(c);
+}
+
+void LogByteAsHex(int value)
+{
+ LogNibbleAsHex(value >> 4);
+ LogNibbleAsHex(value >> 0);
+}
+void LogBytesAsHex(char* value, int size)
+{
+ int i = 0;
+ while(true)
+ {
+ LogByteAsHex(value[size - 1 - i]); //Display big end first
+ i++;
+ if (i >= size) break;
+ if (i % 32 == 0) Log("\r\n");
+ else LogChar(' ');
+ }
+}
--- a/log.h Mon Feb 04 15:26:50 2019 +0000 +++ b/log.h Thu Jun 27 21:19:33 2019 +0000 @@ -18,3 +18,7 @@ extern void LogEnumerateStart(void); extern int LogEnumerate(void); extern void LogEnable(bool value); + +extern void LogNibbleAsHex(int nibble); +extern void LogByteAsHex(int value); +extern void LogBytesAsHex(char* value, int size);