Minor Update:
- BufferCore: - Method WriteToFD should ignore EAGAIN - LogCore: - Add OUT_COUNT output bit (show total output bytes) - SelectableCore: - Add Force param on WriteToFD, ignore EAGAIN if !Force
This commit is contained in:
32
LogCore.cpp
32
LogCore.cpp
@@ -49,30 +49,46 @@ bool ShowOutput( EDebugLevel DebugLevel, EDebugLevel MsgLevel, const short Show,
|
||||
va_list ArgPtr;
|
||||
|
||||
// Validate values
|
||||
if (!Buffer || !(Show & (OUT_NORMAL | OUT_HEX | OUT_BIN)))
|
||||
if (!Buffer || !(Show & (OUT_COUNT |OUT_NORMAL | OUT_HEX | OUT_BIN)))
|
||||
return false;
|
||||
if (Len == -1)
|
||||
Len = strlen( Buffer );
|
||||
|
||||
// Check debug level
|
||||
if (MsgLevel > DebugLevel) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get length
|
||||
if (Len == -1)
|
||||
Len = strlen( Buffer );
|
||||
|
||||
// Show Lead
|
||||
if (Format && *Format) {
|
||||
va_start( ArgPtr, Format );
|
||||
vprintf( Format, ArgPtr );
|
||||
va_end( ArgPtr );
|
||||
}
|
||||
printf( "[%d] ", Len );
|
||||
|
||||
// Show byte count
|
||||
if (Show & OUT_COUNT)
|
||||
{
|
||||
// Print byte count
|
||||
printf( " [%d] ", Len );
|
||||
|
||||
// EOL if only count wanted
|
||||
if (Show & OUT_COUNT) {
|
||||
printf( "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
// Show Normal output
|
||||
if (Show & OUT_NORMAL) {
|
||||
if (Show & OUT_NORMAL)
|
||||
{
|
||||
if (Show & OUT_ASIS) {
|
||||
// Print entire buffer as is (line feeds included)
|
||||
printf( "%s", Buffer );
|
||||
}
|
||||
else {
|
||||
// Ignore \r\n
|
||||
for (int i=0; i<Len; i++) {
|
||||
if ((Buffer[i] < 32) || (Buffer[i] > 126)) {
|
||||
if ((Show & OUT_CRLF) && ((Buffer[i] == '\r') || (Buffer[i] == '\n')))
|
||||
@@ -85,13 +101,16 @@ bool ShowOutput( EDebugLevel DebugLevel, EDebugLevel MsgLevel, const short Show,
|
||||
}
|
||||
}
|
||||
}
|
||||
// Add EOL if not present or ignored
|
||||
if (!(Show & (OUT_ASIS | OUT_CRLF)) || (Buffer[Len-1] != '\n')) {
|
||||
printf( "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
// Show Hex output
|
||||
if (Show & OUT_HEX) {
|
||||
if (Show & OUT_HEX)
|
||||
{
|
||||
// Print Hex values of individual bytes
|
||||
for (int i=0; i<Len; i++) {
|
||||
printf( "%02X ", (unsigned char)Buffer[i] );
|
||||
}
|
||||
@@ -100,6 +119,7 @@ bool ShowOutput( EDebugLevel DebugLevel, EDebugLevel MsgLevel, const short Show,
|
||||
|
||||
// Show Binary output
|
||||
if (Show & OUT_BIN) {
|
||||
// Print each byte as 8-bit binary
|
||||
for (int i=0; i<Len; i++) {
|
||||
for (int j=0; j<8; j++) {
|
||||
printf( "%d", (bool)((Buffer[i] << j) & 0x80) );
|
||||
|
||||
Reference in New Issue
Block a user