Important Update:

- LogCore:
  - Removed global DebugLevel var, now passed as parameter
  - Implemented binary output values
- FunctionCore, SelectCore and SelectableCore:
  - internal DebugLevel param implemented
  - new internal DisplayOutput param (Normal/Hex/Bin)
- BufferCore:
  - Bug fix: allow for empty search string/marker
This commit is contained in:
Charl Wentzel
2016-06-09 06:53:09 +02:00
parent 13b0a4736c
commit b418fa73e0
9 changed files with 115 additions and 101 deletions

View File

@@ -18,12 +18,11 @@
//---------------------------------------------------------------------------
// Global vars
EDebugLevel DebugLevel = dlLow;
char LogStr[1000]; // Temporary var to create log messages, globally available to save on memory operations
//---------------------------------------------------------------------------
bool LogMessage( EDebugLevel Level, const char * Format, ... )
bool LogMessage( EDebugLevel DebugLevel, EDebugLevel MsgLevel, const char * Format, ... )
{
va_list ArgPtr;
@@ -32,7 +31,7 @@ bool LogMessage( EDebugLevel Level, const char * Format, ... )
return false;
// Check debug level
if (Level > DebugLevel) {
if (MsgLevel > DebugLevel) {
return true;
}
@@ -45,18 +44,18 @@ bool LogMessage( EDebugLevel Level, const char * Format, ... )
}
//---------------------------------------------------------------------------
bool ShowOutput( EDebugLevel Level, const short Show, const char * Buffer, int Len, const char * Format, ... )
bool ShowOutput( EDebugLevel DebugLevel, EDebugLevel MsgLevel, const short Show, const char * Buffer, int Len, const char * Format, ... )
{
va_list ArgPtr;
// Validate values
if (!Buffer || !(Show & (OUT_HEX | OUT_NORMAL)))
if (!Buffer || !(Show & (OUT_NORMAL | OUT_HEX | OUT_BIN)))
return false;
if (Len == -1)
Len = strlen( Buffer );
// Check debug level
if (Level > DebugLevel) {
if (MsgLevel > DebugLevel) {
return true;
}
@@ -68,15 +67,7 @@ bool ShowOutput( EDebugLevel Level, const short Show, const char * Buffer, int L
}
printf( "[%d] ", Len );
// Show Hex output
if (Show & OUT_HEX) {
for (int i=0; i<Len; i++) {
printf( "%02X ", Buffer[i] );
}
printf( "\n" );
}
// Show normal output
// Show Normal output
if (Show & OUT_NORMAL) {
if (Show & OUT_ASIS) {
printf( "%s", Buffer );
@@ -98,6 +89,24 @@ bool ShowOutput( EDebugLevel Level, const short Show, const char * Buffer, int L
printf( "\n" );
}
}
// Show Hex output
if (Show & OUT_HEX) {
for (int i=0; i<Len; i++) {
printf( "%02X ", (unsigned char)Buffer[i] );
}
printf( "\n" );
}
// Show Binary output
if (Show & OUT_BIN) {
for (int i=0; i<Len; i++) {
for (int j=0; j<8; j++) {
printf( "%d", (bool)((Buffer[i] << j) & 0x80) );
}
}
printf( "\n" );
}
return true;
}
//---------------------------------------------------------------------------