mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-07-13 08:43:01 -07:00
maybe fixed loading/unloading bug.
This commit is contained in:
parent
2deb4b6b46
commit
1a3c006469
6 changed files with 91 additions and 37 deletions
|
@ -63,6 +63,7 @@ extern "C" void ExitGraphics(void)
|
||||||
if (!gui)
|
if (!gui)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
delete gui;
|
gui->Exit();
|
||||||
|
//delete gui;
|
||||||
gui = NULL;
|
gui = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ extern uint8_t DemodBuffer[MAX_DEMOD_BUF_LEN];
|
||||||
extern size_t DemodBufferLen;
|
extern size_t DemodBufferLen;
|
||||||
extern size_t g_DemodStartIdx;
|
extern size_t g_DemodStartIdx;
|
||||||
extern bool showDemod;
|
extern bool showDemod;
|
||||||
|
extern uint8_t g_debugMode;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "proxguiqt.h"
|
|
||||||
#include "proxgui.h"
|
#include "proxgui.h"
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
//#include <ctime>
|
//#include <ctime>
|
||||||
|
@ -47,6 +46,11 @@ void ProxGuiQT::HideGraphWindow(void)
|
||||||
emit HideGraphWindowSignal();
|
emit HideGraphWindowSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProxGuiQT::Exit(void)
|
||||||
|
{
|
||||||
|
emit ExitSignal();
|
||||||
|
}
|
||||||
|
|
||||||
void ProxGuiQT::_ShowGraphWindow(void)
|
void ProxGuiQT::_ShowGraphWindow(void)
|
||||||
{
|
{
|
||||||
if(!plotapp)
|
if(!plotapp)
|
||||||
|
@ -74,6 +78,9 @@ void ProxGuiQT::_HideGraphWindow(void)
|
||||||
plotwidget->hide();
|
plotwidget->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProxGuiQT::_Exit(void) {
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
void ProxGuiQT::MainLoop()
|
void ProxGuiQT::MainLoop()
|
||||||
{
|
{
|
||||||
plotapp = new QApplication(argc, argv);
|
plotapp = new QApplication(argc, argv);
|
||||||
|
@ -81,6 +88,7 @@ void ProxGuiQT::MainLoop()
|
||||||
connect(this, SIGNAL(ShowGraphWindowSignal()), this, SLOT(_ShowGraphWindow()));
|
connect(this, SIGNAL(ShowGraphWindowSignal()), this, SLOT(_ShowGraphWindow()));
|
||||||
connect(this, SIGNAL(RepaintGraphWindowSignal()), this, SLOT(_RepaintGraphWindow()));
|
connect(this, SIGNAL(RepaintGraphWindowSignal()), this, SLOT(_RepaintGraphWindow()));
|
||||||
connect(this, SIGNAL(HideGraphWindowSignal()), this, SLOT(_HideGraphWindow()));
|
connect(this, SIGNAL(HideGraphWindowSignal()), this, SLOT(_HideGraphWindow()));
|
||||||
|
connect(this, SIGNAL(ExitSignal()), this, SLOT(_Exit()));
|
||||||
|
|
||||||
plotapp->exec();
|
plotapp->exec();
|
||||||
}
|
}
|
||||||
|
@ -92,12 +100,11 @@ ProxGuiQT::ProxGuiQT(int argc, char **argv) : plotapp(NULL), plotwidget(NULL),
|
||||||
|
|
||||||
ProxGuiQT::~ProxGuiQT(void)
|
ProxGuiQT::~ProxGuiQT(void)
|
||||||
{
|
{
|
||||||
if (plotwidget) {
|
//if (plotwidget) {
|
||||||
//plotwidget->close();
|
//plotwidget->destroy(true,true);
|
||||||
delete plotwidget;
|
// delete plotwidget;
|
||||||
plotwidget = NULL;
|
// plotwidget = NULL;
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (plotapp) {
|
if (plotapp) {
|
||||||
plotapp->quit();
|
plotapp->quit();
|
||||||
delete plotapp;
|
delete plotapp;
|
||||||
|
@ -108,22 +115,21 @@ ProxGuiQT::~ProxGuiQT(void)
|
||||||
//--------------------
|
//--------------------
|
||||||
void ProxWidget::applyOperation()
|
void ProxWidget::applyOperation()
|
||||||
{
|
{
|
||||||
printf("ApplyOperation()");
|
//printf("ApplyOperation()");
|
||||||
save_restoreGB(1);
|
save_restoreGB(1);
|
||||||
memcpy(GraphBuffer, s_Buff, sizeof(int) * GraphTraceLen);
|
memcpy(GraphBuffer, s_Buff, sizeof(int) * GraphTraceLen);
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
|
|
||||||
}
|
}
|
||||||
void ProxWidget::stickOperation()
|
void ProxWidget::stickOperation()
|
||||||
{
|
{
|
||||||
save_restoreGB(0);
|
save_restoreGB(0);
|
||||||
printf("stickOperation()");
|
//printf("stickOperation()");
|
||||||
}
|
}
|
||||||
void ProxWidget::vchange_autocorr(int v)
|
void ProxWidget::vchange_autocorr(int v)
|
||||||
{
|
{
|
||||||
int ans;
|
int ans;
|
||||||
ans = AutoCorrelate(GraphBuffer, s_Buff, GraphTraceLen, v, true, false);
|
ans = AutoCorrelate(GraphBuffer, s_Buff, GraphTraceLen, v, true, false);
|
||||||
printf("vchange_autocorr(w:%d): %d\n", v, ans);
|
if (g_debugMode) printf("vchange_autocorr(w:%d): %d\n", v, ans);
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
}
|
}
|
||||||
void ProxWidget::vchange_askedge(int v)
|
void ProxWidget::vchange_askedge(int v)
|
||||||
|
@ -131,20 +137,20 @@ void ProxWidget::vchange_askedge(int v)
|
||||||
int ans;
|
int ans;
|
||||||
//extern int AskEdgeDetect(const int *in, int *out, int len, int threshold);
|
//extern int AskEdgeDetect(const int *in, int *out, int len, int threshold);
|
||||||
ans = AskEdgeDetect(GraphBuffer, s_Buff, GraphTraceLen, v);
|
ans = AskEdgeDetect(GraphBuffer, s_Buff, GraphTraceLen, v);
|
||||||
printf("vchange_askedge(w:%d)\n", v);
|
if (g_debugMode) printf("vchange_askedge(w:%d)%d\n", v, ans);
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
}
|
}
|
||||||
void ProxWidget::vchange_dthr_up(int v)
|
void ProxWidget::vchange_dthr_up(int v)
|
||||||
{
|
{
|
||||||
int down = opsController->horizontalSlider_dirthr_down->value();
|
int down = opsController->horizontalSlider_dirthr_down->value();
|
||||||
directionalThreshold(GraphBuffer, s_Buff, GraphTraceLen, v, down);
|
directionalThreshold(GraphBuffer, s_Buff, GraphTraceLen, v, down);
|
||||||
printf("vchange_dthr_up(%d)", v);
|
//printf("vchange_dthr_up(%d)", v);
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
|
|
||||||
}
|
}
|
||||||
void ProxWidget::vchange_dthr_down(int v)
|
void ProxWidget::vchange_dthr_down(int v)
|
||||||
{
|
{
|
||||||
printf("vchange_dthr_down(%d)", v);
|
//printf("vchange_dthr_down(%d)", v);
|
||||||
int up = opsController->horizontalSlider_dirthr_up->value();
|
int up = opsController->horizontalSlider_dirthr_up->value();
|
||||||
directionalThreshold(GraphBuffer,s_Buff, GraphTraceLen, v, up);
|
directionalThreshold(GraphBuffer,s_Buff, GraphTraceLen, v, up);
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
|
@ -157,7 +163,7 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent)
|
||||||
|
|
||||||
/** Setup the controller widget **/
|
/** Setup the controller widget **/
|
||||||
|
|
||||||
QWidget* controlWidget = new QWidget();
|
controlWidget = new QWidget();
|
||||||
opsController = new Ui::Form();
|
opsController = new Ui::Form();
|
||||||
opsController->setupUi(controlWidget);
|
opsController->setupUi(controlWidget);
|
||||||
//Due to quirks in QT Designer, we need to fiddle a bit
|
//Due to quirks in QT Designer, we need to fiddle a bit
|
||||||
|
@ -189,9 +195,43 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent)
|
||||||
//layout->addWidget(slider);
|
//layout->addWidget(slider);
|
||||||
layout->addWidget(plot);
|
layout->addWidget(plot);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
printf("Proxwidget Constructor just set layout\r\n");
|
//printf("Proxwidget Constructor just set layout\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// not 100% sure what i need in this block
|
||||||
|
// feel free to fix - marshmellow...
|
||||||
|
ProxWidget::~ProxWidget(void)
|
||||||
|
{
|
||||||
|
if (controlWidget) {
|
||||||
|
controlWidget->close();
|
||||||
|
delete controlWidget;
|
||||||
|
controlWidget = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opsController) {
|
||||||
|
delete opsController;
|
||||||
|
opsController = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plot) {
|
||||||
|
plot->close();
|
||||||
|
delete plot;
|
||||||
|
plot = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void ProxWidget::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
event->ignore();
|
||||||
|
this->hide();
|
||||||
|
}
|
||||||
|
void ProxWidget::hideEvent(QHideEvent *event) {
|
||||||
|
controlWidget->hide();
|
||||||
|
plot->hide();
|
||||||
|
}
|
||||||
|
void ProxWidget::showEvent(QShowEvent *event) {
|
||||||
|
controlWidget->show();
|
||||||
|
plot->show();
|
||||||
|
}
|
||||||
|
|
||||||
//----------- Plotting
|
//----------- Plotting
|
||||||
|
|
||||||
|
@ -242,7 +282,7 @@ void Plot::PlotDemod(uint8_t *buffer, size_t len, QRect plotRect, QRect annotati
|
||||||
// round down
|
// round down
|
||||||
if (DemodStart-plotOffset > 0) BitStart = (int)(((DemodStart-plotOffset)+(PlotGridX-1))/PlotGridX)-1;
|
if (DemodStart-plotOffset > 0) BitStart = (int)(((DemodStart-plotOffset)+(PlotGridX-1))/PlotGridX)-1;
|
||||||
first_delta_x += BitStart * PlotGridX;
|
first_delta_x += BitStart * PlotGridX;
|
||||||
if (BitStart > len) return;
|
if (BitStart > (int)len) return;
|
||||||
int delta_x = 0;
|
int delta_x = 0;
|
||||||
int v = 0;
|
int v = 0;
|
||||||
//printf("first_delta_x %i, grid_delta_x %i, DemodStart %i, BitStart %i\n",first_delta_x,grid_delta_x,DemodStart, BitStart);
|
//printf("first_delta_x %i, grid_delta_x %i, DemodStart %i, BitStart %i\n",first_delta_x,grid_delta_x,DemodStart, BitStart);
|
||||||
|
@ -255,8 +295,8 @@ void Plot::PlotDemod(uint8_t *buffer, size_t len, QRect plotRect, QRect annotati
|
||||||
penPath.moveTo(x, y);
|
penPath.moveTo(x, y);
|
||||||
delta_x = 0;
|
delta_x = 0;
|
||||||
int clk = first_delta_x;
|
int clk = first_delta_x;
|
||||||
for(int i = BitStart; i < len && xCoordOf(delta_x+DemodStart, plotRect) < plotRect.right(); i++) {
|
for(int i = BitStart; i < (int)len && xCoordOf(delta_x+DemodStart, plotRect) < plotRect.right(); i++) {
|
||||||
for (int ii = 0; ii < (clk) && i < len && xCoordOf(DemodStart+delta_x+ii, plotRect) < plotRect.right() ; ii++ ) {
|
for (int ii = 0; ii < (clk) && i < (int)len && xCoordOf(DemodStart+delta_x+ii, plotRect) < plotRect.right() ; ii++ ) {
|
||||||
x = xCoordOf(DemodStart+delta_x+ii, plotRect);
|
x = xCoordOf(DemodStart+delta_x+ii, plotRect);
|
||||||
v = buffer[i]*200-100;
|
v = buffer[i]*200-100;
|
||||||
|
|
||||||
|
@ -407,8 +447,6 @@ void Plot::plotGridLines(QPainter* painter,QRect r)
|
||||||
void Plot::paintEvent(QPaintEvent *event)
|
void Plot::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
//QPainterPath penPath, whitePath, greyPath, lightgreyPath, cursorAPath, cursorBPath, cursorCPath, cursorDPath;
|
|
||||||
//QRect r;
|
|
||||||
QBrush brush(QColor(100, 255, 100));
|
QBrush brush(QColor(100, 255, 100));
|
||||||
QPen pen(QColor(100, 255, 100));
|
QPen pen(QColor(100, 255, 100));
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
// GUI (QT)
|
// GUI (QT)
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef PROXGUI_QT
|
||||||
|
#define PROXGUI_QT
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -51,19 +54,24 @@ class ProxGuiQT;
|
||||||
*/
|
*/
|
||||||
class ProxWidget : public QWidget
|
class ProxWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT;
|
Q_OBJECT; //needed for slot/signal classes
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
ProxGuiQT *master;
|
||||||
Plot *plot;
|
Plot *plot;
|
||||||
Ui::Form *opsController;
|
Ui::Form *opsController;
|
||||||
ProxGuiQT *master;
|
QWidget* controlWidget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ProxWidget(QWidget *parent = 0, ProxGuiQT *master = NULL);
|
ProxWidget(QWidget *parent = 0, ProxGuiQT *master = NULL);
|
||||||
|
~ProxWidget(void);
|
||||||
|
//OpsShow(void);
|
||||||
|
|
||||||
//protected:
|
protected:
|
||||||
// void paintEvent(QPaintEvent *event);
|
// void paintEvent(QPaintEvent *event);
|
||||||
// void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
void showEvent(QShowEvent *event);
|
||||||
|
void hideEvent(QHideEvent *event);
|
||||||
// void mouseMoveEvent(QMouseEvent *event);
|
// void mouseMoveEvent(QMouseEvent *event);
|
||||||
// void mousePressEvent(QMouseEvent *event) { mouseMoveEvent(event); }
|
// void mousePressEvent(QMouseEvent *event) { mouseMoveEvent(event); }
|
||||||
// void keyPressEvent(QKeyEvent *event);
|
// void keyPressEvent(QKeyEvent *event);
|
||||||
|
@ -94,14 +102,16 @@ class ProxGuiQT : public QObject
|
||||||
void RepaintGraphWindow(void);
|
void RepaintGraphWindow(void);
|
||||||
void HideGraphWindow(void);
|
void HideGraphWindow(void);
|
||||||
void MainLoop(void);
|
void MainLoop(void);
|
||||||
|
void Exit(void);
|
||||||
private slots:
|
private slots:
|
||||||
void _ShowGraphWindow(void);
|
void _ShowGraphWindow(void);
|
||||||
void _RepaintGraphWindow(void);
|
void _RepaintGraphWindow(void);
|
||||||
void _HideGraphWindow(void);
|
void _HideGraphWindow(void);
|
||||||
|
void _Exit(void);
|
||||||
signals:
|
signals:
|
||||||
void ShowGraphWindowSignal(void);
|
void ShowGraphWindowSignal(void);
|
||||||
void RepaintGraphWindowSignal(void);
|
void RepaintGraphWindowSignal(void);
|
||||||
void HideGraphWindowSignal(void);
|
void HideGraphWindowSignal(void);
|
||||||
|
void ExitSignal(void);
|
||||||
};
|
};
|
||||||
|
#endif // PROXGUI_QT
|
||||||
|
|
|
@ -176,12 +176,12 @@ static void *main_loop(void *targ) {
|
||||||
pthread_join(reader_thread, NULL);
|
pthread_join(reader_thread, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExitGraphics();
|
||||||
|
|
||||||
if (script_file) {
|
if (script_file) {
|
||||||
fclose(script_file);
|
fclose(script_file);
|
||||||
script_file = NULL;
|
script_file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExitGraphics();
|
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ int main(int argc, char* argv[]) {
|
||||||
.usb_present = 0,
|
.usb_present = 0,
|
||||||
.script_cmds_file = NULL
|
.script_cmds_file = NULL
|
||||||
};
|
};
|
||||||
pthread_t main_loop_threat;
|
pthread_t main_loop_thread;
|
||||||
|
|
||||||
|
|
||||||
sp = uart_open(argv[1]);
|
sp = uart_open(argv[1]);
|
||||||
|
@ -288,13 +288,16 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
// create a mutex to avoid interlacing print commands from our different threads
|
// create a mutex to avoid interlacing print commands from our different threads
|
||||||
pthread_mutex_init(&print_lock, NULL);
|
pthread_mutex_init(&print_lock, NULL);
|
||||||
|
pthread_create(&main_loop_thread, NULL, &main_loop, &marg);
|
||||||
|
|
||||||
pthread_create(&main_loop_threat, NULL, &main_loop, &marg);
|
// build ui/graph forms on separate thread (killed on main_loop_thread);
|
||||||
InitGraphics(argc, argv);
|
InitGraphics(argc, argv);
|
||||||
|
|
||||||
MainGraphics();
|
MainGraphics();
|
||||||
|
//this won't return until ExitGraphics() is called
|
||||||
|
|
||||||
|
//wait for thread to finish
|
||||||
|
pthread_join(main_loop_thread, NULL);
|
||||||
|
|
||||||
pthread_join(main_loop_threat, NULL);
|
|
||||||
|
|
||||||
// Clean up the port
|
// Clean up the port
|
||||||
if (offline == 0) {
|
if (offline == 0) {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#define UI_H__
|
#define UI_H__
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
void ShowGui(void);
|
void ShowGui(void);
|
||||||
void HideGraphWindow(void);
|
void HideGraphWindow(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue