Skip to content

Commit

Permalink
Fix hangs (#9)
Browse files Browse the repository at this point in the history
* QLineSeries instead QSplineSeries

* Increase buffer, add reset connection
  • Loading branch information
donarturo11 committed Dec 7, 2023
1 parent 0049ba4 commit ba8d1a0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/GUI/GraphsWidget/TGWaveWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ TGWaveWidget::TGWaveWidget(QWidget *parent)
: TGWidget(parent)
{
_cur_pos = 0;
_series = new QSplineSeries;
_series = new QLineSeries;
init();
}

Expand Down
4 changes: 2 additions & 2 deletions src/GUI/GraphsWidget/TGWaveWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define TGWAVE_WIDGET_H
#include "TGWidget.h"
#include <QList>
#include <QSplineSeries>
#include <QLineSeries>

#define MAXRAWVALUE 2048.0000
#define SAMPLERATE 512.0000
Expand All @@ -14,7 +14,7 @@ class TGWaveWidget : public TGWidget
TGWaveWidget(QWidget *parent = nullptr);
~TGWaveWidget();
void insertValue(int val);
QSplineSeries* series() { return reinterpret_cast<QSplineSeries*>(_series); }
QLineSeries* series() { return reinterpret_cast<QLineSeries*>(_series); }
private:
void update();
void setupAxes();
Expand Down
4 changes: 3 additions & 1 deletion src/QThinkGear/QThinkGear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void QThinkGear::close()
void QThinkGear::onReadyRead()
{
int bufsize = _device.readBufferSize();
char buffer[1024];
char buffer[BUFFER_SIZE];
int size = _device.bytesAvailable();
if (size) {
changeStatus(ThinkGearStatus::Reading);
Expand All @@ -64,6 +64,8 @@ void QThinkGear::checkState()
{
if (!_device.waitForReadyRead(10)) {
changeStatus(ThinkGearStatus::Idle);
close();
open();
emit receiveStatusChanged(0);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/QThinkGear/QThinkGear.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "ThinkGearStreamParser.h"
#include "QThinkGearDataHandler.h"

#define BUFFER_SIZE 2048

const int ThinkgearBaudrates[] {
57600, 9600
};
Expand Down

0 comments on commit ba8d1a0

Please sign in to comment.