Add additional diagnostic commands.

You can connect via the serial monitor and send ‘?’ to get a list of
commands available.  This allows some diagnostics when the board isn’t
working with the OLS client.
Sending ‘4’ does a 4MHz capture and ‘2’ dumbs the data buffer for
example.  Recommended to use this with the simulated signal via a
timer.  See the bottom of the setup() function and change the ‘#if 0’
to ‘#if 1’ to enable it.
Also, fix a long standing bug that broke 2MHz captures and the
ATmega168. (improper #if defined check)
This commit is contained in:
Andrew Gillham
2015-02-07 12:17:24 -08:00
parent d0afee13d2
commit 9a065516e2
4 changed files with 117 additions and 42 deletions

2
README
View File

@@ -69,5 +69,5 @@ NOTE: This master branch now supports Arduino 1.0 only.
Checkout branch logic_analyzer_v0_5 for Arduino 22 support. Checkout branch logic_analyzer_v0_5 for Arduino 22 support.
Release: v0.12 September 6, 2013. Release: v0.13 February 7, 2015.

View File

@@ -2,7 +2,7 @@
* *
* SUMP Protocol Implementation for Arduino boards. * SUMP Protocol Implementation for Arduino boards.
* *
* Copyright (c) 2011,2012,2013,2014 Andrew Gillham * Copyright (c) 2011,2012,2013,2014,2015 Andrew Gillham
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -62,7 +62,7 @@
* until after the trigger fires. * until after the trigger fires.
* Please try it out and report back. * Please try it out and report back.
* *
* Release: v0.12 September 6, 2013. * Release: v0.13 February 7, 2015.
* *
*/ */
@@ -81,6 +81,7 @@ void blinkled(void);
void get_metadata(void); void get_metadata(void);
void debugprint(void); void debugprint(void);
void debugdump(void); void debugdump(void);
void prettydump(void);
/* /*
@@ -170,7 +171,7 @@ void debugdump(void);
#define DEBUG_ENABLE DDRD = DDRD | B10000000 #define DEBUG_ENABLE DDRD = DDRD | B10000000
#define DEBUG_ON PORTD = B10000000 #define DEBUG_ON PORTD = B10000000
#define DEBUG_OFF PORTD = B00000000 #define DEBUG_OFF PORTD = B00000000
#endif #endif /* USE_PORTD */
#define DEBUG #define DEBUG
#ifdef DEBUG #ifdef DEBUG
#define MAX_CAPTURE_SIZE DEBUG_CAPTURE_SIZE #define MAX_CAPTURE_SIZE DEBUG_CAPTURE_SIZE
@@ -263,7 +264,7 @@ void loop()
if (Serial.available() > 0) { if (Serial.available() > 0) {
cmdByte = Serial.read(); cmdByte = Serial.read();
switch(cmdByte) { switch (cmdByte) {
case SUMP_RESET: case SUMP_RESET:
/* /*
* We don't do anything here as some unsupported extended commands have * We don't do anything here as some unsupported extended commands have
@@ -299,7 +300,7 @@ void loop()
} }
else if (divider == 49) { else if (divider == 49) {
/* 2.0MHz */ /* 2.0MHz */
#if defined(__AVR_ATmega168P__) #if !defined(__AVR_ATmega168__)
captureInline2mhz(); captureInline2mhz();
#endif #endif
} }
@@ -394,13 +395,23 @@ void loop()
/* /*
* a couple of debug commands used during development. * a couple of debug commands used during development.
*/ */
case '?':
Serial.println("");
Serial.println("0 = clear cmd buffer");
Serial.println("1 = print cmd buffer");
Serial.println("2 = print data buffer");
Serial.println("3 = pretty print buffer");
Serial.println("4 = capture at 4MHz");
Serial.println("5 = capture at 1MHz");
Serial.println("6 = capture at 500KHz");
break;
case '0': case '0':
/* /*
* This resets the debug buffer pointer, effectively clearing the * This resets the debug buffer pointer, effectively clearing the
* previous commands out of the buffer. Clear the sample data as well. * previous commands out of the buffer. Clear the sample data as well.
* Just send a '0' from the Arduino IDE's Serial Monitor. * Just send a '0' from the Arduino IDE's Serial Monitor.
*/ */
savecount=0; savecount = 0;
for (i = 0 ; i < MAX_CAPTURE_SIZE; i++) { for (i = 0 ; i < MAX_CAPTURE_SIZE; i++) {
logicdata[i] = 0; logicdata[i] = 0;
} }
@@ -416,10 +427,44 @@ void loop()
break; break;
case '2': case '2':
/* /*
* This dumps the sample data to the serial port. Used for debugging. * This dumps the sample data to the serial port.
*/ */
debugdump(); debugdump();
break; break;
case '3':
/*
* Prints a visual representation of the data buffer.
*/
prettydump();
break;
case '4':
/*
* This runs a sample capture at 4MHz.
*/
captureInline4mhz();
Serial.println("");
Serial.println("4MHz capture done.");
break;
case '5':
/*
* This runs a sample capture at 1MHz.
* delayTime = 1ms for 1MHz sampling.
*/
delayTime = 1;
captureMicro();
Serial.println("");
Serial.println("1MHz capture done.");
break;
case '6':
/*
* This runs a sample capture at 500KHz.
* delayTime = 2ms for 500KHz.
*/
delayTime = 1;
captureMicro();
Serial.println("");
Serial.println("500KHz capture done.");
break;
#endif /* DEBUG */ #endif /* DEBUG */
default: default:
/* ignore any unrecognized bytes. */ /* ignore any unrecognized bytes. */
@@ -595,7 +640,7 @@ void captureMicro() {
void captureMilli() { void captureMilli() {
unsigned int i = 0; unsigned int i = 0;
if(rleEnabled) { if (rleEnabled) {
/* /*
* very basic trigger, just like in captureMicros() above. * very basic trigger, just like in captureMicros() above.
*/ */
@@ -606,16 +651,16 @@ void captureMilli() {
byte lastSample = 0; byte lastSample = 0;
byte sampleCount = 0; byte sampleCount = 0;
while(i < readCount) { while (i < readCount) {
/* /*
* Implementation of the RLE unlimited protocol: timings might be off a little * Implementation of the RLE unlimited protocol: timings might be off a little
*/ */
if(lastSample == (CHANPIN & B01111111) && sampleCount < 127) { if (lastSample == (CHANPIN & B01111111) && sampleCount < 127) {
sampleCount++; sampleCount++;
delay(delayTime); delay(delayTime);
continue; continue;
} }
if(sampleCount != 0) { if (sampleCount != 0) {
logicdata[i] = B10000000 | sampleCount; logicdata[i] = B10000000 | sampleCount;
sampleCount = 0; sampleCount = 0;
i++; i++;
@@ -893,7 +938,7 @@ void get_metadata() {
Serial.write('0'); Serial.write('0');
Serial.write('.'); Serial.write('.');
Serial.write('1'); Serial.write('1');
Serial.write('2'); Serial.write('3');
Serial.write((uint8_t)0x00); Serial.write((uint8_t)0x00);
/* sample memory */ /* sample memory */
@@ -942,7 +987,7 @@ void get_metadata() {
} }
/* /*
* This is used by the '0' debug command to dump the contents of some * This is used by the '1' debug command to dump the contents of some
* interesting variables and the debug buffer. * interesting variables and the debug buffer.
* *
*/ */
@@ -1007,6 +1052,35 @@ void debugdump() {
j++; j++;
} }
} }
/*
* This is used by the '3' debugs command to dump the first 64 bytes
* of the sample buffer.
* It prints the data in a graphical representation.
*/
void prettydump() {
int i;
byte j;
byte k;
Serial.print("\r\n");
for (i = 0 ; i < 64; i++) {
#ifdef USE_PORTD
k = logicdata[i] >> 2;
#else
k = logicdata[i];
#endif
for (j = 0; j < 8; j++) {
if (k & 0x01)
Serial.print("| ");
else
Serial.print(" |");
k = k >> 1;
}
Serial.print("\r\n");
}
}
#endif /* DEBUG */ #endif /* DEBUG */
@@ -1019,3 +1093,4 @@ void debugdump() {

View File

@@ -2,7 +2,7 @@
* *
* SUMP Protocol Implementation for Arduino boards. * SUMP Protocol Implementation for Arduino boards.
* *
* Copyright (c) 2011,2012,2013 Andrew Gillham * Copyright (c) 2011,2012,2013,2014,2015 Andrew Gillham
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -2,7 +2,7 @@
* *
* SUMP Protocol Implementation for Arduino boards. * SUMP Protocol Implementation for Arduino boards.
* *
* Copyright (c) 2011,2012,2013 Andrew Gillham * Copyright (c) 2011,2012,2013,2014,2015 Andrew Gillham
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without