diff --git a/build/linux/dist/lib/librxtxSerial.so b/build/linux/dist/lib/librxtxSerial.so deleted file mode 100755 index d340dcb676e..00000000000 Binary files a/build/linux/dist/lib/librxtxSerial.so and /dev/null differ diff --git a/hardware/arduino/cores/arduino/HardwareSerial.h b/hardware/arduino/cores/arduino/HardwareSerial.h index 3efa775f843..22ea9b0eddf 100644 --- a/hardware/arduino/cores/arduino/HardwareSerial.h +++ b/hardware/arduino/cores/arduino/HardwareSerial.h @@ -2,6 +2,8 @@ HardwareSerial.h - Hardware serial library for Wiring Copyright (c) 2006 Nicholas Zambetti. All right reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either diff --git a/libraries/ArduinoTestSuite/ArduinoTestSuite.cpp b/libraries/ArduinoTestSuite/ArduinoTestSuite.cpp new file mode 100644 index 00000000000..845e2efefd8 --- /dev/null +++ b/libraries/ArduinoTestSuite/ArduinoTestSuite.cpp @@ -0,0 +1,715 @@ +//************************************************************************ +//* Arduino Test Suite +//* (C) 2010 by Mark Sproul +//* Open source as per standard Arduino code +//* +//* This library is free software; you can redistribute it and/or +//* modify it under the terms of the GNU Lesser General Public +//* License as published by the Free Software Foundation; either +//* version 2.1 of the License, or (at your option) any later version. +//* +//* This library is distributed in the hope that it will be useful, +//* but WITHOUT ANY WARRANTY; without even the implied warranty of +//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//* Lesser General Public License for more details. +//************************************************************************ +//* Aug 31, 2010 Started on TestArduino +//* Oct 18, 2010 Added memory testing +//************************************************************************ + +#include +#include +#include + + + +#include "ArduinoTestSuite.h" + + +#include "WProgram.h" +#include "HardwareSerial.h" +#include "pins_arduino.h" + + +#include "avr_cpunames.h" + +#if defined(USART3_RX_vect) + #define SERIAL_PORT_COUNT 4 +#elif defined(USART1_RX_vect) + #define SERIAL_PORT_COUNT 2 +#else + #define SERIAL_PORT_COUNT 1 +#endif + + + + +//************************************************************************ +enum +{ + ATS_Manufacturer = 1, + ATS_CPU, + ATS_GCC_version, + ATS_LIBC_version, + ATS_CompiledDate, + ATS_TestSuiteName, + ATS_FreeMemory, + + +}; +unsigned long gTestStartTime; +short gTagIndent; +int gYotalErrors; +int gTestCount; + + + +prog_char gTextMsg_Manufacturer[] PROGMEM = "MANUFACTURER"; +prog_char gTextMsg_CPUname[] PROGMEM = "CPU-NAME"; +prog_char gTextMsg_GCC_VERSION[] PROGMEM = "GCC-Version"; +prog_char gTextMsg_AVR_LIBC[] PROGMEM = "AVR-LibC-Ver"; +prog_char gTextMsg_COMPILED_DATE[] PROGMEM = "Compiled-date"; +prog_char gTextMsg_TEST_SUITE_NAME[] PROGMEM = "Test-Suite-Name"; +prog_char gTextMsg_memoryUsage[] PROGMEM = "Free-memory"; +prog_char gTextMsg_dotdotdot[] PROGMEM = "... "; +prog_char gTextMsg_ok[] PROGMEM = "ok"; +prog_char gTextMsg_FAIL[] PROGMEM = "FAIL"; +prog_char gTextMsg_spaceEqual[] PROGMEM = " = "; +prog_char gTextMsg_info[] PROGMEM = "info."; +prog_char gTextMsg_dashLine[] PROGMEM = "--------------------------"; +prog_char gTextMsg_DigitalRW[] PROGMEM = "DigitalReadWrite_"; +prog_char gTextMsg_PWMoutput[] PROGMEM = "PWMoutput_"; +prog_char gTextMsg_AnalogInput[] PROGMEM = "AnalogInput_"; + +//************************************************************************ +void Serial_print_P(prog_char *flashMemStr) +{ +char theChar; +int ii; + + ii = 0; +#if (FLASHEND > 0x10000) + while (theChar = pgm_read_byte_far(flashMemStr + ii++)) +#else + while (theChar = pgm_read_byte_near(flashMemStr + ii++)) +#endif + { + Serial.print(theChar); + } +} + +//************************************************************************ +void Serial_println_P(prog_char *flashMemStr) +{ + Serial_print_P(flashMemStr); + Serial.println(); +} + +//************************************************************************ +//* this is for internal use only, not made pubic to the API +static void ATS_PrintProperty( int propertyTagNum, + char *propertyName, + char *propertyValue) +{ +char lineBuffer[64]; + + strcpy_P(lineBuffer, gTextMsg_info); + switch(propertyTagNum) + { + case 0: + strcat(lineBuffer, propertyName); + break; + + case ATS_Manufacturer: + strcat_P(lineBuffer, gTextMsg_Manufacturer); + break; + + case ATS_CPU: + strcat_P(lineBuffer, gTextMsg_CPUname); + break; + + case ATS_GCC_version: + strcat_P(lineBuffer, gTextMsg_GCC_VERSION); + break; + + case ATS_LIBC_version: + strcat_P(lineBuffer, gTextMsg_AVR_LIBC); + break; + + case ATS_CompiledDate: + strcat_P(lineBuffer, gTextMsg_COMPILED_DATE); + break; + + case ATS_TestSuiteName: + strcat_P(lineBuffer, gTextMsg_TEST_SUITE_NAME); + break; + + case ATS_FreeMemory: + strcat_P(lineBuffer, gTextMsg_memoryUsage); + break; + } + + while (strlen(lineBuffer) < 20) + { + strcat(lineBuffer, " "); + } + + strcat_P(lineBuffer, gTextMsg_spaceEqual); + if (propertyValue != 0) + { + strcat(lineBuffer, propertyValue); + } + Serial.println(lineBuffer); + +} + + + + +//************************************************************************ +void ATS_begin(char *manufName, char *testSuiteName) +{ +int freeMemory; +char memoryMsg[48]; + + gYotalErrors = 0; + gTestCount = 0; + + Serial.begin(9600); + delay(1000); + + gTestStartTime = millis(); + + Serial.println(); + Serial.println(); + Serial.println(); + + ATS_PrintProperty(ATS_Manufacturer, 0, manufName); + ATS_PrintProperty(ATS_CPU, 0, _AVR_CPU_NAME_); + ATS_PrintProperty(ATS_GCC_version, 0, __VERSION__); + ATS_PrintProperty(ATS_LIBC_version, 0, __AVR_LIBC_VERSION_STRING__); + ATS_PrintProperty(ATS_CompiledDate, 0, __DATE__); + ATS_PrintProperty(ATS_TestSuiteName, 0, testSuiteName); + + freeMemory = ATS_GetFreeMemory(); + sprintf(memoryMsg, "%d bytes", freeMemory); + ATS_PrintProperty(ATS_FreeMemory, 0, memoryMsg); + + randomSeed(analogRead(0)); + +} + +//************************************************************************ +void ATS_end() +{ +long seconds; +long milliSecs; + + + Serial_println_P(gTextMsg_dashLine); + + // Ran 4 tests in 0.000s + Serial.print("Ran "); + Serial.print(gTestCount); + Serial.print(" tests in "); + + seconds = millis() / 1000; + milliSecs = millis() % 1000; + Serial.print(seconds); + Serial.print('.'); + Serial.print(milliSecs); + Serial.print('s'); + Serial.println(); + Serial.println(); + + if (gYotalErrors == 0) + { + Serial.print("OK"); + } + else + { + Serial.print("FAILED (failures="); + Serial.print(gYotalErrors); + Serial.print(")"); + } + Serial.println(); + + //* send control D to terminate (End Of File) + Serial.write(0x04); +} + + + +//************************************************************************ +void ATS_PrintTestStatus(char *testString, boolean passed) +{ +int sLen; + + Serial.print(testString); + sLen = strlen(testString); + while (sLen < 60) + { + Serial.print(' '); + sLen++; + } + Serial_print_P(gTextMsg_dotdotdot); + if (passed) + { + Serial_print_P(gTextMsg_ok); + } + else + { + Serial_print_P(gTextMsg_FAIL); + gYotalErrors++; + } + Serial.println(); + + gTestCount++; +} + + + +//************************************************************************ +//* returns true if no errors, false if there is an error +int ATS_Test_DigitalPinWithHelper(uint8_t digitalPinToTest, uint8_t helperpin) +{ +boolean passedOK; +int pinValue; +char testName[64]; +char numString[32]; + + strcpy_P(testName, gTextMsg_DigitalRW); + sprintf(numString, "%02d", digitalPinToTest); + strcat(testName, numString); + + passedOK = true; + + //* test senario 1 + pinMode(digitalPinToTest, OUTPUT); + pinMode(helperpin, INPUT); + + digitalWrite(digitalPinToTest, HIGH); + pinValue = digitalRead(helperpin); + if (pinValue != HIGH) + { + passedOK = false; + } + + digitalWrite(digitalPinToTest, LOW); + pinValue = digitalRead(helperpin); + if (pinValue != LOW) + { + passedOK = false; + } + + + //* now reverse the input/output + pinMode(digitalPinToTest, INPUT); + pinMode(helperpin, OUTPUT); + + digitalWrite(helperpin, HIGH); + pinValue = digitalRead(digitalPinToTest); + if (pinValue != HIGH) + { + passedOK = false; + } + + digitalWrite(helperpin, LOW); + pinValue = digitalRead(digitalPinToTest); + if (pinValue != LOW) + { + passedOK = false; + } + + + if (! passedOK) + { + sprintf(numString, " (helper pin=%02d)", helperpin); + strcat(testName, numString); + } + ATS_PrintTestStatus(testName, passedOK); + return(passedOK); +} + +//************************************************************************ +boolean ATS_Test_DigitalPin(uint8_t digitalPinToTest) +{ +boolean passedOK; +uint8_t helperpin; + + if ((digitalPinToTest % 2) == 0) + { + //* if its EVEN, add 1 + helperpin = digitalPinToTest + 1; + } + else + { + //* if its ODD + helperpin = digitalPinToTest - 1; + } + passedOK = ATS_Test_DigitalPinWithHelper(digitalPinToTest, helperpin); + return(passedOK); +} + + + +//************************************************************************ +//* returns true if no errors, false if there is an error +int ATS_TestTimer( uint8_t timerPinNumber, + uint8_t inputPin, + char *statusString, + char *errorString) +{ +boolean passedOK; +unsigned long loopCounter; +unsigned long lowCount; +unsigned long highCount; +unsigned long startTime; +int percentLow; +int percentHigh; +int pinValue; +char numString[48]; +int pwmValue; + + pwmValue = 128; + loopCounter = 0; + lowCount = 0; + highCount = 0; + passedOK = true; + + startTime = millis(); + pinMode(inputPin, INPUT); + analogWrite(timerPinNumber, pwmValue); + while ((millis() - startTime) < 500) + { + pinValue = digitalRead(inputPin); + if (pinValue == HIGH) + { + highCount++; + } + else + { + lowCount++; + } + } + analogWrite(timerPinNumber, 0); + + //* the difference should be about 50% + percentLow = lowCount / ((lowCount + highCount) / 100); + percentHigh = highCount / ((lowCount + highCount) / 100); + if ((percentLow > 45) && (percentLow < 55)) + { + passedOK = true; + } + else + { + passedOK = false; + strcat(errorString, " PWM ERROR"); + } + sprintf(numString, " (PWM=%02d %d%% LOW %d%% HIGH)", pwmValue, percentLow, percentHigh); + strcat(statusString, numString); + + return(passedOK); +} + + +//************************************************************************ +//* returns true if no errors, false if there is an error +boolean ATS_Test_PWMPinWithHelper(uint8_t pwmPinToTest, uint8_t helperpin) +{ +boolean passedOK; +char testName[64]; +char errorString[48]; +char numString[8]; +uint8_t timerNumber; + + + + strcpy_P(testName, gTextMsg_PWMoutput); + sprintf(numString, "%02d", pwmPinToTest); + strcat(testName, numString); + + passedOK = true; + errorString[0] = 0; + + + //* is pin1 a timer? + timerNumber = digitalPinToTimer(pwmPinToTest); + if (timerNumber != NOT_ON_TIMER) + { + passedOK = ATS_TestTimer(pwmPinToTest, helperpin, testName, errorString); + } + else + { + //* we should not get here + passedOK = false; + } + + ATS_PrintTestStatus(testName, passedOK); + + + return(passedOK); +} + +//************************************************************************ +boolean ATS_Test_PWM_Pin(uint8_t pwmPinToTest) +{ +boolean passedOK; +uint8_t helperpin; + + if ((pwmPinToTest % 2) == 0) + { + //* if its EVEN, add 1 + helperpin = pwmPinToTest + 1; + } + else + { + //* if its ODD + helperpin = pwmPinToTest - 1; + } + passedOK = ATS_Test_PWMPinWithHelper(pwmPinToTest, helperpin); + return(passedOK); +} + + +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + #define kAnalogPinOffset 54 +#else + #define kAnalogPinOffset 14 +#endif + + +//************************************************************************ +boolean ATS_Test_AnalogInputWithHelper(uint8_t analogPintoTest, uint8_t helperPin) +{ +boolean passedOK; +char testName[64]; +char infoString[48]; +int analogValueHigh; +int analogValueLow; + + + //* first we have to set the ANALOG pin to INPUT + pinMode(analogPintoTest + kAnalogPinOffset, INPUT); + + passedOK = true; + + strcpy_P(testName, gTextMsg_AnalogInput); + sprintf(infoString, "%02d", analogPintoTest); + strcat(testName, infoString); + + + pinMode(helperPin, OUTPUT); + + digitalWrite(helperPin, LOW); + analogValueLow = analogRead(analogPintoTest); + if (analogValueLow > 100) + { + passedOK = false; + } + + + digitalWrite(helperPin, HIGH); + analogValueHigh = analogRead(analogPintoTest); + if (analogValueHigh < 1000) + { + passedOK = false; + } + + + sprintf(infoString, " (Low=%4d High=%4d helper pin=%d)", analogValueLow, analogValueHigh, helperPin); + strcat(testName, infoString); + + ATS_PrintTestStatus(testName, passedOK); + + return(passedOK); +} + + +//************************************************************************ +boolean ATS_Test_AnalogInput(uint8_t analogPinToTest) +{ +boolean passedOK; +uint8_t helperpin; + + if ((analogPinToTest % 2) == 0) + { + //* if its EVEN, add 1 + helperpin = kAnalogPinOffset + analogPinToTest + 1; + } + else + { + //* if its ODD + helperpin = kAnalogPinOffset + analogPinToTest - 1; + } + passedOK = ATS_Test_AnalogInputWithHelper(analogPinToTest, helperpin); + return(passedOK); +} + + +#define kSerialTestBaudRate 9600 +#define kSerialTestDelay 3 + + +#if (SERIAL_PORT_COUNT > 1) && !defined(__AVR_ATmega32U4__) +//************************************************************************ +//* retunrs 0 if no errors, 1 if an error occured +short ATS_TestSerialLoopback(HardwareSerial *theSerialPort, char *serialPortName) +{ +char xmitChar; +char rcvChar; +short ii; +short serialErrCt; +short timeOutLoopCtr; + + + serialErrCt = 1; + if (theSerialPort != 0) + { + serialErrCt = 0; + theSerialPort->begin(kSerialTestBaudRate); + + for (ii=0; ii<150; ii++) + { + xmitChar = ii; + theSerialPort->print(xmitChar); + + timeOutLoopCtr = 0; + //* wait for data to come back or timeout + while (!theSerialPort->available() && (timeOutLoopCtr < kSerialTestDelay)) + { + delay(1); + timeOutLoopCtr++; + } + + if (theSerialPort->available()) + { + //* get the char + rcvChar = theSerialPort->read(); + if (rcvChar != xmitChar) + { + serialErrCt = 1; + } + } + else + { + serialErrCt = 1; + } + } + theSerialPort->end(); + + if (serialErrCt == 0) + { + ATS_PrintTestStatus(serialPortName, PASSED); + } + else + { + ATS_PrintTestStatus(serialPortName, FAILED); + } + } + + return(serialErrCt); +} +#endif + + +//************************************************************************ +boolean ATS_Test_EEPROM(void) +{ +boolean passedOK; +uint8_t dataByte; +uint8_t dataByteRead; +uint16_t dataWord; +uint16_t dataWordRead; +uint32_t dataLongWord; +uint32_t dataLongWordRead; +int addressPtr; +char reportString[48]; + + passedOK = true; + //* test BYTE read/write + addressPtr = random(E2END); + dataByte = 0x5A; + eeprom_write_byte((uint8_t *)addressPtr, dataByte); + dataByteRead = eeprom_read_byte((uint8_t *)addressPtr); + + sprintf(reportString, "EEPROM_byte_rw (addr= 0x%04X)", addressPtr); + if (dataByteRead == dataByte) + { + ATS_PrintTestStatus(reportString, PASSED); + } + else + { + ATS_PrintTestStatus(reportString, FAILED); + passedOK = false; + } + + + //* test WORD read/write + addressPtr = random(E2END); + dataWord = 0xA55A; + eeprom_write_word((uint16_t *)addressPtr, dataWord); + dataWordRead = eeprom_read_word((uint16_t *)addressPtr); + + sprintf(reportString, "EEPROM_word_rw (addr= 0x%04X)", addressPtr); + if (dataWordRead == dataWord) + { + ATS_PrintTestStatus(reportString, PASSED); + } + else + { + ATS_PrintTestStatus(reportString, FAILED); + passedOK = false; + } + + + //* test Long WORD read/write + addressPtr = random(E2END); + dataLongWord = 0x5AA5A55A; + eeprom_write_dword((uint32_t *)addressPtr, dataLongWord); + dataLongWordRead = eeprom_read_dword((uint32_t *)addressPtr); + + sprintf(reportString, "EEPROM_dword_rw (addr= 0x%04X)", addressPtr); + if (dataLongWordRead == dataLongWord) + { + ATS_PrintTestStatus(reportString, PASSED); + } + else + { + ATS_PrintTestStatus(reportString, FAILED); + passedOK = false; + } + + + return(passedOK); +} + + + +//************************************************************************ +extern unsigned int __data_start; +extern unsigned int __data_end; +extern unsigned int __bss_start; +extern unsigned int __bss_end; +extern unsigned int __heap_start; +extern void *__brkval; + + + +//************************************************************************ +int ATS_GetFreeMemory() +{ +int free_memory; + + if((int)__brkval == 0) + { + free_memory = ((int)&free_memory) - ((int)&__bss_end); + } + else + { + free_memory = ((int)&free_memory) - ((int)__brkval); + } + return free_memory; +} + + diff --git a/libraries/ArduinoTestSuite/ArduinoTestSuite.h b/libraries/ArduinoTestSuite/ArduinoTestSuite.h new file mode 100644 index 00000000000..9501d67a25e --- /dev/null +++ b/libraries/ArduinoTestSuite/ArduinoTestSuite.h @@ -0,0 +1,74 @@ +//************************************************************************ +//************************************************************************ +//* Aug 31, 2010 Started on TestArduino +//************************************************************************ + +#ifndef _AVR_IO_H_ + #include +#endif + +#ifndef WProgram_h + #include "WProgram.h" +#endif +#ifndef HardwareSerial_h + #include "HardwareSerial.h" +#endif + + +#if defined(USART3_RX_vect) + #define SERIAL_PORT_COUNT 4 +#elif defined(USART1_RX_vect) + #define SERIAL_PORT_COUNT 2 +#else + #define SERIAL_PORT_COUNT 1 +#endif + + +void ATS_begin(char *manufName, char *testSuiteName); +void ATS_end(); + +void ATS_PrintTestStatus(char *testString, boolean passed); +boolean ATS_Test_DigitalPin(uint8_t digitalPinToTest); +boolean ATS_Test_PWM_Pin(uint8_t digitalPinToTest); +boolean ATS_Test_AnalogInput(uint8_t analogPintoTest); +boolean ATS_Test_EEPROM(void); + +short ATS_TestSerialLoopback(HardwareSerial *theSerialPort, char *serialPortName); + + +int ATS_GetFreeMemory(); + +//************************************************************************ +//* this has to be an inline function because calling subroutines affects free memory +inline void ATS_ReportMemoryUsage(int _memoryUsageAtStart) +{ +int freeMemoryAtEnd; +int lostMemory; +boolean memoryOK; +char memoryUsage[48]; + + freeMemoryAtEnd = ATS_GetFreeMemory(); + lostMemory = _memoryUsageAtStart - freeMemoryAtEnd; + if (lostMemory == 0) + { + strcpy(memoryUsage, "Memory Usage"); + memoryOK = true; + } + else + { + sprintf(memoryUsage, "Memory Usage (lost %d bytes)", lostMemory); + memoryOK = false; + } + ATS_PrintTestStatus(memoryUsage, memoryOK); +} + + + +extern unsigned long gTestStartTime; +extern int gYotalErrors; +extern int gTestCount; + + +#define PASSED true +#define FAILED false + diff --git a/libraries/ArduinoTestSuite/avr_cpunames.h b/libraries/ArduinoTestSuite/avr_cpunames.h new file mode 100644 index 00000000000..80832164c63 --- /dev/null +++ b/libraries/ArduinoTestSuite/avr_cpunames.h @@ -0,0 +1,186 @@ +//************************************************************************************************** +//* +//* Atmel AVR CPU name strings +//* +//************************************************************************************************** +//* Sep 19, 2010 Started on avr_cpunames.h +//************************************************************************************************** + +//#include "avr_cpunames.h" + +//************************************************************************************************** + + +#if defined (__AVR_AT94K__) + #define _AVR_CPU_NAME_ "AT94k" +#elif defined (__AVR_AT43USB320__) +#elif defined (__AVR_AT43USB355__) +#elif defined (__AVR_AT76C711__) +#elif defined (__AVR_AT86RF401__) +#elif defined (__AVR_AT90PWM1__) +#elif defined (__AVR_AT90PWM2__) +#elif defined (__AVR_AT90PWM2B__) +#elif defined (__AVR_AT90PWM3__) +#elif defined (__AVR_AT90PWM3B__) +#elif defined (__AVR_AT90PWM216__) +#elif defined (__AVR_AT90PWM316__) +#elif defined (__AVR_ATmega32C1__) +#elif defined (__AVR_ATmega32M1__) +#elif defined (__AVR_ATmega32U4__) + #define _AVR_CPU_NAME_ "ATmega32U4" +#elif defined (__AVR_ATmega32U6__) + #define _AVR_CPU_NAME_ "ATmega32U6" +#elif defined (__AVR_ATmega128__) + #define _AVR_CPU_NAME_ "Atmega128" +#elif defined (__AVR_ATmega1280__) + #define _AVR_CPU_NAME_ "ATmega1280" +#elif defined (__AVR_ATmega1281__) + #define _AVR_CPU_NAME_ "ATmega1281" +#elif defined (__AVR_ATmega1284P__) + #define _AVR_CPU_NAME_ "ATmega1284" +#elif defined (__AVR_ATmega2560__) + #define _AVR_CPU_NAME_ "ATmega2560" +#elif defined (__AVR_ATmega2561__) + #define _AVR_CPU_NAME_ "ATmega2561" +#elif defined (__AVR_AT90CAN32__) + #define _AVR_CPU_NAME_ "AT90CAN32" +#elif defined (__AVR_AT90CAN64__) + #define _AVR_CPU_NAME_ "AT90CAN64" +#elif defined (__AVR_AT90CAN128__) + #define _AVR_CPU_NAME_ "AT90CAN128" +#elif defined (__AVR_AT90USB82__) + #define _AVR_CPU_NAME_ "AT90USB82" +#elif defined (__AVR_AT90USB162__) + #define _AVR_CPU_NAME_ "AT90USB162" +#elif defined (__AVR_AT90USB646__) + #define _AVR_CPU_NAME_ "AT90USB646" +#elif defined (__AVR_AT90USB647__) + #define _AVR_CPU_NAME_ "AT90USB647" +#elif defined (__AVR_AT90USB1286__) + #define _AVR_CPU_NAME_ "AT90USB1286" +#elif defined (__AVR_AT90USB1287__) + #define _AVR_CPU_NAME_ "AT90USB1287" +#elif defined (__AVR_ATmega64__) + #define _AVR_CPU_NAME_ "ATmega64" +#elif defined (__AVR_ATmega640__) + #define _AVR_CPU_NAME_ "ATmega640" +#elif defined (__AVR_ATmega644__) + #define _AVR_CPU_NAME_ "ATmega644" +#elif defined (__AVR_ATmega644P__) + #define _AVR_CPU_NAME_ "ATmega644P" +#elif defined (__AVR_ATmega645__) + #define _AVR_CPU_NAME_ "ATmega645" +#elif defined (__AVR_ATmega6450__) + #define _AVR_CPU_NAME_ "ATmega6450" +#elif defined (__AVR_ATmega649__) + #define _AVR_CPU_NAME_ "ATmega649" +#elif defined (__AVR_ATmega6490__) + #define _AVR_CPU_NAME_ "ATmega6490" +#elif defined (__AVR_ATmega103__) + #define _AVR_CPU_NAME_ "ATmega103" +#elif defined (__AVR_ATmega32__) + #define _AVR_CPU_NAME_ "Atmega32" +#elif defined (__AVR_ATmega323__) + #define _AVR_CPU_NAME_ "ATmega323" +#elif defined (__AVR_ATmega324P__) + #define _AVR_CPU_NAME_ "ATmega324P" +#elif defined (__AVR_ATmega325__) + #define _AVR_CPU_NAME_ "ATmega325" +#elif defined (__AVR_ATmega325P__) + #define _AVR_CPU_NAME_ "ATmega325P" +#elif defined (__AVR_ATmega3250__) + #define _AVR_CPU_NAME_ "ATmega3250" +#elif defined (__AVR_ATmega3250P__) + #define _AVR_CPU_NAME_ "ATmega3250P" +#elif defined (__AVR_ATmega328P__) + #define _AVR_CPU_NAME_ "ATmega328P" +#elif defined (__AVR_ATmega329__) + #define _AVR_CPU_NAME_ "ATmega329" +#elif defined (__AVR_ATmega329P__) + #define _AVR_CPU_NAME_ "ATmega329P" +#elif defined (__AVR_ATmega3290__) + #define _AVR_CPU_NAME_ "ATmega3290" +#elif defined (__AVR_ATmega3290P__) + #define _AVR_CPU_NAME_ "ATmega3290P" +#elif defined (__AVR_ATmega32HVB__) + #define _AVR_CPU_NAME_ "ATmega32HVB" +#elif defined (__AVR_ATmega406__) + #define _AVR_CPU_NAME_ "ATmega406" +#elif defined (__AVR_ATmega16__) + #define _AVR_CPU_NAME_ "Atmega16" +#elif defined (__AVR_ATmega161__) + #define _AVR_CPU_NAME_ "ATmega161" +#elif defined (__AVR_ATmega162__) + #define _AVR_CPU_NAME_ "ATmega162" +#elif defined (__AVR_ATmega163__) + #define _AVR_CPU_NAME_ "ATmega163" +#elif defined (__AVR_ATmega164P__) + #define _AVR_CPU_NAME_ "ATmega164P" +#elif defined (__AVR_ATmega165__) + #define _AVR_CPU_NAME_ "ATmega165" +#elif defined (__AVR_ATmega165P__) + #define _AVR_CPU_NAME_ "ATmega165P" +#elif defined (__AVR_ATmega168__) + #define _AVR_CPU_NAME_ "ATmega168" +#elif defined (__AVR_ATmega168P__) + #define _AVR_CPU_NAME_ "ATmega168P" +#elif defined (__AVR_ATmega169__) + #define _AVR_CPU_NAME_ "Atmega169" +#elif defined (__AVR_ATmega169P__) + #define _AVR_CPU_NAME_ "ATmega169P" +#elif defined (__AVR_ATmega8HVA__) + #define _AVR_CPU_NAME_ "ATmega8HVA" +#elif defined (__AVR_ATmega16HVA__) + #define _AVR_CPU_NAME_ "ATmega16HVA" +#elif defined (__AVR_ATmega8__) + #define _AVR_CPU_NAME_ "ATmega8" +#elif defined (__AVR_ATmega48__) + #define _AVR_CPU_NAME_ "ATmega48" +#elif defined (__AVR_ATmega48P__) + #define _AVR_CPU_NAME_ "ATmega48P" +#elif defined (__AVR_ATmega88__) + #define _AVR_CPU_NAME_ "ATmega88" +#elif defined (__AVR_ATmega88P__) + #define _AVR_CPU_NAME_ "ATmega88P" +#elif defined (__AVR_ATmega8515__) + #define _AVR_CPU_NAME_ "ATmega8515" +#elif defined (__AVR_ATmega8535__) + #define _AVR_CPU_NAME_ "ATmega8535" +#elif defined (__AVR_AT90S8535__) +#elif defined (__AVR_AT90C8534__) +#elif defined (__AVR_AT90S8515__) +#elif defined (__AVR_AT90S4434__) +#elif defined (__AVR_AT90S4433__) +#elif defined (__AVR_AT90S4414__) +#elif defined (__AVR_ATtiny22__) +#elif defined (__AVR_ATtiny26__) +#elif defined (__AVR_AT90S2343__) +#elif defined (__AVR_AT90S2333__) +#elif defined (__AVR_AT90S2323__) +#elif defined (__AVR_AT90S2313__) +#elif defined (__AVR_ATtiny2313__) + #define _AVR_CPU_NAME_ "ATtiny2313" +#elif defined (__AVR_ATtiny13__) +#elif defined (__AVR_ATtiny13A__) +#elif defined (__AVR_ATtiny25__) +#elif defined (__AVR_ATtiny45__) +#elif defined (__AVR_ATtiny85__) +#elif defined (__AVR_ATtiny24__) +#elif defined (__AVR_ATtiny44__) +#elif defined (__AVR_ATtiny84__) +#elif defined (__AVR_ATtiny261__) +#elif defined (__AVR_ATtiny461__) +#elif defined (__AVR_ATtiny861__) +#elif defined (__AVR_ATtiny43U__) +#elif defined (__AVR_ATtiny48__) +#elif defined (__AVR_ATtiny88__) +#elif defined (__AVR_ATtiny167__) + +#else + #error cpu not defined +#endif + + +#if !defined (_AVR_CPU_NAME_) +// #define _AVR_CPU_NAME_ "UNKNOWN" +#endif diff --git a/libraries/ArduinoTestSuite/examples/ATS_Constants/ATS_Constants.pde b/libraries/ArduinoTestSuite/examples/ATS_Constants/ATS_Constants.pde new file mode 100644 index 00000000000..d58e8bac637 --- /dev/null +++ b/libraries/ArduinoTestSuite/examples/ATS_Constants/ATS_Constants.pde @@ -0,0 +1,76 @@ +//************************************************************************ +//* Arduino Test of Arduino Constants +//* (C) 2010 by Rick Anderson +//* Open source as per standard Arduino code +//* +//************************************************************************ +//* Oct 16, 2010 Test of Arduino Constants +//************************************************************************ + +#include "WProgram.h" +#include "HardwareSerial.h" +#include + +//************************************************************************ +void setup() +{ + int startMemoryUsage; + + //Start memory usage must be site prior to ATS_begin + startMemoryUsage = ATS_GetFreeMemory(); + ATS_begin("Arduino", "Test of Arduino Constants"); + /* + * Test Run Start + */ + + + //test true constant + ATS_PrintTestStatus("1. Test of true constant", true == 1); + + //test false consts + ATS_PrintTestStatus( "2. Test of false constant", false == 0); + + //Test of HIGH == 1 + ATS_PrintTestStatus( "3. Test of HIGH == 1", HIGH == 1); + + //Test of LOW == 0 + ATS_PrintTestStatus( "4. Test of LOW == 0", LOW == 0); + + //Test of INPUT == 1 + ATS_PrintTestStatus( "5. Test of INPUT == 1", HIGH == 1); + + //Test of OUTPUT == 0 + ATS_PrintTestStatus( "6. Test of OUTPUT == 0", LOW == 0); + + //test decimal + ATS_PrintTestStatus( "7. Test of decimal constant", 101 == ((1 * pow(10,2)) + (0 * pow(10,1)) + 1)); + + //test binary + ATS_PrintTestStatus( "8. Test of binary constant", B101 == 5); + + //test octal + ATS_PrintTestStatus( "9. Test of octal constant", 0101 == 65); + + //test hexadecimal + ATS_PrintTestStatus( "7. Test of hexadecimal constant", (0x101 == 257)); + + /* + * Test Run End + */ + ATS_ReportMemoryUsage(startMemoryUsage); + ATS_end(); + +} + + +//************************************************************************ +void loop() +{ + + +} + + + + + diff --git a/libraries/ArduinoTestSuite/examples/ATS_Delay/ATS_Delay.pde b/libraries/ArduinoTestSuite/examples/ATS_Delay/ATS_Delay.pde new file mode 100644 index 00000000000..8ac9fd2028d --- /dev/null +++ b/libraries/ArduinoTestSuite/examples/ATS_Delay/ATS_Delay.pde @@ -0,0 +1 @@ +//************************************************************************ //* Arduino Test Suite //* ATS_ToneTest //* //* Copyright (c) 2010 Mark Sproul All right reserved. //* //* This library is free software; you can redistribute it and/or //* modify it under the terms of the GNU Lesser General Public //* License as published by the Free Software Foundation; either //* version 2.1 of the License, or (at your option) any later version. //* //* This library is distributed in the hope that it will be useful, //* but WITHOUT ANY WARRANTY; without even the implied warranty of //* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU //* Lesser General Public License for more details. //* //* You should have received a copy of the GNU Lesser General Public //* License along with this library; if not, write to the Free Software //* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA //************************************************************************ //* Aug 31, 2010 Started on TestArduino //* Oct 28, 2010 Started on Delay //************************************************************************ #include "WProgram.h" #include "HardwareSerial.h" #include //************************************************************************ void setup() { short ii; short testNum; int startMemoryUsage; unsigned long startMillis; unsigned long endMillis; unsigned long deltaMillis; unsigned long errMillis; boolean passed; char testNameString[80]; startMemoryUsage = ATS_GetFreeMemory(); ATS_begin("Arduino", "DelayTest"); testNum = 1; //* we start at 2 because 0/1 are RXD/TXD for (ii=0; ii<1000; ii+= 15) { startMillis = millis(); delay(ii); endMillis = millis(); deltaMillis = endMillis - startMillis; if (deltaMillis >= ii) { errMillis = deltaMillis - ii; } else { errMillis = ii - deltaMillis; } if (errMillis <= 1) { passed = true; } else { passed = false; } sprintf(testNameString, "DelayTest.%02d (delay= %4d actual delay=%ld err=%ld)", testNum, ii, deltaMillis, errMillis); ATS_PrintTestStatus(testNameString, passed); testNum++; } ATS_ReportMemoryUsage(startMemoryUsage); ATS_end(); } //************************************************************************ void loop() { } \ No newline at end of file diff --git a/libraries/ArduinoTestSuite/examples/ATS_General/ATS_General.pde b/libraries/ArduinoTestSuite/examples/ATS_General/ATS_General.pde new file mode 100644 index 00000000000..502248a233e --- /dev/null +++ b/libraries/ArduinoTestSuite/examples/ATS_General/ATS_General.pde @@ -0,0 +1,94 @@ +//************************************************************************ +//* Arduino Test Suite +//* (C) 2010 by Mark Sproul +//* Open source as per standard Arduino code +//* +//************************************************************************ +//* Aug 31, 2010 Started on TestArduino +//* Oct 18, 2010 Added memory testing +//************************************************************************ + +#include "WProgram.h" +#include "HardwareSerial.h" +#include "pins_arduino.h" +#include +#include "avr_cpunames.h" + + +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) +#define kBoard_PinCount 20 +#define kBoard_AnalogCount 6 +#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) +#define kBoard_PinCount 70 +#define kBoard_AnalogCount 16 +#endif + + + + +//************************************************************************ +void setup() +{ + short ii; + uint8_t timerNumber; + int startMemoryUsage; + + startMemoryUsage = ATS_GetFreeMemory(); + + ATS_begin("Arduino", "general"); + + //* test digital pins + //* we start at 2 because 0/1 are RXD/TXD + for (ii=2; ii 1) + ATS_TestSerialLoopback(&Serial1, "Serial1"); +#endif +#if (SERIAL_PORT_COUNT > 2) + ATS_TestSerialLoopback(&Serial2, "Serial2"); +#endif +#if (SERIAL_PORT_COUNT > 3) + ATS_TestSerialLoopback(&Serial3, "Serial3"); +#endif + + ATS_Test_EEPROM(); + + + ATS_ReportMemoryUsage(startMemoryUsage); + + ATS_end(); + +} + + +//************************************************************************ +void loop() +{ + + +} + + + + + diff --git a/libraries/ArduinoTestSuite/examples/ATS_Skeleton/ATS_Skeleton.pde b/libraries/ArduinoTestSuite/examples/ATS_Skeleton/ATS_Skeleton.pde new file mode 100644 index 00000000000..33fc8168081 --- /dev/null +++ b/libraries/ArduinoTestSuite/examples/ATS_Skeleton/ATS_Skeleton.pde @@ -0,0 +1,52 @@ +//************************************************************************ +//* Arduino Test Example Skeleton +//* (C) 2010 by Rick Anderson +//* Open source as per standard Arduino code +//* +//************************************************************************ +//* Oct 16, 2010 Started on String Test +//************************************************************************ + +#include "WProgram.h" +#include "HardwareSerial.h" +#include + +//************************************************************************ +void setup() +{ + int startMemoryUsage; + + //startMemoryUsage must be set directly before ATS_begin + startMemoryUsage = ATS_GetFreeMemory(); + ATS_begin("Arduino", "Skeleton Test"); + /* + * Test Run Start + * Test one passes because result is set to true + * Test two fails becuase result is set to false + * You can test memory for any set of tests by using the ATS_ReportMemoryUsage test + * There is also a way to print current memeory for debugging + */ + ATS_PrintTestStatus("1. Test of true test status", true); + + ATS_PrintTestStatus("2. Test of false test status, this will fail.", false); + + ATS_ReportMemoryUsage(startMemoryUsage); + /* + * Test Run End + */ + + ATS_end(); + +} + + +//************************************************************************ +void loop() +{ + + +} + + + + diff --git a/libraries/ArduinoTestSuite/examples/ATS_StringIndexOfMemory/ATS_StringIndexOfMemory.pde b/libraries/ArduinoTestSuite/examples/ATS_StringIndexOfMemory/ATS_StringIndexOfMemory.pde new file mode 100644 index 00000000000..71a6bea1963 --- /dev/null +++ b/libraries/ArduinoTestSuite/examples/ATS_StringIndexOfMemory/ATS_StringIndexOfMemory.pde @@ -0,0 +1,102 @@ +//************************************************************************ +//* Arduino Test Example Skeleton +//* (C) 2010 by Rick Anderson +//* Open source as per standard Arduino code +//* +//************************************************************************ +//* Oct 16, 2010 Started on String Test +//************************************************************************ + +#include "WProgram.h" +#include "HardwareSerial.h" +#include + +//************************************************************************ +void setup() +{ + char testName[64]; + int startMemoryUsage; + /* + * Create variable for the tests. + */ + + + String stringOne; + int firstClosingBracket; + int firstOpeningBracket; + int secondOpeningBracket; + int secondClosingBracket; + int bodyTag; + int firstListItem; + int secondListItem; + int lastOpeningBracket; + int lastListItem; + int lastParagraph; + int secondLastGraf; + + /*; + * initiate the test run + */ + startMemoryUsage = ATS_GetFreeMemory(); + ATS_begin("Arduino", "String Memory Test"); + // indexOf() returns the position (i.e. index) of a particular character + // in a string. For example, if you were parsing HTML tags, you could use it: + stringOne = ""; + firstClosingBracket = stringOne.indexOf('>'); + Serial.println("The index of > in the string " + stringOne + " is " + firstClosingBracket); + + stringOne = ""; + secondOpeningBracket = firstClosingBracket + 1; + secondClosingBracket = stringOne.indexOf('>', secondOpeningBracket ); + Serial.println("The index of the second > in the string " + stringOne + " is " + secondClosingBracket); + + // you can also use indexOf() to search for Strings: + stringOne = ""; + bodyTag = stringOne.indexOf(""); + Serial.println("The index of the body tag in the string " + stringOne + " is " + bodyTag); + + stringOne = "
  • item
  • item
  • item
