From bf9c55db66741f5af79e52caef0676be469d415b Mon Sep 17 00:00:00 2001 From: meepingsnesroms Date: Tue, 29 May 2018 13:51:09 -0700 Subject: [PATCH] Debug path setting for some reason nothing is written to the debug path --- localTester/LocalTester/LocalTester.pro.user | 2 +- localTester/LocalTester/mainwindow.cpp | 3 ++ localTester/LocalTester/serialportio.cpp | 7 ++-- .../LocalTester/testexecutionenviroment.cpp | 11 ++++-- .../LocalTester/testexecutionenviroment.h | 2 ++ localTester/dependencyBlob.js | 35 +++++++++++++++---- localTester/jsTests/relayFromSerialPort.js | 29 ++++++++++----- 7 files changed, 67 insertions(+), 22 deletions(-) diff --git a/localTester/LocalTester/LocalTester.pro.user b/localTester/LocalTester/LocalTester.pro.user index 7b88ce2..8502bb7 100644 --- a/localTester/LocalTester/LocalTester.pro.user +++ b/localTester/LocalTester/LocalTester.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/localTester/LocalTester/mainwindow.cpp b/localTester/LocalTester/mainwindow.cpp index 5cc30be..8c5b3b4 100644 --- a/localTester/LocalTester/mainwindow.cpp +++ b/localTester/LocalTester/mainwindow.cpp @@ -32,6 +32,9 @@ MainWindow::MainWindow(QWidget* parent) : dependencyBlob = ""; testProgram = ""; + //temporary + testEnv.setErrorPath("/Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/localTester/jsError.log"); + refreshWindow = new QTimer(this); connect(refreshWindow, SIGNAL(timeout()), this, SLOT(updateWindow())); } diff --git a/localTester/LocalTester/serialportio.cpp b/localTester/LocalTester/serialportio.cpp index db5c537..7202c0b 100644 --- a/localTester/LocalTester/serialportio.cpp +++ b/localTester/LocalTester/serialportio.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -11,7 +12,7 @@ SerialPortIO::SerialPortIO(QString serialDeviceFilePath) : QObject(nullptr){ deviceFilePath = serialDeviceFilePath; - deviceFile = open(serialDeviceFilePath.toStdString().c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK); + deviceFile = open(serialDeviceFilePath.toStdString().c_str(), O_RDWR | O_NOCTTY); if(deviceFile < 0) throw std::invalid_argument("Cant open file!"); } @@ -29,11 +30,11 @@ unsigned int SerialPortIO::bytesAvailable(){ void SerialPortIO::transmitUint8(unsigned int data){ uint8_t realData = data; - write(deviceFile, &realData, 1); + send(deviceFile, &realData, 1, MSG_DONTWAIT); } unsigned int SerialPortIO::receiveUint8(){ uint8_t data = 0x00; - read(deviceFile, &data, 1); + recv(deviceFile, &data, 1, MSG_DONTWAIT); return data; } diff --git a/localTester/LocalTester/testexecutionenviroment.cpp b/localTester/LocalTester/testexecutionenviroment.cpp index 576a9d8..2a0c02a 100644 --- a/localTester/LocalTester/testexecutionenviroment.cpp +++ b/localTester/LocalTester/testexecutionenviroment.cpp @@ -11,6 +11,7 @@ TestExecutionEnviroment::TestExecutionEnviroment(){ jsRunning = false; + errorFilePath = ""; lastProgramReturnValue = ""; engine = new QJSEngine(); } @@ -25,15 +26,19 @@ void TestExecutionEnviroment::jsThreadFunction(QString program, QString args, bo if(callMain){ QJSValue jsGlobal = engine->globalObject(); jsGlobal.setProperty("__programArgs", QJSValue(args)); - engine->evaluate(program); - lastProgramReturnValue = engine->evaluate("main(__programArgs);").toString(); + engine->evaluate(program, errorFilePath); + lastProgramReturnValue = engine->evaluate("main(__programArgs);", errorFilePath).toString(); } else{ - engine->evaluate(program); + engine->evaluate(program, errorFilePath); } jsRunning = false; } +void TestExecutionEnviroment::setErrorPath(QString path){ + errorFilePath = path; +} + void TestExecutionEnviroment::clearExecutionEnviroment(){ finish(); engine->collectGarbage(); diff --git a/localTester/LocalTester/testexecutionenviroment.h b/localTester/LocalTester/testexecutionenviroment.h index 0a30c1c..27b8471 100644 --- a/localTester/LocalTester/testexecutionenviroment.h +++ b/localTester/LocalTester/testexecutionenviroment.h @@ -13,6 +13,7 @@ private: QJSEngine* engine; std::thread jsThread; std::atomic jsRunning; + QString errorFilePath; QString lastProgramReturnValue; void jsThreadFunction(QString program, QString args, bool callMain); @@ -21,6 +22,7 @@ public: TestExecutionEnviroment(); ~TestExecutionEnviroment(); + void setErrorPath(QString path); void clearExecutionEnviroment(); void installClass(QString name, QObject* jsClass); diff --git a/localTester/dependencyBlob.js b/localTester/dependencyBlob.js index d056a63..9cf1942 100644 --- a/localTester/dependencyBlob.js +++ b/localTester/dependencyBlob.js @@ -4,8 +4,8 @@ var __BlobVersion = 1.0; var irdaCommands; -var trapNames; -var trapNumbers; +var trapNameFromNumber; +var trapNumberFromName; //constructors and converters @@ -1180,11 +1180,14 @@ var __trapList = [ ["sysTrapLastTrapNumber", 0xA475] ]; -for(var i in __trapList){ - trapNames[this[0]] = this[1]; - trapNumbers[this[1]] = this[0]; +/* +//currently causing crasing, just disable for now +for(var i = 0; i < __trapList.length; i++){ + trapNameFromNumber[__trapList[i][1]] = __trapList[i][0]; + trapNumberFromName[__trapList[i][0]] = __trapList[i][1]; } -__trapList = undefined;//free the memory +*/ +//__trapList = undefined;//free the memory //functions @@ -1194,7 +1197,27 @@ jsSystem.validDependencyBlob = function (version){ return false; } +serialPort.receiveBuffer = function (size){ + var array = [0]; + + for(var index = 0; index < size; index++) + array[index] = serialPort.receiveUint8(); + + return array; +} + +serialPort.flushFifo = function (){ + var buffer = [0]; + var size = serialPort.bytesAvailable(); + userIo.writeStringJs("Type of size:" + typeof size); + jsSystem.uSleep(16666 * 2); + serialPort.receiveBuffer(buffer, size); +} + function isAlphanumeric(char){ + if(typeof char === 'string') + char = char.charCodeAt(0); + if(!(char > 47 && char < 58)/*numeric (0-9)*/ && !(char > 64 && char < 91)/*upper alpha (A-Z)*/ && !(char > 96 && char < 123)/*lower alpha (a-z)*/) return false; return true; diff --git a/localTester/jsTests/relayFromSerialPort.js b/localTester/jsTests/relayFromSerialPort.js index d7e7261..56fec0c 100644 --- a/localTester/jsTests/relayFromSerialPort.js +++ b/localTester/jsTests/relayFromSerialPort.js @@ -1,16 +1,27 @@ function main(args){ //copy 100 chars from the serial port to user output userIo.writeStringJs("Started, wating on serial port"); - var string; - for(var count = 0; count < 100; count++){ - if(serialPort.bytesAvailable() > 0){ - var letter = serialPort.receiveUint8(); + var string = ""; + //userIo.writeStringJs("Type of serialPort:" + typeof serialPort); + //userIo.writeStringJs(trapNameFromNumber[0xA474].toString()); + //userIo.writeStringJs("Type of serialPort.flushFifo:" + typeof serialPort.flushFifo); + //serialPort.flushFifo = 2; + //userIo.writeStringJs("Type of serialPort.flushFifo:" + typeof serialPort.flushFifo); + userIo.writeStringJs("Blob is valid:" + jsSystem.validDependencyBlob(1.0).toString()); + userIo.writeStringJs("Bytes in FIFO before flush:" + serialPort.bytesAvailable().toString()); + serialPort.flushFifo(); + userIo.writeStringJs("Bytes in FIFO after flush:" + serialPort.bytesAvailable().toString()); + for(var count = 0; count < 10000; count++){ + //if(serialPort.bytesAvailable() > 0){ + var letter = String.fromCharCode(serialPort.receiveUint8()); if(isAlphanumeric(letter)) - string += String.fromCharCode(letter); - } - else{ - jsSystem.uSleep(16666); - } + string += letter; + else + string += " "; + //} + //else{ + // jsSystem.uSleep(16666); + //} } userIo.writeStringJs(string); userIo.writeStringJs("Ended");