Skip to content

Commit

Permalink
Remove TPIU from client utilities and test
Browse files Browse the repository at this point in the history
  • Loading branch information
mubes committed Sep 2, 2024
1 parent 99b1cb2 commit ee24c89
Show file tree
Hide file tree
Showing 17 changed files with 195 additions and 686 deletions.
6 changes: 3 additions & 3 deletions Inc/nw.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ extern "C" {

// ====================================================================================================

#define OTCLIENT_SERVER_PORT (3402) /* ORBTrace COBS server port definition */
#define NWCLIENT_SERVER_PORT (3443) /* Server port definition */
#define LEGACY_SERVER_PORT_OFS (NWCLIENT_SERVER_PORT-OTCLIENT_SERVER_PORT)
#define OFCLIENT_SERVER_PORT (3402) /* orbflow server port definition */
#define NWCLIENT_SERVER_PORT (3443) /* legacy server port definition */
#define LEGACY_SERVER_PORT_OFS (NWCLIENT_SERVER_PORT-OFCLIENT_SERVER_PORT)

#define TRANSFER_SIZE (65536*4)

Expand Down
1 change: 1 addition & 0 deletions Inc/oflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct OFLOW
bool selfAllocated; /* Flag indicating that memory was allocated by the library */
struct COBS c;
struct OFLOWFrame f;
uint64_t perror;

/* Materials for callback */
void ( *cb )( struct OFLOWFrame *p, void *param );
Expand Down
9 changes: 3 additions & 6 deletions Inc/tpiuDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,15 @@ struct TPIUPacket
};

// ====================================================================================================
/* LEGACY */ bool TPIUGetPacket( struct TPIUDecoder *t, struct TPIUPacket *p );
/* LEGACY */ enum TPIUPumpEvent TPIUPump( struct TPIUDecoder *t, uint8_t d );

void TPIUDecoderForceSync( struct TPIUDecoder *t, uint8_t offset );
void TPIUDecoderZeroStats( struct TPIUDecoder *t );
bool TPIUDecoderSynced( struct TPIUDecoder *t );
struct TPIUDecoderStats *TPIUDecoderGetStats( struct TPIUDecoder *t );
struct TPIUCommsStats *TPIUGetCommsStats( struct TPIUDecoder *t );

void TPIUPump2( struct TPIUDecoder *t, uint8_t *frame, int len,
void ( *packetRxed )( enum TPIUPumpEvent e, struct TPIUPacket *p, void *param ),
void *param );
void TPIUPump( struct TPIUDecoder *t, uint8_t *frame, int len,
void ( *packetRxed )( enum TPIUPumpEvent e, struct TPIUPacket *p, void *param ),
void *param );

struct TPIUDecoder *TPIUDecoderCreate( void );
void TPIUDecoderInit( struct TPIUDecoder *t );
Expand Down
2 changes: 2 additions & 0 deletions Inc/uicolours_default.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#define C_SUPPORT2 C_LCYAN /* Output data secondary value alternate */
#define C_CONTEXT C_CYAN /* Context (e.g. units) for output data value */

#define C_TSTAMP C_YELLOW /* Colour stamp in orbcat output */

#define C_VERB_ERROR C_LRED /* Verbal level error */
#define C_VERB_WARN C_YELLOW /* Verbal level warning */
#define C_VERB_INFO C_LCYAN /* Verbal level info */
Expand Down
2 changes: 1 addition & 1 deletion Src/itmfifos.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ static void _OFLOWpacketRxed ( struct OFLOWFrame *p, void *param )

if ( !p->good )
{
genericsReport( V_WARN, "Bad packet received" EOL );
genericsReport( V_INFO, "Bad packet received" EOL );
}
else
{
Expand Down
36 changes: 22 additions & 14 deletions Src/oflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,32 @@ static void _pumpcb( struct Frame *p, void *param )
/* Callback function when a COBS packet is complete */
struct OFLOW *t = ( struct OFLOW * )param;

t->f.len = p->len - 2; /* OFLOW frames have the first element representing the tag and last element the checksum */
t->f.tag = p->d[0]; /* First byte of an OFLOW frame is the tag */
t->f.sum = p->d[p->len - 1]; /* Last byte of an OFLOW frame is the sum */
t->f.d = &p->d[1]; /* This is the rest of the data */

/* Calculate received packet sum and insert good status into packet */
uint8_t sum = t->f.tag;

for ( int i = 0; i < t->f.len; i++ )
if ( p->len < 2 )
{
sum += t->f.d[i];
t->perror++;
}
else
{
t->f.len = p->len - 2; /* OFLOW frames have the first element representing the tag and last element the checksum */
t->f.tag = p->d[0]; /* First byte of an OFLOW frame is the tag */
t->f.sum = p->d[p->len - 1]; /* Last byte of an OFLOW frame is the sum */
t->f.d = &p->d[1]; /* This is the rest of the data */

sum += t->f.sum;
t->f.good = ( sum == 0 );
/* Calculate received packet sum and insert good status into packet */
uint8_t sum = t->f.tag;

/* Timestamp was already set for this cluster */
( t->cb )( &t->f, t->param );
for ( int i = 0; i < t->f.len; i++ )
{
sum += t->f.d[i];
}

sum += t->f.sum;
t->f.good = ( sum == 0 );
t->perror += !( t->f.good );

/* Timestamp was already set for this cluster */
( t->cb )( &t->f, t->param );
}
}

void OFLOWPump( struct OFLOW *t, const uint8_t *incoming, int len,
Expand Down
94 changes: 51 additions & 43 deletions Src/orbcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@
#define DEFAULT_TS_TRIGGER '\n' /* Default trigger character for timestamp output */

#define MSG_REORDER_BUFLEN (10) /* Maximum number of samples to re-order for timekeeping */
#define ONE_SEC_IN_USEC (1000000) /* Used for time conversions...usec in one sec */
#define ONE_SEC_IN_USEC (1000000L) /* Used for time conversions...usec in one sec */

/* Formats for timestamping */
#define REL_FORMAT "%6" PRIu64 ".%01" PRIu64 "|"
#define REL_FORMAT_INIT " Initial|"
#define DEL_FORMAT "%3" PRIu64 ".%03" PRIu64 "|"
#define DEL_FORMAT_CTD " +|"
#define DEL_FORMAT_INIT "Initial|"
#define REL_FORMAT C_TSTAMP "%6" PRIu64 ".%03" PRIu64 "|" C_RESET
#define REL_FORMAT_INIT C_TSTAMP " R-Initial|" C_RESET
#define DEL_FORMAT C_TSTAMP "%5" PRIu64 ".%03" PRIu64 "|" C_RESET
#define DEL_FORMAT_CTD C_TSTAMP " +|" C_RESET
#define DEL_FORMAT_INIT C_TSTAMP "D-Initial|" C_RESET
#define ABS_FORMAT_TM "%d/%b/%y %H:%M:%S"
#define ABS_FORMAT "%s.%03" PRIu64" |"
#define STAMP_FORMAT "%12" PRIu64 "|"
#define STAMP_FORMAT_MS "%8" PRIu64 ".%03" PRIu64 "_%03" PRIu64 "|"
#define STAMP_FORMAT_MS_DELTA "%5" PRIu64 ".%03" PRIu64 "_%03" PRIu64 "|"
#define ABS_FORMAT C_TSTAMP "%s.%03" PRIu64"|" C_RESET
#define STAMP_FORMAT C_TSTAMP "%12" PRIu64 "|" C_RESET
#define STAMP_FORMAT_MS C_TSTAMP "%8" PRIu64 ".%03" PRIu64 "_%03" PRIu64 "|" C_RESET
#define STAMP_FORMAT_MS_DELTA C_TSTAMP "%5" PRIu64 ".%03" PRIu64 "_%03" PRIu64 "|" C_RESET

enum TSType { TSNone, TSAbsolute, TSRelative, TSDelta, TSStamp, TSStampDelta, TSNumTypes };

Expand All @@ -66,7 +66,7 @@ struct
enum TSType tsType;
char *tsLineFormat;
char tsTrigger;

bool mono; /* Supress colour in output */

/* Sink information */
char *presFormat[NUM_CHANNELS + 1]; /* Format string for each channel */
Expand All @@ -83,7 +83,7 @@ struct
{
.forceITMSync = true,
.tag = 1,
.port = OTCLIENT_SERVER_PORT,
.port = OFCLIENT_SERVER_PORT,
.server = "localhost",
.tsTrigger = DEFAULT_TS_TRIGGER
};
Expand Down Expand Up @@ -112,7 +112,7 @@ struct
#define DWT_TO_US (100000L)

// ====================================================================================================
int64_t _timestamp( void )
uint64_t _timestamp( void )

{
struct timeval te;
Expand Down Expand Up @@ -152,7 +152,7 @@ static void _printTimestamp( char *strstore )
}
else
{
res = _r.oldte - _timestamp();
res = _timestamp() - _r.oldte;
sprintf( strstore, REL_FORMAT, res / ONE_SEC_IN_USEC, ( res / ( ONE_SEC_IN_USEC / 1000 ) ) % 1000 );
}

Expand Down Expand Up @@ -246,7 +246,7 @@ static void _outputText( char *p )
if ( !_r.inLine )
{
_printTimestamp( opConstruct );
fputs( opConstruct, stdout );
genericsPrintf( "%s", opConstruct );
_r.inLine = true;
}

Expand All @@ -256,21 +256,21 @@ static void _outputText( char *p )
if ( q )
{
*q = 0;
fprintf( stdout, "%s" EOL, p );
genericsPrintf( "%s" EOL, p );
/* Once we've output these data then we're not in a line any more */
_r.inLine = false;

/* ...and if there were any DWT messages to print we'd better output those */
if ( _r.dwtText[0] )
{
fprintf( stdout, "%s" EOL, _r.dwtText );
genericsPrintf( "%s" EOL, _r.dwtText );
_r.dwtText[0] = 0;
}
}
else
{
/* Just output the whole of the data we've got, then we're done */
fputs( p, stdout );
genericsPrintf( "%s", p );
break;
}

Expand All @@ -296,7 +296,7 @@ void _expex( const char *fmt, ... )
/* See if we exceeded max length...if so then output what we have and start a fresh buffer */
if ( MAX_STRING_LENGTH - strlen( _r.dwtText ) < 100 )
{
fputs( _r.dwtText, stdout );
genericsPrintf( "%s", _r.dwtText );
_r.dwtText[0] = 0;
}

Expand All @@ -310,7 +310,7 @@ void _expex( const char *fmt, ... )

if ( !_r.inLine )
{
fputs( _r.dwtText, stdout );
genericsPrintf( "%s", _r.dwtText );
_r.dwtText[0] = 0;
}
}
Expand Down Expand Up @@ -549,24 +549,24 @@ static void _itmPumpProcess( char c )
static void _printHelp( const char *const progName )