"; + firstListItem = stringOne.indexOf("
  • "); + secondListItem = stringOne.indexOf("item", firstListItem + 1 ); + Serial.println("The index of the second list item in the string " + stringOne + " is " + secondClosingBracket); + + // lastIndexOf() gives you the last occurrence of a character or string: + lastOpeningBracket = stringOne.lastIndexOf('<'); + Serial.println("The index of the last < in the string " + stringOne + " is " + lastOpeningBracket); + + lastListItem = stringOne.lastIndexOf("
  • "); + Serial.println("The index of the last list item in the string " + stringOne + " is " + lastListItem); + + + // lastIndexOf() can also search for a string: + stringOne = "

    Lorem ipsum dolor sit amet

    Ipsem

    Quod

    "; + lastParagraph = stringOne.lastIndexOf(" Started on String Test +//************************************************************************ + +#include "WProgram.h" +#include "HardwareSerial.h" +#include + +//************************************************************************ +void setup() +{ + + int startMemoryUsage; + + ATS_begin("Arduino", "Test of String Library"); + + /* + * Test Variable Setup + * Best practive set all your test variables prior to teseting. + * This is required for Memory tests. + */ + + String stringOne = String("stringThree = "); + String stringTwo = String("this string"); + String stringThree = String (); + char charResult[100]; + + + + /* + * Run the tests + */ + + // adding a constant integer to a string: + stringThree = stringOne + 123; + //strcpy(charResult, "\0"); + stringThree.toCharArray(charResult, sizeof(charResult)); + + ATS_PrintTestStatus("1. Adding a constant integer to a string:", strcmp(charResult,"stringThree = 123" ) == 0); + + // adding a constant long interger to a string: + stringThree = stringOne + 123456789; + stringThree.toCharArray(charResult, sizeof(charResult)); + + ATS_PrintTestStatus("2. Adding a constant long interger to a string", strcmp(charResult,"stringThree = 123456789" ) == 0); + + + // adding a constant character to a string: + stringThree = stringOne + 'A'; + stringThree.toCharArray(charResult, sizeof(charResult)); + + ATS_PrintTestStatus("3. Adding a constant character to a string", strcmp(charResult,"stringThree = A" ) == 0); + + + // adding a constant string to a string: + stringThree = stringOne + "abc"; + stringThree.toCharArray(charResult, sizeof(charResult)); + + ATS_PrintTestStatus("4. Adding a constant string variable to a string", strcmp(charResult,"stringThree = abc" ) == 0); + + //"5. Adding a constant long interger to a string" + stringThree = stringOne + stringTwo; + stringThree.toCharArray(charResult, sizeof(charResult)); + + ATS_PrintTestStatus("5. Adding a constant long interger to a string", strcmp(charResult,"stringThree = this string" ) == 0); + + + /* + * setup up String Comparison Operater Tests + */ + + stringOne = String("this"); + stringTwo = String("that"); + + // two strings equal: + ATS_PrintTestStatus("6. Two strings equal",stringOne == "this"); + + // two strings not equal: + ATS_PrintTestStatus("7. Two strings not equal",stringOne != stringTwo); + + // two strings not equal (case sensitivity matters): + stringOne = "This"; + stringTwo = "this"; + ATS_PrintTestStatus("8. Two strings not equal [case sensitivity matters]", stringOne != stringTwo); + + // you can also use equals() to see if two strings are the same: + stringOne = "this"; + stringTwo = "this"; + ATS_PrintTestStatus("9. Equals() method equals", stringOne.equals(stringTwo)); + + + // you can also use not equals() to see if two strings are not the same: + stringOne = String("This"); + stringTwo = String("this"); + ATS_PrintTestStatus("10. Not equals() method equals", !stringOne.equals(stringTwo)); + + // or perhaps you want to ignore case: + ATS_PrintTestStatus("11. EqualsIgnoreCase() method equals", stringOne.equalsIgnoreCase(stringTwo)); + + // a numeric string compared to the number it represents: + stringOne = "1"; + int numberOne = 1; + ATS_PrintTestStatus("12. A numeric string compared to the number it represents", stringOne == numberOne); + + // two numeric strings compared: + stringOne = "2"; + stringTwo = "1"; + ATS_PrintTestStatus("13. Two numeric strings compared",stringOne >= stringTwo); + + + // comparison operators can be used to compare strings for alphabetic sorting too: + +/* + stringOne = String("Brown"); + ATS_PrintTestStatus("14. comparison operator < can be used to compare strings for alphabetic sorting ",stringOne < "Charles"); + ATS_PrintTestStatus("15. comparison operator > can be used to compare strings for alphabetic sorting ",stringOne > "Adams"); + ATS_PrintTestStatus("16. comparison operator <= can be used to compare strings for alphabetic sorting ",stringOne <= "Browne"); + ATS_PrintTestStatus("17. comparison operator >= can be used to compare strings for alphabetic sorting ",stringOne >= "Brow"); + */ + + + // the compareTo() operator also allows you to compare strings + stringOne = "Cucumber"; + stringTwo = "Cucuracha"; + + ATS_PrintTestStatus("18. The compareTo() operator also allows you to compare strings", stringOne.compareTo(stringTwo) < 0); + + // compareTo() String with numnber > String with number: + stringOne = "Sensor: 50"; + stringTwo= "Sensor: 150"; + ATS_PrintTestStatus("19. The compareTo() String with integers", stringOne.compareTo(stringTwo) < 0); + + +// compareTo() String with numnber > String with number append integer, matches example code: + stringOne = "Sensor: "; + stringTwo= "Sensor: "; + stringOne += 50; + stringTwo += 150; + ATS_PrintTestStatus("20. The compareTo() compare strings with appended integers", stringOne.compareTo(stringTwo) < 0); + + + /* + * setup up String Append Operation Tests + */ + // Serious awful problem here + stringOne = String("Sensor "); + stringTwo = String("value"); + + stringOne += stringTwo; + ATS_PrintTestStatus("21. Adding string to string += ", stringOne.equals("Sensor value")); + + ATS_PrintTestStatus("22. The compareTo() compare strings with appended integers", stringOne.compareTo(stringTwo) < 0); + /* + * Test complete + */ + + ATS_end(); + +} + + +//************************************************************************ +void loop() +{ + + +} + + + + + + + + + + + + diff --git a/libraries/ArduinoTestSuite/examples/ATS_ToneTest/ATS_ToneTest.pde b/libraries/ArduinoTestSuite/examples/ATS_ToneTest/ATS_ToneTest.pde new file mode 100644 index 00000000000..8bec6be2aaf --- /dev/null +++ b/libraries/ArduinoTestSuite/examples/ATS_ToneTest/ATS_ToneTest.pde @@ -0,0 +1,250 @@ +//************************************************************************ +//* Arduino Test Suite +//* ATS_ToneTest +//* +//* Copyright (c) 2010 Mark Sproul All right reserved. +//* +//* This library is free software; you can redistribute it and/or +//* modify it under the terms of the GNU Lesser General Public +//* License as published by the Free Software Foundation; either +//* version 2.1 of the License, or (at your option) any later version. +//* +//* This library is distributed in the hope that it will be useful, +//* but WITHOUT ANY WARRANTY; without even the implied warranty of +//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//* Lesser General Public License for more details. +//* +//* You should have received a copy of the GNU Lesser General Public +//* License along with this library; if not, write to the Free Software +//* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +//************************************************************************ +//* Aug 31, 2010 Started on TestArduino +//* Oct 23, 2010 Started on ToneTest +//************************************************************************ + + + + + +#include "WProgram.h" +#include "HardwareSerial.h" + +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) + #define kBoard_PinCount 20 + #define kBoard_AnalogCount 6 +#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + #define kBoard_PinCount 70 + #define kBoard_AnalogCount 16 +#endif + +#include + +//************************************************************************ +void TestTonePin(uint8_t toneOutputPinNumber) +{ +uint8_t helperpin; +unsigned long startMilliSecs; +unsigned long highCount, lowCount; +int previousState; +int currentState; +char testNameString[80]; +long outputFreq; +long measuredFreq; +boolean passed; +long percentError; +long deltaFreq; + + if ((toneOutputPinNumber % 2) == 0) + { + //* if its EVEN, add 1 + helperpin = toneOutputPinNumber + 1; + } + else + { + //* if its ODD + helperpin = toneOutputPinNumber - 1; + } + + //* dont set the mode of the OUTPUT pin, the tone command does that + + pinMode(helperpin, INPUT); + + previousState = digitalRead(helperpin); + startMilliSecs = millis(); + highCount = 0; + lowCount = 0; + measuredFreq = 0; + //* we are going to watch for one second + outputFreq = random(200, 2000); + + tone(toneOutputPinNumber, outputFreq); + while ((millis() - startMilliSecs) < 1000) + { + currentState = digitalRead(helperpin); + if (currentState == HIGH) + { + highCount++; + } + else + { + lowCount++; + } + //* check to see if it changed state + if ((currentState == HIGH) && (previousState == LOW)) + { + measuredFreq++; + } + + previousState = currentState; + } + noTone(toneOutputPinNumber); + + deltaFreq = abs(measuredFreq - outputFreq); + + percentError = 100 - abs(((outputFreq - deltaFreq) * 100) / outputFreq); + + sprintf(testNameString, "ToneTest.%02d (out freq= %4ld measured freq= %4ld err= %ld%%)", toneOutputPinNumber, outputFreq, measuredFreq, percentError); + if (percentError < 5) + { + passed = true; + } + else + { + passed = false; + } + + ATS_PrintTestStatus(testNameString, passed); +} + + +//************************************************************************ +//* this test to make sure the duration option works +void TestToneDuration(uint8_t toneOutputPinNumber) +{ +uint8_t helperpin; +unsigned long startMilliSecs; +unsigned long highCount, lowCount; +int previousState; +int currentState; +char testNameString[80]; +long outputFreq; +long measuredFreq; +boolean passed; +long percentError; +long deltaFreq; +long durationTime; + + if ((toneOutputPinNumber % 2) == 0) + { + //* if its EVEN, add 1 + helperpin = toneOutputPinNumber + 1; + } + else + { + //* if its ODD + helperpin = toneOutputPinNumber - 1; + } + + //* dont set the mode of the OUTPUT pin, the tone command does that + + pinMode(helperpin, INPUT); + + previousState = digitalRead(helperpin); + startMilliSecs = millis(); + highCount = 0; + lowCount = 0; + measuredFreq = 0; + durationTime = 0; + //* we are going to watch for one second + outputFreq = random(500, 2000); + + tone(toneOutputPinNumber, outputFreq, 1000); + while ((millis() - startMilliSecs) < 2000) + { + currentState = digitalRead(helperpin); + if (currentState == HIGH) + { + highCount++; + } + else + { + lowCount++; + } + //* count the freq + if ((currentState == HIGH) && (previousState == LOW)) + { + measuredFreq++; + } + + //* check to see if it changed state + if (currentState != previousState) + { + durationTime = millis() - startMilliSecs; + } + + previousState = currentState; + } + + deltaFreq = abs(measuredFreq - outputFreq); + + percentError = 100 - abs(((outputFreq - deltaFreq) * 100) / outputFreq); + + sprintf(testNameString, "ToneTesDurationt.%02d (durationTime =%4ld/1000 freq err= %ld%%)", toneOutputPinNumber, durationTime, percentError); + if ((durationTime > 990) && (durationTime < 1010) && (percentError < 5)) + { + passed = true; + } + else + { + passed = false; + } + noTone(toneOutputPinNumber); + + ATS_PrintTestStatus(testNameString, passed); +} + + + +//************************************************************************ +void setup() +{ +short ii; +uint8_t timerNumber; +int startMemoryUsage; + + startMemoryUsage = ATS_GetFreeMemory(); + + ATS_begin("Arduino", "ToneTest"); + + + //* we start at 2 because 0/1 are RXD/TXD + for (ii=2; ii 0 or self.passedTestsCount > 0: + #self.addHTMLLog ('tests summary', "
    " + log.getText() + "
    ") + self.addHTMLLog ('tests summary', self.createTestsSummary(log)) + self.descriptionDone = [self.getTestName(log.getText())] + + def getText(self, cmd, results): + text = ShellCommand.getText(self, cmd, results) + if self.failedTestsCount > 0 or self.passedTestsCount > 0: + text.append("tests failed: " + str(self.failedTestsCount)) + text.append("tests passed: " + str(self.passedTestsCount)) + return text + + def getTestName(self, log): + for line in log.splitlines(): + if line.startswith('info.Test-Suite-Name'): + testname = line.split('= ')[1] + return testname + return None + + + def evaluateCommand(self, cmd): + if self.failedTestsCount > 0: + return FAILURE + else: + return SUCCESS + + def createTestsSummary(self,log): + # Create a string with your html report and return it + return "
    " + log.getText() + "
    " + +#class Nose(ShellCommand): +# def __init__(self, stage=None,module=None, moduleset=None, **kwargs): +# command = ['nosetests', '--with-coverage', '--cover-erase', '--cover-html'] +# +# def describe(self, done=False): +# if not done: +# return 'testing' +# else: +# return 'test done' +# +# def createSummary(self, log): +# buildnumber = self.getProperty('buildnumber') +# coverage_index = (self.coverage_path + '/index.html') % buildnumber +# f = open(coverage_index) +# m = re.search(r'Percent: (\d+) %', f.read()) +# f.close() +# self.addURL("coverage %s%%" % m.group(1), +# self.coverage_url % buildnumber) + + +######## BUILDERS +from buildbot.process import factory +from buildbot.steps import source, shell +#from buildbot.steps.python_twisted import Trial + + +test_factory = factory.BuildFactory() +test_factory.addStep(source.Git(repourl='git://github.com/ricklon/Arduino.git', branch='master', shallow=True)) +test_factory.addStep(shell.ShellCommand, command=['git','log','-1'], descriptionDone="Latest Change from Git Log") +test_factory.addStep(shell.ShellCommand, command=['ant'], workdir='build/build') +test_factory.addStep(ArduinoTestCmd( command=["make", "arduinotest"], descriptionDone="Arduino Tests", workdir='build/test/examples')) +test_factory.addStep(ArduinoTestCmd( command=["make", "test"], descriptionDone="Arduino Tests All", workdir='build/test/examples')) +test_factory.addStep(ArduinoTestCmd( command=["make", "success"], descriptionDone="Arduino Tests Success", workdir='build/test/examples')) +test_factory.addStep(ArduinoTestCmd( descriptionDone="Arduino Tests Default", workdir='build/test/examples')) +test_factory.addStep(ArduinoTestCmd ( command=["make", "bogus"], descriptionDone="Arduino bogus make target", workdir='build/test/examples')) +test_factory.addStep(ArduinoTestCmd( command=["make", "failure"], descriptionDone="Shell Arduino Tests Failure",workdir='build/test/examples')) + + + +b1 = {'name': "arduino-buildbot-ubuntu-10.04", + 'slavename': "ardutestbot1", + 'builddir': "ArduinoUbuntu", + 'factory': test_factory, + } + +b2 = {'name': "arduino-buildbot-macosx-10.6.4", + 'slavename': "ardumacbot1", + 'builddir': "ArduinoMacOSX", + 'factory': test_factory, + } + +b3 = {'name': "arduino-buildbot-windowsX", + 'slavename': "arduwinbot1", + 'builddir': "ArduinoWindowsX", + 'factory': test_factory, + } + +c['builders'] = [b1, b2, b3] + + +####### STATUS TARGETS + +# 'status' is a list of Status Targets. The results of each build will be +# pushed to these targets. buildbot/status/*.py has a variety to choose from, +# including web pages, email senders, and IRC bots. + +c['status'] = [] + +# Use allowForce=True (boolean, not a string. ie: not 'True') to allow +# Forcing Builds in the Web User Interface. The default is False. +from buildbot.status import html +c['status'].append(html.WebStatus(http_port=8010,allowForce=True)) + +#from buildbot.status import html +#c['status'].append(html.WebStatus(http_port=8010)) + +# from buildbot.status import mail +# c['status'].append(mail.MailNotifier(fromaddr="buildbot@localhost", +# extraRecipients=["builds@example.com"], +# sendToInterestedUsers=False)) +# +from buildbot.status import words +c['status'].append(words.IRC(host="irc.freenode.net", nick="ardbot", channels=["#arduinobuild"])) +# +# from buildbot.status import client +# c['status'].append(client.PBListener(9988)) + + +####### DEBUGGING OPTIONS + +# if you set 'debugPassword', then you can connect to the buildmaster with +# the diagnostic tool in contrib/debugclient.py . From this tool, you can +# manually force builds and inject changes, which may be useful for testing +# your buildmaster without actually committing changes to your repository (or +# before you have a functioning 'sources' set up). The debug tool uses the +# same port number as the slaves do: 'slavePortnum'. + +#c['debugPassword'] = "debugpassword" + +# if you set 'manhole', you can ssh into the buildmaster and get an +# interactive python shell, which may be useful for debugging buildbot +# internals. It is probably only useful for buildbot developers. You can also +# use an authorized_keys file, or plain telnet. +#from buildbot import manhole +#c['manhole'] = manhole.PasswordManhole("tcp:9999:interface=127.0.0.1", +# "admin", "password") + + +####### PROJECT IDENTITY + +c['projectName'] = "Arduino" +c['projectURL'] = "http://arduino.cc" + +c['buildbotURL'] = "http://localhost:8010/" diff --git a/testing/examples/Makefile b/testing/examples/Makefile new file mode 100644 index 00000000000..6d06ac82876 --- /dev/null +++ b/testing/examples/Makefile @@ -0,0 +1,22 @@ +#Makefile stub for test output simulation for testing the Buildbot make test fesature + +all: test + +test: success failure arduinotest + +success: + cat arduino-success.test + +failure: + cat arduino-mixed.test + +test3: + cat arduino1.test + +arduinotest: + cat arduino-success.test + + + + + diff --git a/testing/examples/README b/testing/examples/README new file mode 100644 index 00000000000..95908da7b10 --- /dev/null +++ b/testing/examples/README @@ -0,0 +1,84 @@ +Arduino test result format + + +The Arduino test result format is based on the need for a result that can be streamed, sumary data is at the end of the test, and is human readable. + +Test result format description. + +The file begins with info data. It's indicated by having "info." at the begging of the line. +Common info fields: +info.MANUFACTURER = Arduino +info.CPU-NAME = ATmega328P +info.GCC-Version = 4.3.2 +info.AVR-LibC-Ver = 1.6.4 +info.Compiled-date = Oct 4 2010 +info.Test-Suite-Name = general + + +Followed by test run results. + +Test run results format: +name of test (information about test) ... test result condition + +A test has the following test result conditions: +ok +FAIL +ERROR + +Test result summary is last and seperated from the test by dashes: +-------------------------- + +Summary will say: +Ran n test in Secs + +Test suite final condition: +OK +FAILED (failures=n) + + + +Example test Results: + +info.MANUFACTURER = Arduino +info.CPU-NAME = ATmega328P +info.GCC-Version = 4.3.2 +info.AVR-LibC-Ver = 1.6.4 +info.Compiled-date = Oct 4 2010 +info.Test-Suite-Name = general +DigitalReadWrite_02 ... ok +DigitalReadWrite_03 ... ok +DigitalReadWrite_04 ... ok +DigitalReadWrite_05 ... ok +DigitalReadWrite_06 ... ok +DigitalReadWrite_07 ... ok +DigitalReadWrite_08 ... ok +DigitalReadWrite_09 ... ok +DigitalReadWrite_10 ... ok +DigitalReadWrite_11 ... ok +DigitalReadWrite_12 ... ok +DigitalReadWrite_13 ... ok +DigitalReadWrite_14 ... ok +DigitalReadWrite_15 ... ok +DigitalReadWrite_16 ... ok +DigitalReadWrite_17 ... ok +DigitalReadWrite_18 ... ok +DigitalReadWrite_19 ... ok +PWMoutput_03 (PWM=128 50% LOW 49% HIGH) ... ok +PWMoutput_05 (PWM=128 50% LOW 49% HIGH) ... ok +PWMoutput_06 (PWM=128 50% LOW 49% HIGH) ... ok +PWMoutput_09 (PWM=128 50% LOW 49% HIGH) ... ok +PWMoutput_10 (PWM=128 50% LOW 49% HIGH) ... ok +PWMoutput_11 (PWM=128 50% LOW 49% HIGH) ... ok +AnalogInput_00 (Low= 0 High= 472 helper pin=15) ... FAIL +AnalogInput_01 (Low= 477 High=1023 helper pin=14) ... FAIL +AnalogInput_02 (Low= 0 High= 474 helper pin=17) ... FAIL +AnalogInput_03 (Low= 479 High=1023 helper pin=16) ... FAIL +AnalogInput_04 (Low= 0 High= 470 helper pin=19) ... FAIL +AnalogInput_05 (Low= 475 High=1023 helper pin=18) ... FAIL +-------------------------- +Ran 30 tests in 7.326s + +FAILED (failures=6) + + + diff --git a/testing/examples/arduino-mixed.test b/testing/examples/arduino-mixed.test new file mode 100644 index 00000000000..8a365b123f6 --- /dev/null +++ b/testing/examples/arduino-mixed.test @@ -0,0 +1,40 @@ +info.MANUFACTURER = Arduino +info.CPU-NAME = ATmega328P +info.GCC-Version = 4.3.2 +info.AVR-LibC-Ver = 1.6.4 +info.Compiled-date = Oct 4 2010 +info.Test-Suite-Name = general +DigitalReadWrite_02 ... ok +DigitalReadWrite_03 ... ok +DigitalReadWrite_04 ... ok +DigitalReadWrite_05 ... ok +DigitalReadWrite_06 ... ok +DigitalReadWrite_07 ... ok +DigitalReadWrite_08 ... ok +DigitalReadWrite_09 ... ok +DigitalReadWrite_10 ... ok +DigitalReadWrite_11 ... ok +DigitalReadWrite_12 ... ok +DigitalReadWrite_13 ... ok +DigitalReadWrite_14 ... ok +DigitalReadWrite_15 ... ok +DigitalReadWrite_16 ... ok +DigitalReadWrite_17 ... ok +DigitalReadWrite_18 ... ok +DigitalReadWrite_19 ... ok +PWMoutput_03 (PWM=128 50% LOW 49% HIGH) ... ok +PWMoutput_05 (PWM=128 50% LOW 49% HIGH) ... ok +PWMoutput_06 (PWM=128 50% LOW 49% HIGH) ... ok +PWMoutput_09 (PWM=128 50% LOW 49% HIGH) ... ok +PWMoutput_10 (PWM=128 50% LOW 49% HIGH) ... ok +PWMoutput_11 (PWM=128 50% LOW 49% HIGH) ... ok +AnalogInput_00 (Low= 0 High= 472 helper pin=15) ... FAIL +AnalogInput_01 (Low= 477 High=1023 helper pin=14) ... FAIL +AnalogInput_02 (Low= 0 High= 474 helper pin=17) ... FAIL +AnalogInput_03 (Low= 479 High=1023 helper pin=16) ... FAIL +AnalogInput_04 (Low= 0 High= 470 helper pin=19) ... FAIL +AnalogInput_05 (Low= 475 High=1023 helper pin=18) ... FAIL +-------------------------- +Ran 30 tests in 7.326s + +FAILED (failures=6) diff --git a/testing/examples/arduino-success.test b/testing/examples/arduino-success.test new file mode 100644 index 00000000000..2376ef66923 --- /dev/null +++ b/testing/examples/arduino-success.test @@ -0,0 +1,42 @@ + + +info.MANUFACTURER = Arduino +info.CPU-NAME = ATmega328P +info.GCC-Version = 4.3.2 +info.AVR-LibC-Ver = 1.6.4 +info.Compiled-date = Oct 5 2010 +info.Test-Suite-Name = general +DigitalReadWrite_02 ... ok +DigitalReadWrite_03 ... ok +DigitalReadWrite_04 ... ok +DigitalReadWrite_05 ... ok +DigitalReadWrite_06 ... ok +DigitalReadWrite_07 ... ok +DigitalReadWrite_08 ... ok +DigitalReadWrite_09 ... ok +DigitalReadWrite_10 ... ok +DigitalReadWrite_11 ... ok +DigitalReadWrite_12 ... ok +DigitalReadWrite_13 ... ok +DigitalReadWrite_14 ... ok +DigitalReadWrite_15 ... ok +DigitalReadWrite_16 ... ok +DigitalReadWrite_17 ... ok +DigitalReadWrite_18 ... ok +DigitalReadWrite_19 ... ok +PWMoutput_03 (PWM=128 50% LOW 49% HIGH) ... ok +PWMoutput_05 (PWM=128 50% LOW 49% HIGH) ... ok +PWMoutput_06 (PWM=128 50% LOW 49% HIGH) ... ok +PWMoutput_09 (PWM=128 50% LOW 49% HIGH) ... ok +PWMoutput_10 (PWM=128 50% LOW 49% HIGH) ... ok +PWMoutput_11 (PWM=128 50% LOW 49% HIGH) ... ok +AnalogInput_00 (Low= 0 High=1023 helper pin=15) ... ok +AnalogInput_01 (Low= 15 High=1023 helper pin=14) ... ok +AnalogInput_02 (Low= 0 High=1023 helper pin=17) ... ok +AnalogInput_03 (Low= 15 High=1023 helper pin=16) ... ok +AnalogInput_04 (Low= 0 High=1023 helper pin=19) ... ok +AnalogInput_05 (Low= 14 High=1023 helper pin=18) ... ok +-------------------------- +Ran 30 tests in 6.362s + +OK diff --git a/testing/examples/arduino1.test b/testing/examples/arduino1.test new file mode 100644 index 00000000000..41baca1438d --- /dev/null +++ b/testing/examples/arduino1.test @@ -0,0 +1,36 @@ +info.MANUFACTURER = Arduino ... ok +info.CPU-NAME = ATmega2560 ... ok +info.GCC-Version = 4.3.2 ... ok +info.AVR-LibC-Ver = 1.6.4 ... ok +info.Compiled-date = Oct 3 2010 ... ok +Serial1 ... ok +Serial2 ... ok +Serial3 ... ok +PIN_IN_OUT 2/3 1-PWM 2-PWM ... ok +PIN_IN_OUT 4/5 1-PWM 2-PWM ... FAIL +PIN_IN_OUT 6/7 1-PWM 2-PWM ... FAIL +PIN_IN_OUT 8/9 1-PWM 2-PWM ... FAIL +PIN_IN_OUT 10/11 1-PWM 2-PWM ... FAIL +PIN_IN_OUT 12/13 1-PWM 2-PWM ... FAIL +PIN_IN_OUT 14/15 ... ok +PIN_IN_OUT 16/17 ... ok +PIN_IN_OUT 18/19 ... ok +PIN_IN_OUT 20/21 ... FAIL +PIN_IN_OUT 22/23 ... FAIL +PIN_IN_OUT 24/25 ... FAIL +PIN_IN_OUT 26/27 ... FAIL +PIN_IN_OUT 28/29 ... FAIL +PIN_IN_OUT 30/31 ... FAIL +PIN_IN_OUT 32/33 ... FAIL +PIN_IN_OUT 34/35 ... FAIL +PIN_IN_OUT 36/37 ... FAIL +PIN_IN_OUT 38/39 ... FAIL +PIN_IN_OUT 40/41 ... FAIL +PIN_IN_OUT 42/43 ... FAIL +PIN_IN_OUT 44/45 1-PWM 2-PWM ... FAIL +PIN_IN_OUT 46/47 1-PWM ... ok +PIN_IN_OUT 48/49 ... FAIL +---------------------------- +Ran 27 tests in 22.170s + +FALIED (failures=19) diff --git a/testing/src/Makefile b/testing/src/Makefile new file mode 100644 index 00000000000..e69de29bb2d diff --git a/testing/src/serialcap/serialcap.c b/testing/src/serialcap/serialcap.c new file mode 100644 index 00000000000..a9f87e67bce --- /dev/null +++ b/testing/src/serialcap/serialcap.c @@ -0,0 +1,128 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define TIMEOUT 60 +#define BAUDRATE B9600 + +#define _POSIX_SOURCE 1 /* POSIX compliant source */ +#define FALSE 0 +#define TRUE 1 + +volatile int STOP=FALSE; + +void signal_handler_IO (int status); /* definition of signal handler */ +speed_t convert_baud (char *baudstring); /* convert string baud rate to bit pattern */ +int wait_flag=TRUE; /* TRUE while no signal received */ + +int main(int argc, char** argv) +{ + int fd, c, res; + char *ctl; + struct termios oldtio,newtio; + struct sigaction saio; /* definition of signal action */ + char buf[255]; + char device[MAXPATHLEN]; + int errno = 0; + speed_t baud; + + /* if first command line arg exists then it is the serial device to use */ + if ( argv[1] != NULL ) { + strncpy(device, argv[1], MAXPATHLEN - 1); + } else { + fprintf(stderr,"usage: serialcap [baud]\n"); + exit(-1); + } + + /* second command line arg is baud (if it exists) */ + argv[2] != NULL ? (baud = convert_baud(argv[2])) : (baud = BAUDRATE); + + /* open the device to be non-blocking (read will return immediatly) */ + fd = open(device, O_RDONLY | O_NOCTTY | O_NONBLOCK); + if (fd <0) {perror(device); exit(-1); } + + /* install the signal handler before making the device asynchronous */ + saio.sa_handler = signal_handler_IO; + sigemptyset(&saio.sa_mask); + saio.sa_flags = 0; + saio.sa_restorer = NULL; + sigaction(SIGIO,&saio,NULL); + + /* allow the process to receive SIGIO */ + fcntl(fd, F_SETOWN, getpid()); + + /* Make the file descriptor asynchronous (the manual page says only + O_APPEND and O_NONBLOCK, will work with F_SETFL...) */ + fcntl(fd, F_SETFL, FASYNC); + + tcgetattr(fd,&oldtio); /* save current port settings */ + /* set new port settings for non-canonical input processing */ + newtio.c_cflag = baud | CS8 | CLOCAL | CREAD; + newtio.c_iflag = IGNPAR | ICRNL; + newtio.c_oflag = 0; + newtio.c_lflag &= ~(ICANON|ECHO); + newtio.c_cc[VMIN]=1; + newtio.c_cc[VTIME]=0; + tcflush(fd, TCIFLUSH); + tcsetattr(fd,TCSANOW,&newtio); + + // No buffering on output + setvbuf(stdout, NULL, _IONBF, 0); + + /* loop while waiting for input. normally we would do something + useful here */ + while (STOP==FALSE) { + /* wait until TIMEOUT seconds for new input, SIGIO will interupt this */ + sleep(TIMEOUT); + /* after receiving SIGIO, wait_flag = FALSE, input is available + and can be read */ + if (wait_flag==FALSE) { + res = read(fd,buf,255); + buf[res]=0; + + /* check for ^d and ^z, replace 1st with null, let it print, then exit; */ + if (ctl = strchr(buf, 0x04)) { + *ctl = 0; + STOP=TRUE; + } + if (ctl = strchr(buf, 0x1A)) { + *ctl = 0; + STOP=TRUE; + } + + printf("%s", buf); + wait_flag = TRUE; /* wait for new input */ + } else { + STOP=TRUE; + errno = 1; + } + } + /* restore old port settings */ + tcsetattr(fd,TCSANOW,&oldtio); + exit(errno); +} + +/*************************************************************************** +* signal handler. sets wait_flag to FALSE, to indicate above loop that * +* characters have been received. * +***************************************************************************/ + +void signal_handler_IO (int status) +{ + wait_flag = FALSE; +} + +// setbaud(char* baudstring) +// convert string baud to proper bit pattern + +speed_t convert_baud(char *baudstring) +{ + fprintf(stderr, "convert_ baud not finished\n"); + return BAUDRATE; +} diff --git a/testing/tests/ATS_Constants/ATS_Constants.pde b/testing/tests/ATS_Constants/ATS_Constants.pde new file mode 100644 index 00000000000..d58e8bac637 --- /dev/null +++ b/testing/tests/ATS_Constants/ATS_Constants.pde @@ -0,0 +1,76 @@ +//************************************************************************ +//* Arduino Test of Arduino Constants +//* (C) 2010 by Rick Anderson +//* Open source as per standard Arduino code +//* +//************************************************************************ +//* Oct 16, 2010 Test of Arduino Constants +//************************************************************************ + +#include "WProgram.h" +#include "HardwareSerial.h" +#include + +//************************************************************************ +void setup() +{ + int startMemoryUsage; + + //Start memory usage must be site prior to ATS_begin + startMemoryUsage = ATS_GetFreeMemory(); + ATS_begin("Arduino", "Test of Arduino Constants"); + /* + * Test Run Start + */ + + + //test true constant + ATS_PrintTestStatus("1. Test of true constant", true == 1); + + //test false consts + ATS_PrintTestStatus( "2. Test of false constant", false == 0); + + //Test of HIGH == 1 + ATS_PrintTestStatus( "3. Test of HIGH == 1", HIGH == 1); + + //Test of LOW == 0 + ATS_PrintTestStatus( "4. Test of LOW == 0", LOW == 0); + + //Test of INPUT == 1 + ATS_PrintTestStatus( "5. Test of INPUT == 1", HIGH == 1); + + //Test of OUTPUT == 0 + ATS_PrintTestStatus( "6. Test of OUTPUT == 0", LOW == 0); + + //test decimal + ATS_PrintTestStatus( "7. Test of decimal constant", 101 == ((1 * pow(10,2)) + (0 * pow(10,1)) + 1)); + + //test binary + ATS_PrintTestStatus( "8. Test of binary constant", B101 == 5); + + //test octal + ATS_PrintTestStatus( "9. Test of octal constant", 0101 == 65); + + //test hexadecimal + ATS_PrintTestStatus( "7. Test of hexadecimal constant", (0x101 == 257)); + + /* + * Test Run End + */ + ATS_ReportMemoryUsage(startMemoryUsage); + ATS_end(); + +} + + +//************************************************************************ +void loop() +{ + + +} + + + + + diff --git a/testing/tests/ATS_Delay/ATS_Delay.pde b/testing/tests/ATS_Delay/ATS_Delay.pde new file mode 100644 index 00000000000..8ac9fd2028d --- /dev/null +++ b/testing/tests/ATS_Delay/ATS_Delay.pde @@ -0,0 +1 @@ +//************************************************************************ //* Arduino Test Suite //* ATS_ToneTest //* //* Copyright (c) 2010 Mark Sproul All right reserved. //* //* This library is free software; you can redistribute it and/or //* modify it under the terms of the GNU Lesser General Public //* License as published by the Free Software Foundation; either //* version 2.1 of the License, or (at your option) any later version. //* //* This library is distributed in the hope that it will be useful, //* but WITHOUT ANY WARRANTY; without even the implied warranty of //* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU //* Lesser General Public License for more details. //* //* You should have received a copy of the GNU Lesser General Public //* License along with this library; if not, write to the Free Software //* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA //************************************************************************ //* Aug 31, 2010 Started on TestArduino //* Oct 28, 2010 Started on Delay //************************************************************************ #include "WProgram.h" #include "HardwareSerial.h" #include //************************************************************************ void setup() { short ii; short testNum; int startMemoryUsage; unsigned long startMillis; unsigned long endMillis; unsigned long deltaMillis; unsigned long errMillis; boolean passed; char testNameString[80]; startMemoryUsage = ATS_GetFreeMemory(); ATS_begin("Arduino", "DelayTest"); testNum = 1; //* we start at 2 because 0/1 are RXD/TXD for (ii=0; ii<1000; ii+= 15) { startMillis = millis(); delay(ii); endMillis = millis(); deltaMillis = endMillis - startMillis; if (deltaMillis >= ii) { errMillis = deltaMillis - ii; } else { errMillis = ii - deltaMillis; } if (errMillis <= 1) { passed = true; } else { passed = false; } sprintf(testNameString, "DelayTest.%02d (delay= %4d actual delay=%ld err=%ld)", testNum, ii, deltaMillis, errMillis); ATS_PrintTestStatus(testNameString, passed); testNum++; } ATS_ReportMemoryUsage(startMemoryUsage); ATS_end(); } //************************************************************************ void loop() { } \ No newline at end of file diff --git a/testing/tests/ATS_General/ATS_General.pde b/testing/tests/ATS_General/ATS_General.pde new file mode 100644 index 00000000000..502248a233e --- /dev/null +++ b/testing/tests/ATS_General/ATS_General.pde @@ -0,0 +1,94 @@ +//************************************************************************ +//* Arduino Test Suite +//* (C) 2010 by Mark Sproul +//* Open source as per standard Arduino code +//* +//************************************************************************ +//* Aug 31, 2010 Started on TestArduino +//* Oct 18, 2010 Added memory testing +//************************************************************************ + +#include "WProgram.h" +#include "HardwareSerial.h" +#include "pins_arduino.h" +#include +#include "avr_cpunames.h" + + +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) +#define kBoard_PinCount 20 +#define kBoard_AnalogCount 6 +#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) +#define kBoard_PinCount 70 +#define kBoard_AnalogCount 16 +#endif + + + + +//************************************************************************ +void setup() +{ + short ii; + uint8_t timerNumber; + int startMemoryUsage; + + startMemoryUsage = ATS_GetFreeMemory(); + + ATS_begin("Arduino", "general"); + + //* test digital pins + //* we start at 2 because 0/1 are RXD/TXD + for (ii=2; ii 1) + ATS_TestSerialLoopback(&Serial1, "Serial1"); +#endif +#if (SERIAL_PORT_COUNT > 2) + ATS_TestSerialLoopback(&Serial2, "Serial2"); +#endif +#if (SERIAL_PORT_COUNT > 3) + ATS_TestSerialLoopback(&Serial3, "Serial3"); +#endif + + ATS_Test_EEPROM(); + + + ATS_ReportMemoryUsage(startMemoryUsage); + + ATS_end(); + +} + + +//************************************************************************ +void loop() +{ + + +} + + + + + diff --git a/testing/tests/ATS_Skeleton/ATS_Skeleton.pde b/testing/tests/ATS_Skeleton/ATS_Skeleton.pde new file mode 100644 index 00000000000..33fc8168081 --- /dev/null +++ b/testing/tests/ATS_Skeleton/ATS_Skeleton.pde @@ -0,0 +1,52 @@ +//************************************************************************ +//* Arduino Test Example Skeleton +//* (C) 2010 by Rick Anderson +//* Open source as per standard Arduino code +//* +//************************************************************************ +//* Oct 16, 2010 Started on String Test +//************************************************************************ + +#include "WProgram.h" +#include "HardwareSerial.h" +#include + +//************************************************************************ +void setup() +{ + int startMemoryUsage; + + //startMemoryUsage must be set directly before ATS_begin + startMemoryUsage = ATS_GetFreeMemory(); + ATS_begin("Arduino", "Skeleton Test"); + /* + * Test Run Start + * Test one passes because result is set to true + * Test two fails becuase result is set to false + * You can test memory for any set of tests by using the ATS_ReportMemoryUsage test + * There is also a way to print current memeory for debugging + */ + ATS_PrintTestStatus("1. Test of true test status", true); + + ATS_PrintTestStatus("2. Test of false test status, this will fail.", false); + + ATS_ReportMemoryUsage(startMemoryUsage); + /* + * Test Run End + */ + + ATS_end(); + +} + + +//************************************************************************ +void loop() +{ + + +} + + + + diff --git a/testing/tests/ATS_StringIndexOfMemory/ATS_StringIndexOfMemory.pde b/testing/tests/ATS_StringIndexOfMemory/ATS_StringIndexOfMemory.pde new file mode 100644 index 00000000000..71a6bea1963 --- /dev/null +++ b/testing/tests/ATS_StringIndexOfMemory/ATS_StringIndexOfMemory.pde @@ -0,0 +1,102 @@ +//************************************************************************ +//* Arduino Test Example Skeleton +//* (C) 2010 by Rick Anderson +//* Open source as per standard Arduino code +//* +//************************************************************************ +//* Oct 16, 2010 Started on String Test +//************************************************************************ + +#include "WProgram.h" +#include "HardwareSerial.h" +#include + +//************************************************************************ +void setup() +{ + char testName[64]; + int startMemoryUsage; + /* + * Create variable for the tests. + */ + + + String stringOne; + int firstClosingBracket; + int firstOpeningBracket; + int secondOpeningBracket; + int secondClosingBracket; + int bodyTag; + int firstListItem; + int secondListItem; + int lastOpeningBracket; + int lastListItem; + int lastParagraph; + int secondLastGraf; + + /*; + * initiate the test run + */ + startMemoryUsage = ATS_GetFreeMemory(); + ATS_begin("Arduino", "String Memory Test"); + // indexOf() returns the position (i.e. index) of a particular character + // in a string. For example, if you were parsing HTML tags, you could use it: + stringOne = ""; + firstClosingBracket = stringOne.indexOf('>'); + Serial.println("The index of > in the string " + stringOne + " is " + firstClosingBracket); + + stringOne = ""; + secondOpeningBracket = firstClosingBracket + 1; + secondClosingBracket = stringOne.indexOf('>', secondOpeningBracket ); + Serial.println("The index of the second > in the string " + stringOne + " is " + secondClosingBracket); + + // you can also use indexOf() to search for Strings: + stringOne = ""; + bodyTag = stringOne.indexOf(""); + Serial.println("The index of the body tag in the string " + stringOne + " is " + bodyTag); + + stringOne = "
    • item
    • item
    • item
    "; + firstListItem = stringOne.indexOf("
  • "); + secondListItem = stringOne.indexOf("item", firstListItem + 1 ); + Serial.println("The index of the second list item in the string " + stringOne + " is " + secondClosingBracket); + + // lastIndexOf() gives you the last occurrence of a character or string: + lastOpeningBracket = stringOne.lastIndexOf('<'); + Serial.println("The index of the last < in the string " + stringOne + " is " + lastOpeningBracket); + + lastListItem = stringOne.lastIndexOf("
  • "); + Serial.println("The index of the last list item in the string " + stringOne + " is " + lastListItem); + + + // lastIndexOf() can also search for a string: + stringOne = "

    Lorem ipsum dolor sit amet

    Ipsem

    Quod

    "; + lastParagraph = stringOne.lastIndexOf(" Started on String Test +//************************************************************************ + +#include "WProgram.h" +#include "HardwareSerial.h" +#include + +//************************************************************************ +void setup() +{ + + int startMemoryUsage; + + ATS_begin("Arduino", "Test of String Library"); + + /* + * Test Variable Setup + * Best practive set all your test variables prior to teseting. + * This is required for Memory tests. + */ + + String stringOne = String("stringThree = "); + String stringTwo = String("this string"); + String stringThree = String (); + char charResult[100]; + + + + /* + * Run the tests + */ + + // adding a constant integer to a string: + stringThree = stringOne + 123; + //strcpy(charResult, "\0"); + stringThree.toCharArray(charResult, sizeof(charResult)); + + ATS_PrintTestStatus("1. Adding a constant integer to a string:", strcmp(charResult,"stringThree = 123" ) == 0); + + // adding a constant long interger to a string: + stringThree = stringOne + 123456789; + stringThree.toCharArray(charResult, sizeof(charResult)); + + ATS_PrintTestStatus("2. Adding a constant long interger to a string", strcmp(charResult,"stringThree = 123456789" ) == 0); + + + // adding a constant character to a string: + stringThree = stringOne + 'A'; + stringThree.toCharArray(charResult, sizeof(charResult)); + + ATS_PrintTestStatus("3. Adding a constant character to a string", strcmp(charResult,"stringThree = A" ) == 0); + + + // adding a constant string to a string: + stringThree = stringOne + "abc"; + stringThree.toCharArray(charResult, sizeof(charResult)); + + ATS_PrintTestStatus("4. Adding a constant string variable to a string", strcmp(charResult,"stringThree = abc" ) == 0); + + //"5. Adding a constant long interger to a string" + stringThree = stringOne + stringTwo; + stringThree.toCharArray(charResult, sizeof(charResult)); + + ATS_PrintTestStatus("5. Adding a constant long interger to a string", strcmp(charResult,"stringThree = this string" ) == 0); + + + /* + * setup up String Comparison Operater Tests + */ + + stringOne = String("this"); + stringTwo = String("that"); + + // two strings equal: + ATS_PrintTestStatus("6. Two strings equal",stringOne == "this"); + + // two strings not equal: + ATS_PrintTestStatus("7. Two strings not equal",stringOne != stringTwo); + + // two strings not equal (case sensitivity matters): + stringOne = "This"; + stringTwo = "this"; + ATS_PrintTestStatus("8. Two strings not equal [case sensitivity matters]", stringOne != stringTwo); + + // you can also use equals() to see if two strings are the same: + stringOne = "this"; + stringTwo = "this"; + ATS_PrintTestStatus("9. Equals() method equals", stringOne.equals(stringTwo)); + + + // you can also use not equals() to see if two strings are not the same: + stringOne = String("This"); + stringTwo = String("this"); + ATS_PrintTestStatus("10. Not equals() method equals", !stringOne.equals(stringTwo)); + + // or perhaps you want to ignore case: + ATS_PrintTestStatus("11. EqualsIgnoreCase() method equals", stringOne.equalsIgnoreCase(stringTwo)); + + // a numeric string compared to the number it represents: + stringOne = "1"; + int numberOne = 1; + ATS_PrintTestStatus("12. A numeric string compared to the number it represents", stringOne == numberOne); + + // two numeric strings compared: + stringOne = "2"; + stringTwo = "1"; + ATS_PrintTestStatus("13. Two numeric strings compared",stringOne >= stringTwo); + + + // comparison operators can be used to compare strings for alphabetic sorting too: + +/* + stringOne = String("Brown"); + ATS_PrintTestStatus("14. comparison operator < can be used to compare strings for alphabetic sorting ",stringOne < "Charles"); + ATS_PrintTestStatus("15. comparison operator > can be used to compare strings for alphabetic sorting ",stringOne > "Adams"); + ATS_PrintTestStatus("16. comparison operator <= can be used to compare strings for alphabetic sorting ",stringOne <= "Browne"); + ATS_PrintTestStatus("17. comparison operator >= can be used to compare strings for alphabetic sorting ",stringOne >= "Brow"); + */ + + + // the compareTo() operator also allows you to compare strings + stringOne = "Cucumber"; + stringTwo = "Cucuracha"; + + ATS_PrintTestStatus("18. The compareTo() operator also allows you to compare strings", stringOne.compareTo(stringTwo) < 0); + + // compareTo() String with numnber > String with number: + stringOne = "Sensor: 50"; + stringTwo= "Sensor: 150"; + ATS_PrintTestStatus("19. The compareTo() String with integers", stringOne.compareTo(stringTwo) < 0); + + +// compareTo() String with numnber > String with number append integer, matches example code: + stringOne = "Sensor: "; + stringTwo= "Sensor: "; + stringOne += 50; + stringTwo += 150; + ATS_PrintTestStatus("20. The compareTo() compare strings with appended integers", stringOne.compareTo(stringTwo) < 0); + + + /* + * setup up String Append Operation Tests + */ + // Serious awful problem here + stringOne = String("Sensor "); + stringTwo = String("value"); + + stringOne += stringTwo; + ATS_PrintTestStatus("21. Adding string to string += ", stringOne.equals("Sensor value")); + + ATS_PrintTestStatus("22. The compareTo() compare strings with appended integers", stringOne.compareTo(stringTwo) < 0); + /* + * Test complete + */ + + ATS_end(); + +} + + +//************************************************************************ +void loop() +{ + + +} + + + + + + + + + + + + diff --git a/testing/tests/ATS_ToneTest/ATS_ToneTest.pde b/testing/tests/ATS_ToneTest/ATS_ToneTest.pde new file mode 100644 index 00000000000..8bec6be2aaf --- /dev/null +++ b/testing/tests/ATS_ToneTest/ATS_ToneTest.pde @@ -0,0 +1,250 @@ +//************************************************************************ +//* Arduino Test Suite +//* ATS_ToneTest +//* +//* Copyright (c) 2010 Mark Sproul All right reserved. +//* +//* This library is free software; you can redistribute it and/or +//* modify it under the terms of the GNU Lesser General Public +//* License as published by the Free Software Foundation; either +//* version 2.1 of the License, or (at your option) any later version. +//* +//* This library is distributed in the hope that it will be useful, +//* but WITHOUT ANY WARRANTY; without even the implied warranty of +//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//* Lesser General Public License for more details. +//* +//* You should have received a copy of the GNU Lesser General Public +//* License along with this library; if not, write to the Free Software +//* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +//************************************************************************ +//* Aug 31, 2010 Started on TestArduino +//* Oct 23, 2010 Started on ToneTest +//************************************************************************ + + + + + +#include "WProgram.h" +#include "HardwareSerial.h" + +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) + #define kBoard_PinCount 20 + #define kBoard_AnalogCount 6 +#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + #define kBoard_PinCount 70 + #define kBoard_AnalogCount 16 +#endif + +#include + +//************************************************************************ +void TestTonePin(uint8_t toneOutputPinNumber) +{ +uint8_t helperpin; +unsigned long startMilliSecs; +unsigned long highCount, lowCount; +int previousState; +int currentState; +char testNameString[80]; +long outputFreq; +long measuredFreq; +boolean passed; +long percentError; +long deltaFreq; + + if ((toneOutputPinNumber % 2) == 0) + { + //* if its EVEN, add 1 + helperpin = toneOutputPinNumber + 1; + } + else + { + //* if its ODD + helperpin = toneOutputPinNumber - 1; + } + + //* dont set the mode of the OUTPUT pin, the tone command does that + + pinMode(helperpin, INPUT); + + previousState = digitalRead(helperpin); + startMilliSecs = millis(); + highCount = 0; + lowCount = 0; + measuredFreq = 0; + //* we are going to watch for one second + outputFreq = random(200, 2000); + + tone(toneOutputPinNumber, outputFreq); + while ((millis() - startMilliSecs) < 1000) + { + currentState = digitalRead(helperpin); + if (currentState == HIGH) + { + highCount++; + } + else + { + lowCount++; + } + //* check to see if it changed state + if ((currentState == HIGH) && (previousState == LOW)) + { + measuredFreq++; + } + + previousState = currentState; + } + noTone(toneOutputPinNumber); + + deltaFreq = abs(measuredFreq - outputFreq); + + percentError = 100 - abs(((outputFreq - deltaFreq) * 100) / outputFreq); + + sprintf(testNameString, "ToneTest.%02d (out freq= %4ld measured freq= %4ld err= %ld%%)", toneOutputPinNumber, outputFreq, measuredFreq, percentError); + if (percentError < 5) + { + passed = true; + } + else + { + passed = false; + } + + ATS_PrintTestStatus(testNameString, passed); +} + + +//************************************************************************ +//* this test to make sure the duration option works +void TestToneDuration(uint8_t toneOutputPinNumber) +{ +uint8_t helperpin; +unsigned long startMilliSecs; +unsigned long highCount, lowCount; +int previousState; +int currentState; +char testNameString[80]; +long outputFreq; +long measuredFreq; +boolean passed; +long percentError; +long deltaFreq; +long durationTime; + + if ((toneOutputPinNumber % 2) == 0) + { + //* if its EVEN, add 1 + helperpin = toneOutputPinNumber + 1; + } + else + { + //* if its ODD + helperpin = toneOutputPinNumber - 1; + } + + //* dont set the mode of the OUTPUT pin, the tone command does that + + pinMode(helperpin, INPUT); + + previousState = digitalRead(helperpin); + startMilliSecs = millis(); + highCount = 0; + lowCount = 0; + measuredFreq = 0; + durationTime = 0; + //* we are going to watch for one second + outputFreq = random(500, 2000); + + tone(toneOutputPinNumber, outputFreq, 1000); + while ((millis() - startMilliSecs) < 2000) + { + currentState = digitalRead(helperpin); + if (currentState == HIGH) + { + highCount++; + } + else + { + lowCount++; + } + //* count the freq + if ((currentState == HIGH) && (previousState == LOW)) + { + measuredFreq++; + } + + //* check to see if it changed state + if (currentState != previousState) + { + durationTime = millis() - startMilliSecs; + } + + previousState = currentState; + } + + deltaFreq = abs(measuredFreq - outputFreq); + + percentError = 100 - abs(((outputFreq - deltaFreq) * 100) / outputFreq); + + sprintf(testNameString, "ToneTesDurationt.%02d (durationTime =%4ld/1000 freq err= %ld%%)", toneOutputPinNumber, durationTime, percentError); + if ((durationTime > 990) && (durationTime < 1010) && (percentError < 5)) + { + passed = true; + } + else + { + passed = false; + } + noTone(toneOutputPinNumber); + + ATS_PrintTestStatus(testNameString, passed); +} + + + +//************************************************************************ +void setup() +{ +short ii; +uint8_t timerNumber; +int startMemoryUsage; + + startMemoryUsage = ATS_GetFreeMemory(); + + ATS_begin("Arduino", "ToneTest"); + + + //* we start at 2 because 0/1 are RXD/TXD + for (ii=2; ii' > $(IMAGE).cpp + cat $^ $(ARD_MAIN) >> $(IMAGE).cpp + cd $(BUILD_DIR) && $(CXX) -c $(CXX_FLAGS) $(OPT_FLAGS) $(ARD_FLAGS) \ + -I.. -I../.. $(subst -I../,-I../../,$(INC_FLAGS)) $(SKETCH).cpp \ + -o $(SKETCH).o + @ $(AR) rc $@ $*.o + @ $(RM) $*.o + +(%.o) : $(ARD_SRC_DIR)/%.c + $(run-cc) + +(%.o) : $(ARD_SRC_DIR)/%.cpp + $(run-cxx) + +(%.o) : %.c + $(run-cc) + +(%.o) : %.cpp + $(run-cxx) + +$(IMAGE).hex : $(ARD_AR_OBJ) $(LIB_AR_OBJ) $(SKT_AR_OBJ) $(SKT_PDE_OBJ) + $(CXX) $(CXX_FLAGS) $(OPT_FLAGS) $(ARD_FLAGS) -L$(BUILD_DIR) \ + $(SKT_LD_FLAG) $(LIB_LD_FLAG) $(ARD_LD_FLAG) -o $(IMAGE).elf + $(OBJCOPY) -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load \ + --no-change-warnings --change-section-lma .eeprom=0 $(IMAGE).elf \ + $(IMAGE).eep + $(OBJCOPY) -O ihex -R .eeprom $(IMAGE).elf $(IMAGE).hex + $(SIZE) $(IMAGE).hex + +upload : clean all +# - pkill -f $(MON_CMD).*$(PORT) +# $(RESET) $(PORT) + $(AVRDUDE) -C$(AVRDUDE_CONF) -p$(MCU) -c$(PROGRAMMER) -P$(PORT) -b$(UPLOAD_SPEED) -D -Uflash:w:$(IMAGE).hex:i -q + +monitor : + LD_LIBRARY_PATH= LD_PRELOAD= \ + $(MON_TERM) -t '$(BOARD) $(PORT)' \ + -e '$(MON_CMD) -$(MON_SPEED) $(PORT)' & + +upload_monitor : upload monitor + +env: + @echo ARD_AR: $(ARD_AR) + @echo ARD_AR_OBJ: "$(ARD_AR_OBJ)" + @echo ARD_C_OBJ: $(ARD_C_OBJ) + @echo ARD_C_SRC: $(ARD_C_SRC) + @echo ARD_CXX_OBJ: $(ARD_CXX_OBJ) + @echo ARD_CXX_SRC: $(ARD_CXX_SRC) + @echo ARD_FLAGS: $(ARD_FLAGS) + @echo ARD_HOME: $(ARD_HOME) + @echo ARD_LD_FLAG: $(ARD_LD_FLAG) + @echo ARD_LIB: $(ARD_LIB) + @echo ARD_SRC_HOME $(ARD_SRC_HOME) + @echo C_FLAGS: $(C_FLAGS) + @echo CXX_FLAGS: $(CXX_FLAGS) + @echo IMAGE $(IMAGE) + @echo INC_ARD_SRC: $(INC_ARD_SRC) + @echo INC_FLAGS: $(INC_FLAGS) + @echo INC_LIBDIR: $(INC_LIBDIR) + @echo LIB_C_SRC $(LIB_C_SRC) + @echo LIB_CXX_SRC $(LIB_CXX_SRC) + @echo LIB_SRC $(LIB_SRC) + @echo OPT_FLAGS: $(OPT_FLAGS) + @echo SKETCH: $(SKETCH) + @echo SKT_C_SRC $(SKT_C_SRC) + @echo SKT_CXX_SRC $(SKT_CXX_SRC) + @echo SKT_DIR $(SKT_DIR) + @echo SKT_PDE_SRC $(SKT_PDE_SRC) + @echo VPATH $(VPATH) + +.PHONY: printvars +printvars: + $(foreach V,$(sort $(.VARIABLES)), + $(if $(filter-out environment% default automatic, + $(origin $V)),$(warning $V=$($V) ($(value $V))))) + + + diff --git a/testing/tests/Makefile.runner b/testing/tests/Makefile.runner new file mode 100755 index 00000000000..ac98b32bc04 --- /dev/null +++ b/testing/tests/Makefile.runner @@ -0,0 +1,27 @@ +#Test builder and runner make file +# each test needs make compiole, make upload, make getResult +#this also need to be done for the build for each environment + + +#Board info +BOARD ?= atmega328 +PORT ?= /dev/ttyUSB0 +UPLOAD_SPEED ?= 57600 + +#Arduino info + +ARD_SRC_HOME ?= /home/ricklon/projects/Arduino +ARD_HOME ?= $(ARD_SRC_HOME)/build/linux/work +SKT_DIR ?= $(ARD_SRC_HOME)/testing/tests + +#Toolchain info +AVRDUDE_BIN ?= /usr/bin +ARD_BIN ?= /usr/bin +AVRDUDE_CONF ?=/etc/avrdude.conf +PROGRAMMER = stk500v1 +LIB_DIRS = $(wildcard $(ARD_HOME)/libraries/*) $(wildcard $(ARD_HOME)/libraries/*/utility) + +OUTPUT_DIR ?= OUT + + +include Makefile.master diff --git a/testing/tests/Makefile.windows b/testing/tests/Makefile.windows new file mode 100644 index 00000000000..e0a38cf6f86 --- /dev/null +++ b/testing/tests/Makefile.windows @@ -0,0 +1,28 @@ +#Test builder and runner make file +# each test needs make compiole, make upload, make getResult +#this also need to be done for the build for each environment + + +#Board info +BOARD ?= atmega328 +PORT ?= /dev/ttyUSB0 +UPLOAD_SPEED ?= 57600 + +#Arduino info +#/home/ricklon/projects/Arduino/testing/tests +TARGET_OS ?= windows +ARD_SRC_HOME ?= /home/ricklon/projects/Arduino +ARD_HOME ?= $(ARD_SRC_HOME)/build/$(TARGET_OS)/work +SKT_DIR ?= $(ARD_SRC_HOME)/testing/tests + +#Toolchain info +AVRDUDE_BIN ?= $(ARD_HOME)/hardware/tools/avr/bin +ARD_BIN ?= $(ARD_HOME)/hardware/tools/avr/bin +AVRDUDE_CONF ?= $(ARD_HOME)/hardware/tools/avr/etc/avrdude.conf +PROGRAMMER = stk500v1 +LIB_DIRS = $(wildcard $(ARD_HOME)/libraries/*) $(wildcard $(ARD_HOME)/libraries/*/utility) + +OUTPUT_DIR ?= OUT + + +include Makefile.master diff --git a/testing/tests/README b/testing/tests/README new file mode 100644 index 00000000000..612b875f630 --- /dev/null +++ b/testing/tests/README @@ -0,0 +1,21 @@ +#Changes being implemented for running sketches +Use boards.txt as the list of boards and properties. +Must be able to build the custom libraries. +Must be able to build the core libraries if needed. +If possible autodetect the board type. +Be able to specify a board type on command line. +Be able to query the ports and identify all the boards attached. +No need to go to any Java code for compiling. +Be able to specify upload target specify board type, port and all +appropriate targets executed, and upload occurs properly. + +Examples to start with: +Dump all vars: +make -f Makefile.runner env "SKETCH=ATS_Skeleton" + +Make a sketch: +make -f Makefile.runner all "SKETCH=ATS_Skeleton" + +Clean: +make -f Makefile.runner clean +