I have made some progress now on where I wanted to reroute the digitalRead, digitalWrite and pinMode functions. And it threatens to work
Here you see the blink program with one include for a library. But instead of blinking it actually sends the output to the Serial in CSV format.
A normal program blink has only the AutoTest.h include to enable Autotesting. comment it out and you have the original program (still have to fixe something for the Serial though)
#include <AutoTest.h>
void setup()
{
Serial.begin(9600); // BAUDRATE
pinMode(BLINK, OUTPUT); // output pin 1
}
void loop()
{
delay (1000); // wait on second
//
// Read output, toggle it and Write output
//
digitalWrite(BLINK, !digitalRead(BLINK) );
}
AutoTest.h includes a file called testcases.h (might change this in the future). Sill a lot of fancy making to do on that one
/**
* testcases.h
*
* Created on : 27 aug. 2013
* Author : Nico Verduin
* Email : info@verelec.com
* Website : www.verelec.nl
*
* Testcases.h contains all the testcases to be performed after startup
* All tescases are stored in PROGMEM to avoid using sRAM. Only the current case is always copied to SRAM.
*
* Revision Control
*
* Latest Revsion
* ____________________
*
* Revision : $Revision$
* Date : $Date$
* Author : $Author$
*
*/
#ifndef TESTCASES_H
#define TESTCASES_H
#include "Arduino.h"
#include <avr/pgmspace.h>
// ********************************************************************************************************
// to avoid stupid warning : warning: only initialized variables can be placed into program memory area
//
// Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734
#ifdef PROGMEM
#undef PROGMEM
#define PROGMEM __attribute__((section(".progmem.data")))
#endif
//
// end avoidance
// ********************************************************************************************************
/*
* descriptions of pins
* 2 column array where column 0 contains the pin number and column 1 contains the description
* Actual input/output settings are determined at pinMode() function
*/
#define BLINK 5
struct pinDescription {
byte pin; // pin as described on board
char description[11]; // name given to pin for output to CSV on serial. Max of 9 characters. Can be modified
};
//
// keep the pin descriptions local in DATA for now
//
static pinDescription pinDesc[] = { { 3, "input 1" },
{ 4, "input 3" },
{ BLINK, "Blink" },
{ 255, "" } // table terminator
};
/*
* Actual testcases
*/
/*
* description of a single testcase
*/
struct testCase {
char description[21]; // description of this testcase (max 20 characters)
byte pin[2]; // pin setting. Set only one pin per testcase as you are always reading one at a time.
// also define only the number of input pins
unsigned long delayTime; // time to wait before this test case becomes active. 0 means it can execute straight away
};
//
// this test case has only 2 inputs. The order is determined by pinDesc
//
static testCase tc[] = {
{"Input 1 pushed on ",{ 1 , 0} , 1000 },
{"Input 1 released " ,{ 0 , 0} , 1000 },
{"Input 2 pushed on ",{ 0 , 1} , 500 },
{"Input 2 released " ,{ 0 , 1} , 1500 }
};
#endif
and the serial output
Blink Read;0;999
Blink On;1;1000
Blink Read;1;2000
Blink Off;0;2000
Blink Read;0;3001
Blink On;1;3002
Blink Read;1;4002
Blink Off;0;4002
Blink Read;0;5003
Blink On;1;5004
Blink Read;1;6004
Blink Off;0;6004
Blink Read;0;7005
Blink On;1;7006
Blink Read;1;8006
Blink Off;0;8006
Although not fit for all applications this does make it possible to perform a number of predefined tests over and over again.
Probably unuseable for:
- critical timing programs
- programs already running on the board limits for SRAM and Program memory
Next steps:
- Get the test sets executed
- move the test sets to PROGMEM area and use only the current testcase in SRAM.
- minimize variables to required size
- Make it useable on more Arduino boards
Nice project to do