summaryrefslogtreecommitdiff
path: root/qpsxserial.h
blob: 21050a59aecd2c57687fb4af1f4c02deb4880d6a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef QPSXSERIAL_H
#define QPSXSERIAL_H

#include <QMainWindow>
#include <QtSerialPort/QSerialPort>
#include <QString>
#include <QDebug>
#include <QTimer>
#include <QThread>
#include <QTime>
#ifdef __WIN32__
#include <QWinTaskbarButton>
#endif
#include <QMessageBox>
#include <iostream>
#include "ui_stdout.h"

#define QPSXSERIAL_VERSION_STR      "0.5"
#define QPSXSERIAL_URL              "https://github.com/XaviDCR92/OpenSend"
#define OPENSEND_URL                "https://github.com/XaviDCR92/QPSXSerial/"

typedef enum
{
    CLI_APP,
    GUI_APP
}APP_INTERFACE;

namespace Ui {
class QPSXSerial;
}

class QPSXSerial : public QMainWindow
{
    Q_OBJECT

public:
    explicit QPSXSerial(QWidget *parent = nullptr, APP_INTERFACE interface = GUI_APP);
    ~QPSXSerial();
    void setParamList(QStringList param){_paramlist = param;}

private:
    bool            sendExe(void);
    void            sendData(QByteArray data, QString fileName);
    void            sendDataSize(quint32 size);
    void            showError(QString error);
    void            showHelp(void);
    QString         getInputExeFromFolder(QString *folder);
    void            showGUICLIerror(QString error);

    Ui::QPSXSerial      *ui;
    Ui::Stdout_Console  *stdout_ui;
    QDialog             *stdout_dialog;
    const APP_INTERFACE app_interface;
    QString             inputExe;
    QString             selectedPort;
    QString             selectedFolder;
    QSerialPort         serial;
    bool                ack;
    bool                exe_sent;
    QTimer              init_timer;
    bool                write_ready;
    bool                byte_sent_received;
    QByteArray          last_packet_sent;
    bool                first_entered;
    QTimer              lost_packet_timer;
    QStringList         _paramlist;
    bool                disable_psx_stdout;

public slots:
    void cli_run(void);

private slots:
    void onLoadFileBtnReleased(void);
    void onUpdatePortsBtnReleased(void);
    void onSendBtnReleased(void);
    void onPortSelectedComboBox(QString);
    void onBytesWritten(qint64);
    void onReadyRead(void);
    void connectToPSXTimeout(void);
    void onPacketLost(void);
    void onStdOutButtonReleased(void);

signals:
    void debug_frame_received(QString);
    void finished(void);
};

#endif // QPSXSERIAL_H