Big change to serial code - moved out to its own class and thread. Serial comm is now run on a separate thread. This code now certainly leaks a small amount of memory but that'll get fixed.

This commit is contained in:
Collin Kidder
2015-05-06 22:22:14 -04:00
parent c37bca4132
commit 5f4fd37839
5 changed files with 249 additions and 168 deletions
+7 -18
View File
@@ -13,18 +13,6 @@ namespace Ui {
class MainWindow;
}
enum STATE //keep this enum synchronized with the Arduino firmware project
{
IDLE,
GET_COMMAND,
BUILD_CAN_FRAME,
TIME_SYNC,
GET_DIG_INPUTS,
GET_ANALOG_INPUTS,
SET_DIG_OUTPUTS,
SETUP_CANBUS
};
class MainWindow : public QMainWindow
{
Q_OBJECT
@@ -37,20 +25,22 @@ private slots:
void handleLoadFile();
void handleSaveFile();
void connButtonPress();
void readSerialData();
void showGraphingWindow();
void showFrameDataAnalysis();
void clearFrames();
void showPlaybackWindow();
public slots:
void gotFrame(CANFrame *frame);
signals:
void sendSerialPort(QString portName);
private:
Ui::MainWindow *ui;
CANFrameModel *model;
QSerialPort *port;
QThread serialWorkerThread;
QByteArray inputBuffer;
STATE rx_state;
int rx_step;
CANFrame buildFrame;
GraphingWindow *graphingWindow;
FrameInfoWindow *frameInfoWindow;
FramePlaybackWindow *playbackWindow;
@@ -65,7 +55,6 @@ private:
void saveLogFile(QString);
void saveMicrochipFile(QString);
void addFrameToDisplay(CANFrame &, bool);
void procRXChar(unsigned char);
};
#endif // MAINWINDOW_H