summaryrefslogtreecommitdiff
path: root/qpsxserial.cpp
diff options
context:
space:
mode:
authorXaviDCR92 <xavi.dcr@gmail.com>2017-07-27 07:36:06 +0200
committerXaviDCR92 <xavi.dcr@gmail.com>2017-07-27 07:36:06 +0200
commit36b9059c6c5777560fd4567d24e7bbb3b012bfbe (patch)
treee334351da9d8e2843cdf69e789c43870e85ff069 /qpsxserial.cpp
parent011e7b092a9d17f534ca2963dc25a25a1f145fe5 (diff)
* Stdout console implemented. Test pending.
* Console now prints a formatted string starting with "#" and ending with "@" to indicate a CD-ROM filepath.
Diffstat (limited to 'qpsxserial.cpp')
-rw-r--r--qpsxserial.cpp115
1 files changed, 74 insertions, 41 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;
}