I am trying to run a test code using the Aunit library in Arduino ide. I am not able to get the serial output. I tried different baud rates but it still won't work. Could anyone provide me with ideas to get serial output? Any help is appreciated.
#include <Arduino.h>
#include <AUnit.h>
using aunit::TestRunner;
// Include the header file with the turnEverythingOff function
#include "sketch_oct3a.h"
test(turnEverythingOffShouldTurnPinsToLow) {
digitalWrite(irrPump,HIGH);
digitalWrite(vacPump,HIGH);
digitalWrite(airPump,HIGH);
digitalWrite(vacValve,HIGH);
digitalWrite(airValve,HIGH);
int p_irrPump = 1;
int p_vacPump = 1;
int p_airPump = 1;
int p_vacValve = 1;
int p_airValve = 1;
turnEverythingOff();
// Assert: Check that the digitalWrite calls set the pins to LOW
assertEqual(1, p_irrPump-digitalRead(irrPump));
assertEqual(1, p_vacPump-digitalRead(vacPump));
assertEqual(1, p_airPump-digitalRead(airPump));
assertEqual(1, p_vacValve-digitalRead(vacValve));
assertEqual(1, p_airValve-digitalRead(airValve));
}
test(tubeblockerrorTest) {
tubeBlockError();
assertEqual(1, digitalRead(redLED));
assertEqual(0, digitalRead(greenLED));
assertEqual(1, digitalRead(blueLED));
}
test(valveCycleTest) {
valveCycle();
if(b==30 || b==60 || b==86){
int checkLeveltest = digitalRead(canisterLS);
if(checkLeveltest == HIGH){
//turneverythingoff
assertEqual(0, digitalRead(irrPump));
assertEqual(0, digitalRead(vacPump));
assertEqual(0, digitalRead(airPump));
assertEqual(0, digitalRead(vacValve));
assertEqual(0, digitalRead(airValve));
}
}
if(b==0 || b==11 || b==29 || b==59 || b==85){
assertEqual(1, digitalRead(airPump));
assertEqual(0, digitalRead(vacValve));
}
else if (b==17|| b==35|| b==52||b==69||b==84){ //86 to 84
assertEqual(0, digitalRead(vacValve));
}
else{
//turneverythingoff
assertEqual(0, digitalRead(irrPump));
assertEqual(0, digitalRead(vacPump));
assertEqual(0, digitalRead(airPump));
assertEqual(0, digitalRead(vacValve));
assertEqual(0, digitalRead(airValve));
}
}
test(haltCheckCycleTest) {
haltExecution = true;
haltCheckCycle();
//turneverythingoff
assertEqual(0, digitalRead(irrPump));
assertEqual(0, digitalRead(vacPump));
assertEqual(0, digitalRead(airPump));
assertEqual(0, digitalRead(vacValve));
assertEqual(0, digitalRead(airValve));
//greenled on
assertEqual(1, digitalRead(greenLED));
}
test(tubeCleanCycleTest) {
tubeCleanCycle();
//vaccum pumo low
assertEqual(0, digitalRead(vacPump));
//--haltcheckcycletest
assertEqual(1, digitalRead(greenLED));
//turneverythingoff
assertEqual(0, digitalRead(irrPump));
assertEqual(0, digitalRead(vacPump));
assertEqual(0, digitalRead(airPump));
assertEqual(0, digitalRead(vacValve));
assertEqual(0, digitalRead(airValve));
//greenled on
}
test(waterhaltCheckCycleTest) {
waterhaltCheckCycle();
int x = digitalRead(buttonUI);
if(x==LOW){
//turneverythingoff
assertEqual(0, digitalRead(irrPump));
assertEqual(0, digitalRead(vacPump));
assertEqual(0, digitalRead(airPump));
assertEqual(0, digitalRead(vacValve));
assertEqual(0, digitalRead(airValve));
//green led
assertEqual(1, digitalRead(greenLED));
}
}
test(irrigationCycleTest) {
int pumpTime = 5; // Set the desired pumpTime for testing
irrigationCycle(pumpTime);
delay(1000);
assertEqual(digitalRead(irrPump), HIGH);
delay(5000);
// Call your function
//assertTrue(haltCheckCycletest);
// Assuming you are setting the irrigation pump pin to HIGH
// assertEqual(digitalRead(irrPump), HIGH);
}
//----------------------------------------------------------------------------
// setup() and loop()
//----------------------------------------------------------------------------
void setup() {
WatchDog::init(blinkISR, 500);
attachInterrupt(digitalPinToInterrupt(buttonUI), buttonPressed1, CHANGE);
//----define pin modes - OUTPUT
pinMode(irrPump, OUTPUT);
pinMode(vacPump, OUTPUT);
pinMode(airPump, OUTPUT);
pinMode(vacValve, OUTPUT);
pinMode(airValve, OUTPUT);
pinMode(redLED, OUTPUT);
pinMode(blueLED, OUTPUT);
pinMode(greenLED, OUTPUT);
//---------Define pin modes - INPUT------------------------------------------------------//
pinMode(buttonUI, INPUT);
pinMode(canisterLS, INPUT);
pinMode(waterLS, INPUT);
pinMode(pressureSensor, INPUT);
//---------Default Variable LOW Condition-----------------------------------------------//
digitalWrite(waterLS, LOW);
digitalWrite(greenLED, LOW);
digitalWrite(redLED, LOW);
digitalWrite(blueLED, LOW);
//---------setup for ISR-for haltcheck_cycle-------------------------------------------//
cli();
TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
OCR1A = 15624;
TCCR1B |= (1 << WGM12);
TCCR1B |= (1 << CS12) | (1 << CS10);
TIMSK1 |= (1 << OCIE1A);
sei();
delay(1000); // wait for stability on some boards to prevent garbage Serial
Serial.begin(115200); // ESP8266 default of 74880 not supported on Linux
while (! Serial);
TestRunner::setPrinter(&Serial);
Serial.println("This test should produce the following:");
Serial.println(
"7s passed 0 skipped, 0 timed out, out of 7 test(s)."
);
Serial.println("----");
}
void loop() {
aunit::TestRunner::run();
}