Replace uartPrintf() with uartPutInteger() and ...HexByte() because WTF everything is broken
This commit is contained in:
parent
201b1db6a6
commit
07e5b74e83
|
|
@ -21,7 +21,7 @@ void executeCommand(CommandLine cmdLine) {
|
|||
}
|
||||
else if (strcmp(cmdLine.command, "HELP") == 0) {
|
||||
// HELP command: Print a list of supported commands.
|
||||
commandHelp(cmdLine.arg);
|
||||
commandHelp();
|
||||
}
|
||||
else if (strcmp(cmdLine.command, "READ") == 0) {
|
||||
// READ command: Takes a hex address range (or single address) as argument,
|
||||
|
|
@ -123,10 +123,13 @@ void commandRead(char* arg) {
|
|||
}
|
||||
} else {
|
||||
// Fancy ASCII output
|
||||
uartPrintf("<%d>", buffer.bytes);
|
||||
uartPutChar('<');
|
||||
uartPutInteger(buffer.bytes);
|
||||
uartPutChar('>');
|
||||
|
||||
for (int i = 0; i < buffer.bytes; i++) {
|
||||
uartPrintf(" %02X", buffer.data[i]);
|
||||
uartPutChar(' ');
|
||||
uartPutHexByte(buffer.data[i]);
|
||||
}
|
||||
uartPutLine(NULL);
|
||||
}
|
||||
|
|
@ -163,8 +166,10 @@ void commandErase() {
|
|||
void commandTestRead() {
|
||||
eepromSetReadMode();
|
||||
|
||||
for (int i = 0x00; i < 0x20; i++) {
|
||||
uartPrintf("TESTREAD 0x%02X: ", i);
|
||||
for (uint8_t i = 0x00; i < 0x20; i++) {
|
||||
uartPutString("TESTREAD 0x");
|
||||
uartPutHexByte(i);
|
||||
uartPutString(": ");
|
||||
|
||||
uint8_t byte = eepromReadByte(i);
|
||||
|
||||
|
|
@ -174,7 +179,9 @@ void commandTestRead() {
|
|||
uartPutChar('?');
|
||||
}
|
||||
|
||||
uartPrintf(" (0x%02X)\n");
|
||||
uartPutString(" (0x");
|
||||
uartPutHexByte(byte);
|
||||
uartPutLine(")");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,17 +56,18 @@ void uartPutLine(char* data) {
|
|||
uartPutChar('\n');
|
||||
}
|
||||
|
||||
// Transmit a sprintf formatted string (maximum buffer: 256 bytes!)
|
||||
void uartPrintf(const char* format, ...) {
|
||||
char outBuffer[256];
|
||||
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
vsprintf(outBuffer, format, args);
|
||||
// Convert an integer to decimal ASCII and transmit
|
||||
void uartPutInteger(int value) {
|
||||
char outBuffer[32];
|
||||
snprintf(outBuffer, 32, "%d", value);
|
||||
uartPutString(outBuffer);
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
// Convert a byte to hexadecimal ASCII and transmit
|
||||
void uartPutHexByte(uint8_t byte) {
|
||||
char outBuffer[8];
|
||||
snprintf(outBuffer, 8, "%02hhX", byte);
|
||||
uartPutString(outBuffer);
|
||||
}
|
||||
|
||||
// Receive a single character (blocking)
|
||||
|
|
|
|||
|
|
@ -16,8 +16,11 @@ void uartPutString(char* data);
|
|||
// Transmit a string followed by a line break
|
||||
void uartPutLine(char* data);
|
||||
|
||||
// Transmit a sprintf formatted string (maximum buffer: 256 bytes!)
|
||||
void uartPrintf(const char* format, ...);
|
||||
// Convert an integer to decimal ASCII and transmit
|
||||
void uartPutInteger(int value);
|
||||
|
||||
// Convert a byte to hexadecimal ASCII and transmit
|
||||
void uartPutHexByte(uint8_t byte);
|
||||
|
||||
// Read a single character (blocking)
|
||||
unsigned char uartGetChar();
|
||||
|
|
|
|||
Loading…
Reference in New Issue