diff options
| -rw-r--r-- | qpsxserial.cpp | 86 | ||||
| -rw-r--r-- | qpsxserial.h | 3 |
2 files changed, 57 insertions, 32 deletions
diff --git a/qpsxserial.cpp b/qpsxserial.cpp index 4ea7567..a87f109 100644 --- a/qpsxserial.cpp +++ b/qpsxserial.cpp @@ -18,7 +18,10 @@ QPSXSerial::QPSXSerial(QWidget *parent, APP_INTERFACE interface) : write_ready(false), byte_sent_received(false), first_entered(false), - disable_psx_stdout(false) + disable_psx_stdout(false), + packet_sz(8), + version(0), + dump(false) { connect(&lost_packet_timer, SIGNAL(timeout()), this, SLOT(onPacketLost())); connect(&serial, SIGNAL(bytesWritten(qint64)), this, SLOT(onBytesWritten(qint64))); @@ -75,7 +78,7 @@ void QPSXSerial::onLoadFileBtnReleased(void) { selectedFolder = QFileDialog::getExistingDirectory( this, "Load folder with PSX data", - "C:/", + "/home/xavier/OpenSend/cdimg", QFileDialog::ShowDirsOnly ); if (selectedFolder.isEmpty()) @@ -166,6 +169,7 @@ void QPSXSerial::connectToPSXTimeout(void) if (ack == false) { ba.append(99); + printf("->99\n"); serial.write(ba); @@ -194,6 +198,9 @@ void QPSXSerial::onReadyRead(void) static QTime time = QTime::currentTime(); static bool cdrom_petition; + if (version && data.count() != 1) + qDebug() << data; + if (exe_sent) { static QByteArray fileName; @@ -213,6 +220,7 @@ void QPSXSerial::onReadyRead(void) } } + qDebug() << data; if (cdrom_petition) @@ -326,7 +334,15 @@ void QPSXSerial::onReadyRead(void) qDebug() << "An error happened when sending EXE file!"; } - exe_sent = true; + /*exe_sent = true;*/ + exe_sent = false; + lost_packet_timer.stop(); + dump = false; + ack = false; + first_entered = false; + packet_sz = 128; + version = 1; + init_timer.start(); } } } @@ -348,7 +364,7 @@ bool QPSXSerial::sendExe(void) ack = false; - QByteArray data = f.read(2048 /* PSX-EXE header */); + QByteArray data = f.read(32 /* PSX-EXE header */); if (app_interface == GUI_APP) { @@ -366,7 +382,8 @@ bool QPSXSerial::sendExe(void) QByteArray send; write_ready = false; - QThread::msleep(100); + if (!version) + QThread::msleep(100); QApplication::processEvents(); @@ -377,37 +394,40 @@ bool QPSXSerial::sendExe(void) serial.write(send); } - if (app_interface == GUI_APP) + if (!version) { - ui->inFileName->setText("Sending PSX-EXE size..."); - } - else if (app_interface == CLI_APP) - { - printf("Sending PSX-EXE size...\n"); - } + if (app_interface == GUI_APP) + { + ui->inFileName->setText("Sending PSX-EXE size..."); + } + else if (app_interface == CLI_APP) + { + printf("Sending PSX-EXE size...\n"); + } - if (serial.waitForReadyRead() == false) - { - qDebug() << "Did not receive any ACK!"; - } - else - { - onReadyRead(); - } + if (serial.waitForReadyRead() == false) + { + qDebug() << "Did not receive any ACK!"; + } + else + { + onReadyRead(); + } - qDebug () << "Sending EXE size..."; + qDebug () << "Sending EXE size..."; - qint64 sz = f.size() - 2048; + qint64 sz = f.size() - 2048; - sendDataSize(static_cast<quint32>(sz)); + sendDataSize(static_cast<quint32>(sz)); - if (serial.waitForReadyRead() == false) - { - qDebug() << "Did not receive any ACK!"; - } - else - { - onReadyRead(); + if (serial.waitForReadyRead() == false) + { + qDebug() << "Did not receive any ACK!"; + } + else + { + onReadyRead(); + } } // Send file size without header @@ -420,6 +440,8 @@ bool QPSXSerial::sendExe(void) qDebug() << data.count(); + dump = true; + sendData(data, inputExe); f.close(); @@ -487,12 +509,12 @@ void QPSXSerial::sendData(QByteArray data, QString fileName) lost_packet_timer.setInterval(LOST_PACKET_TIMEOUT); lost_packet_timer.setSingleShot(true); - for (int i = 0; i < data.count(); i+= 8) + for (int i = 0; i < data.count(); i+= packet_sz) { QByteArray send; ack = false; - send.append(data.mid(i, 8)); + send.append(data.mid(i, packet_sz)); //qDebug() << "Sent packet"; diff --git a/qpsxserial.h b/qpsxserial.h index 21050a5..eb2b9d5 100644 --- a/qpsxserial.h +++ b/qpsxserial.h @@ -65,6 +65,9 @@ private: QTimer lost_packet_timer; QStringList _paramlist; bool disable_psx_stdout; + int packet_sz; + int version; + bool dump; public slots: void cli_run(void); |
