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 2:ee4ec2d72525, committed 2017-02-04
- Comitter:
- andrewboyson
- Date:
- Sat Feb 04 18:45:41 2017 +0000
- Parent:
- 1:4d81afe3859e
- Child:
- 3:7806ff3f1a2d
- Commit message:
- Display non-ascii characters as hex
Changed in this revision
| log.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/log.cpp Wed Feb 01 07:41:22 2017 +0000
+++ b/log.cpp Sat Feb 04 18:45:41 2017 +0000
@@ -20,40 +20,58 @@
//Only add if allowed
if (!enable) return;
+ char* pNext;
+
+ //Work out what has to be sent
+ bool delimited = false;
+ if (c < ' ' && c != '\r' && c != '\n') delimited = true;
+ if (c > 126) delimited = true;
+
//Move the pull position if about to run into it
- char* pNext = incrementPushPullPointer(pPush, buffer, BUFFER_LENGTH);
+ pNext = incrementPushPullPointer(pPush, buffer, BUFFER_LENGTH);
+ if (pNext == pPull) pPull = incrementPushPullPointer(pPull, buffer, BUFFER_LENGTH);
+
+ //Add the character at the push position
+ if (delimited) *pPush = '^';
+ else *pPush = c;
+ pPush = incrementPushPullPointer(pPush, buffer, BUFFER_LENGTH);
+
+ if (!delimited) return;
+
+ //Move the pull position if about to run into it
+ pNext = incrementPushPullPointer(pPush, buffer, BUFFER_LENGTH);
if (pNext == pPull) pPull = incrementPushPullPointer(pPull, buffer, BUFFER_LENGTH);
//Add the character at the push position
- *pPush = c;
+ char h = c >> 4;
+ if (h < 10) h += '0';
+ else h += 'A' - 10;
+ *pPush = h;
pPush = incrementPushPullPointer(pPush, buffer, BUFFER_LENGTH);
+
+ //Move the pull position if about to run into it
+ pNext = incrementPushPullPointer(pPush, buffer, BUFFER_LENGTH);
+ if (pNext == pPull) pPull = incrementPushPullPointer(pPull, buffer, BUFFER_LENGTH);
+
+ //Add the character at the push position
+ h = c & 0x0F;
+ if (h < 10) h += '0';
+ else h += 'A' - 10;
+ *pPush = h;
+ pPush = incrementPushPullPointer(pPush, buffer, BUFFER_LENGTH);
+
}
static char *pEnumerate;
-static int hadNull;
void LogEnumerateStart()
{
pEnumerate = pPull;
- hadNull = false;
}
int LogEnumerate()
{
- if (hadNull)
- {
- hadNull = false;
- return '0';
- }
if (pEnumerate == pPush) return EOF;
char c = *pEnumerate;
pEnumerate = incrementPushPullPointer(pEnumerate, buffer, BUFFER_LENGTH);
- if (c)
- {
- return c;
- }
- else
- {
- hadNull = true;
- return '\\';
- }
+ return c;
}
void LogEnable(int on)
{