diff options
| author | XaviDCR92 <xavi.dcr@gmail.com> | 2017-07-27 07:36:06 +0200 |
|---|---|---|
| committer | XaviDCR92 <xavi.dcr@gmail.com> | 2017-07-27 07:36:06 +0200 |
| commit | 36b9059c6c5777560fd4567d24e7bbb3b012bfbe (patch) | |
| tree | e334351da9d8e2843cdf69e789c43870e85ff069 | |
| parent | 011e7b092a9d17f534ca2963dc25a25a1f145fe5 (diff) | |
* Stdout console implemented. Test pending.
* Console now prints a formatted string starting with "#" and ending with "@" to indicate a CD-ROM filepath.
| -rw-r--r-- | qpsxserial.cpp | 115 | ||||
| -rw-r--r-- | qpsxserial.h | 5 | ||||
| -rw-r--r-- | release/QPSXSerial.exe | bin | 49664 -> 53760 bytes | |||
| -rw-r--r-- | stdout.ui | 42 | ||||
| -rw-r--r-- | stdout_dialog.ui | 45 |
5 files changed, 120 insertions, 87 deletions
diff --git a/qpsxserial.cpp b/qpsxserial.cpp index e9ace2f..5775d00 100644 --- a/qpsxserial.cpp +++ b/qpsxserial.cpp @@ -6,7 +6,8 @@ QPSXSerial::QPSXSerial(QWidget *parent) : QMainWindow(parent), - ui(new Ui::QPSXSerial) + ui(new Ui::QPSXSerial), + stdout_ui(new Ui::Stdout_Console) { ui->setupUi(this); lost_packet_timer = new QTimer(); @@ -47,7 +48,19 @@ void QPSXSerial::onStdOutButtonReleased(void) { QDialog* dialog_ui = new QDialog(); + qDebug() << "1"; + + stdout_ui->setupUi(dialog_ui); + + qDebug() << "2"; + + connect(stdout_ui->close_Btn, SIGNAL(released()), dialog_ui, SLOT(close())); + qDebug() << "3"; + connect(this, SIGNAL(debug_frame_received(QString)), stdout_ui->stdout_Log, SLOT(append(QString))); + qDebug() << "4"; + dialog_ui->show(); + qDebug() << "5"; } void QPSXSerial::onLoadFileBtnReleased(void) @@ -150,7 +163,7 @@ void QPSXSerial::onSendBtnReleased(void) init_timer = new QTimer(); init_timer->setSingleShot(true); - init_timer->setInterval(1000); + init_timer->setInterval(3000); connect(init_timer, SIGNAL(timeout(void)), this, SLOT(connectToPSXTimeout(void))); } @@ -164,7 +177,7 @@ void QPSXSerial::onSendBtnReleased(void) ui->inFileName->setVisible(true); - init_timer->start(1000); + init_timer->start(3000); ui->send_Btn->setText("Disconnect from PSX"); } @@ -173,6 +186,9 @@ void QPSXSerial::onSendBtnReleased(void) serial.close(); ui->send_Btn->setText("Send to PSX!"); qDebug() << "Disconnected"; + ui->exeProgressBar->setVisible(false); + exe_sent = false; + lost_packet_timer->stop(); init_timer->stop(); } } @@ -219,71 +235,86 @@ void QPSXSerial::onReadyRead(void) static bool first_entered = false; QByteArray data = serial.readAll(); static QTime time = QTime::currentTime(); + static bool cdrom_petition; //qDebug() << QString("Received ") + QString::number(data.count()) + QString(" bytes."); //qDebug() << QString("Took ") + QString::number(time.msecsTo(QTime::currentTime())); if(exe_sent == true) { - //qDebug() << data; + static QByteArray fileName; - QByteArray header = data.left(5); + if(data.startsWith("#") == true) + { + cdrom_petition = true; + fileName.clear(); + } - if(header == "cdrom") + if(data.count() == 1) { - qDebug() << "INPUT FRAME: " + data; - QString filePath = QString(data); + if(data.at(0) == 'b') + { + ack = true; + return; + } + } - filePath.remove("cdrom:\\"); + if(cdrom_petition == true) + { + fileName.append(data); - qDebug() << "selectedFolder = " + selectedFolder; + if(fileName.endsWith("@") == true) + { + cdrom_petition = false; - filePath.prepend(selectedFolder); + qDebug() << "INPUT FRAME: " + fileName; + QString filePath = QString(fileName); - filePath.replace("\\", "/"); + filePath.remove("@"); + filePath.remove("#"); - filePath.chop(2); // Remove ending ";1" + filePath.remove("cdrom:\\"); - qDebug() << "filePath = " + filePath; + qDebug() << "selectedFolder = " + selectedFolder; - QFile f(filePath); + filePath.prepend(selectedFolder); - if(f.open(QFile::ReadOnly) == false) - { - qDebug() << "Error while reading input file!"; - return; - } + filePath.replace("\\", "/"); - QByteArray file_data = f.readAll(); - quint32 sz = file_data.count(); + filePath.chop(2); // Remove ending ";1" - sendDataSize(sz); + qDebug() << "filePath = " + filePath; - while(ack == false) - { - QApplication::processEvents(); - } + QFile f(filePath); - qDebug() << "sendData for file..."; + if(f.open(QFile::ReadOnly) == false) + { + qDebug() << "Error while reading input file!"; + return; + } - sendData(file_data, filePath); + QByteArray file_data = f.readAll(); + quint32 sz = file_data.count(); - f.close(); - } - else - { - if(data.count() == 1) - { - if(data.at(0) == 'b') + sendDataSize(sz); + + while(ack == false) { - ack = true; + QApplication::processEvents(); } - } - else - { - qDebug() << data; + + qDebug() << "sendData for file..."; + + sendData(file_data, filePath); + + f.close(); } } + else + { + qDebug() << data; + emit debug_frame_received(QString(data)); + } } if(data.isEmpty() == false) @@ -380,6 +411,8 @@ bool QPSXSerial::sendExe(void) f.close(); + qDebug() << "PSX-EXE sent successfully!"; + return true; } diff --git a/qpsxserial.h b/qpsxserial.h index 4349f5b..13d098e 100644 --- a/qpsxserial.h +++ b/qpsxserial.h @@ -9,7 +9,7 @@ #include <QThread> #include <QTime> #include <QWinTaskbarButton> -#include "ui_stdout_dialog.h" +#include "ui_stdout.h" namespace Ui { class QPSXSerial; @@ -52,6 +52,9 @@ private slots: void connectToPSXTimeout(void); void onPacketLost(void); void onStdOutButtonReleased(void); + +signals: + void debug_frame_received(QString); }; #endif // QPSXSERIAL_H diff --git a/release/QPSXSerial.exe b/release/QPSXSerial.exe Binary files differindex 7642f18..1c67436 100644 --- a/release/QPSXSerial.exe +++ b/release/QPSXSerial.exe diff --git a/stdout.ui b/stdout.ui new file mode 100644 index 0000000..b68e505 --- /dev/null +++ b/stdout.ui @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Stdout_Console</class> + <widget class="QDialog" name="Stdout_Console"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>389</width> + <height>320</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <widget class="QPushButton" name="close_Btn"> + <property name="geometry"> + <rect> + <x>280</x> + <y>260</y> + <width>75</width> + <height>23</height> + </rect> + </property> + <property name="text"> + <string>Close</string> + </property> + </widget> + <widget class="QTextEdit" name="stdout_Log"> + <property name="geometry"> + <rect> + <x>30</x> + <y>20</y> + <width>321</width> + <height>231</height> + </rect> + </property> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/stdout_dialog.ui b/stdout_dialog.ui deleted file mode 100644 index ad110c1..0000000 --- a/stdout_dialog.ui +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Stdout_Console</class> - <widget class="QMainWindow" name="Stdout_Console"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>258</height> - </rect> - </property> - <property name="windowTitle"> - <string>QPSXSerial</string> - </property> - <widget class="QWidget" name="centralWidget"> - <widget class="QPushButton" name="close_Button"> - <property name="geometry"> - <rect> - <x>340</x> - <y>230</y> - <width>51</width> - <height>23</height> - </rect> - </property> - <property name="text"> - <string>Close</string> - </property> - </widget> - <widget class="QTextEdit" name="textEdit"> - <property name="geometry"> - <rect> - <x>30</x> - <y>20</y> - <width>341</width> - <height>201</height> - </rect> - </property> - </widget> - </widget> - </widget> - <layoutdefault spacing="6" margin="11"/> - <resources/> - <connections/> -</ui> |