{
fprintf( stdout, "Usage: %s [options]" EOL, progName );
fprintf( stdout, " -c, --channel: <Number>,<Format> of channel to add into output stream (repeat per channel)" EOL );
fprintf( stdout, " -C, --cpufreq: <Frequency in KHz> (Scaled) speed of the CPU" EOL
" generally /1, /4, /16 or /64 of the real CPU speed," EOL );
fprintf( stdout, " -E, --eof: Terminate when the file/socket ends/is closed, or wait for more/reconnect" EOL );
fprintf( stdout, " -f, --input-file: <filename> Take input from specified file" EOL );
fprintf( stdout, " -g, --trigger: <char> to use to trigger timestamp (default is newline)" EOL );
fprintf( stdout, " -h, --help: This help" EOL );
fprintf( stdout, " -n, --itm-sync: Enforce sync requirement for ITM (i.e. ITM needs to issue syncs)" EOL );
fprintf( stdout, " -p, --protocol: Protocol to communicate. Defaults to OFLOW if -s is not set, otherwise ITM" EOL );
fprintf( stdout, " -s, --server: <Server>:<Port> to use" EOL );
fprintf( stdout, " -t, --tag: <stream>: Which orbflow tag to use (normally 1)" EOL );
fprintf( stdout, " -T, --timestamp: <a|r|d|s|t>: Add absolute, relative (to session start)," EOL
" delta, system timestamp or system timestamp delta to output. Note" EOL
" a,r & d are host dependent and you may need to run orbuculum with -H." EOL );
fprintf( stdout, " -v, --verbose: <level> Verbose mode 0(errors)..3(debug)" EOL );
fprintf( stdout, " -V, --version: Print version and exit" EOL );
fprintf( stdout, " -x, --exceptions: Include exception information in output, in time order" EOL );
genericsPrintf( "Usage: %s [options]" EOL, progName );
genericsPrintf( " -c, --channel: <Number>,<Format> of channel to add into output stream (repeat per channel)" EOL );
genericsPrintf( " -C, --cpufreq: <Frequency in KHz> (Scaled) speed of the CPU" EOL
" generally /1, /4, /16 or /64 of the real CPU speed," EOL );
genericsPrintf( " -E, --eof: Terminate when the file/socket ends/is closed, or wait for more/reconnect" EOL );
genericsPrintf( " -f, --input-file: <filename> Take input from specified file" EOL );
genericsPrintf( " -g, --trigger: <char> to use to trigger timestamp (default is newline)" EOL );
genericsPrintf( " -h, --help: This help" EOL );
genericsPrintf( " -n, --itm-sync: Enforce sync requirement for ITM (i.e. ITM needs to issue syncs)" EOL );
genericsPrintf( " -p, --protocol: Protocol to communicate. Defaults to OFLOW if -s is not set, otherwise ITM" EOL );
genericsPrintf( " -s, --server: <Server>:<Port> to use" EOL );
genericsPrintf( " -t, --tag: <stream>: Which orbflow tag to use (normally 1)" EOL );
genericsPrintf( " -T, --timestamp: <a|r|d|s|t>: Add absolute, relative (to session start)," EOL
" delta, system timestamp or system timestamp delta to output. Note" EOL
" the accuracy of a,r & d are host dependent." EOL );
genericsPrintf( " -v, --verbose: <level> Verbose mode 0(errors)..3(debug)" EOL );
genericsPrintf( " -V, --version: Print version and exit" EOL );
genericsPrintf( " -x, --exceptions: Include exception information in output, in time order" EOL );
}
// ====================================================================================================
static void _printVersion( void )
Expand All @@ -584,6 +584,8 @@ static struct option _longOptions[] =
{"help", no_argument, NULL, 'h'},
{"trigger", required_argument, NULL, 'g' },
{"itm-sync", no_argument, NULL, 'n'},
{"no-colour", no_argument, NULL, 'M'},
{"no-color", no_argument, NULL, 'M'},
{"protocol", required_argument, NULL, 'p'},
{"server", required_argument, NULL, 's'},
{"tag", required_argument, NULL, 't'},
Expand All @@ -606,7 +608,7 @@ bool _processOptions( int argc, char *argv[] )

