Skip to content

Commit

Permalink
TODO Squash
Browse files Browse the repository at this point in the history
  • Loading branch information
jrvollmer committed Oct 28, 2023
1 parent bcfd5db commit bfb7808
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 48 deletions.
2 changes: 2 additions & 0 deletions helpers/serialWrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "serialWrapper.h"
#include <cstring>


/**
Expand Down Expand Up @@ -36,6 +37,7 @@ size_t SerialWrapper::readLine(char* dest, size_t buffSize, int timeout) {
}*/

// Read in from serial
// TODO this->readable() check
if((err = this->read(dest + strlen, buffSize)) > 0) {
strlen += err;
// TODO Check for buffer overflow after read
Expand Down
6 changes: 0 additions & 6 deletions helpers/serialWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@
#define __SERIAL_WRAPPER_H__

#include "mbed.h"
#include <string.h>

// TODO REMOVE: #define BUFFER_SIZE 16

class SerialWrapper : public BufferedSerial {
public:
SerialWrapper(PinName tx, PinName rx, int baud=MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE): BufferedSerial(tx, rx, baud) {};
size_t readLine(char* dest, size_t buffSize, int timeout=10000);

// TODO private:
// BufferedSerial *serial;

};

#endif // __SERIAL_WRAPPER_H__
4 changes: 3 additions & 1 deletion testRunner.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "mbed.h"
// Helper includes
#include "serialWrapper.h"
// Test includes
#include "serialTest.cpp"

// Serial interface for BTF communication
Expand All @@ -8,7 +10,7 @@ SerialWrapper pc(USBTX, USBRX);

int main()
{
// Test BTF communication before running other tests
// Verify BTF communication before running other tests
SerialTest serialTest = SerialTest();
if(serialTest.execute()) {
// Run tests
Expand Down
4 changes: 1 addition & 3 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ All custom test classes must inherit the base `Test` class, as it defines a stan
#ifndef __CUSTOM_TEST__
#define __CUSTOM_TEST__

#include <cstring>
#include "test.h"
#include <string>

using namespace std;


class CustomTest : public Test {
Expand Down
40 changes: 2 additions & 38 deletions tests/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
#define __TEST_H__

#include "mbed.h"
#include "serialWrapper.h"
#include <cstring>
#include <string>
#include "serialWrapper.h"

using namespace std;

Expand Down Expand Up @@ -47,40 +48,20 @@ class Test {

// Signal to the BTF test runner to start the test
bool signalStart() {
// REMOVE bool started = false;
// REMOVE int attempts = 0;
char buff[7];

// Send start message to BTF test runner
printf("START TEST %s\n", testName.c_str());

// Read response from BTF test runner
// REMOVE Need this? memset(buff, '\0', sizeof(buff));
size_t nread = pc.readLine(buff, sizeof(buff));

// The response should be "READY"
return (nread == 5) && (strcmp(buff, "READY") == 0);
/* REMOVE
do {
// TODO Change to readLine with timeout
if(pc.readable()) {
pc.read(buff, sizeof(buff));
started = strncmp(buff, "READY", 5) == 0;
} else {
ThisThread::sleep_for(100);
attempts++;
}
} while(!started && (attempts < 100));
return started;*/
}

// Signal to the BTF test runner to end the test
bool signalEnd(bool result) {
// REMOVE bool ended = false;
// REMOVE int attempts = 0;
char buff[6];

// Send end message to BTF test runner
Expand All @@ -91,27 +72,10 @@ class Test {
}

// Read response from BTF test runner
// REMOVE Need this? memset(buff, '\0', sizeof(buff));
size_t nread = pc.readLine(buff, sizeof(buff));

// The response should be 'DONE'. If so, preserve the test result
return result && (nread == 4) && (strcmp(buff, "DONE") == 0);

/* REMOVE
do {
// TODO Change to readLine with timeout
if(pc.readable()) {
pc.read(buff, sizeof(buff));
ended = strncmp(buff, "DONE", 4) == 0;
} else {
ThisThread::sleep_for(100);
attempts++;
}
} while(!ended && (attempts < 100));
return ended;*/
}
};

Expand Down

0 comments on commit bfb7808

Please sign in to comment.