#define DELIMITER ','

while ( ( c = getopt_long ( argc, argv, "c:C:Ef:g:hVnp:s:t:T:v:x", _longOptions, &optionIndex ) ) != -1 )
while ( ( c = getopt_long ( argc, argv, "c:C:Ef:g:hVnMp:s:t:T:v:x", _longOptions, &optionIndex ) ) != -1 )
switch ( c )
{
// ------------------------------------
Expand Down Expand Up @@ -651,6 +653,11 @@ bool _processOptions( int argc, char *argv[] )
options.forceITMSync = false;
break;

// ------------------------------------
case 'M':
options.mono = true;
break;

// ------------------------------------

case 'p':
Expand Down Expand Up @@ -920,7 +927,7 @@ static void _OFLOWpacketRxed ( struct OFLOWFrame *p, void *param )
{
if ( !p->good )
{
genericsReport( V_WARN, "Bad packet received" EOL );
genericsReport( V_INFO, "Bad packet received" EOL );
}
else
{
Expand Down Expand Up @@ -982,8 +989,7 @@ static void _feedStream( struct Stream *stream )
/* Check if an exception report timed out */
if ( ( _r.inLine ) && _r.dwtText[0] && ( _timestamp() - _r.dwtte > DWT_TO_US ) )
{
fputs( EOL, stdout );
fputs( _r.dwtText, stdout );
genericsPrintf( EOL "%s", _r.dwtText );
_r.dwtText[0] = 0;
_r.inLine = false;
}
Expand Down Expand Up @@ -1011,6 +1017,8 @@ int main( int argc, char *argv[] )
exit( -1 );
}

genericsScreenHandling( !options.mono );

/* Reset the handlers before we start */
ITMDecoderInit( &_r.i, options.forceITMSync );
OFLOWInit( &_r.c );
Expand Down Expand Up @@ -1052,7 +1060,7 @@ int main( int argc, char *argv[] )
break;
}

/* Checking every 100ms for a connection is quite often enough */
/* Checking every 10ms for a connection is quite often enough */
usleep( 10000 );
}

Expand Down
Loading

0 comments on commit ee24c89

Please sign in to comment.