mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Actually start using bits of the decoder framework.
This commit is contained in:
4
Makefile
4
Makefile
@@ -46,8 +46,8 @@ $(error You must have these pkg-config packages installed: $(PACKAGES))
|
||||
endif
|
||||
|
||||
export PROTOC = protoc
|
||||
export CC = gcc
|
||||
export CXX = g++
|
||||
export CC = clang
|
||||
export CXX = clang++
|
||||
export AR = ar rc
|
||||
export RANLIB = ranlib
|
||||
export STRIP = strip
|
||||
|
||||
@@ -17,7 +17,7 @@ USB::~USB() {}
|
||||
|
||||
static std::unique_ptr<CandidateDevice> selectDevice()
|
||||
{
|
||||
auto candidates = findUsbDevices({FLUXENGINE_ID, GREASEWEAZLE_ID});
|
||||
auto candidates = findUsbDevices();
|
||||
if (candidates.size() == 0)
|
||||
Error() << "no devices found (is one plugged in? Do you have the "
|
||||
"appropriate permissions?";
|
||||
|
||||
@@ -5,8 +5,11 @@
|
||||
#include "fmt/format.h"
|
||||
#include "usbfinder.h"
|
||||
#include "greaseweazle.h"
|
||||
#include "protocol.h"
|
||||
#include "libusbp.hpp"
|
||||
|
||||
static const std::set<uint32_t> VALID_DEVICES = { GREASEWEAZLE_ID, FLUXENGINE_ID };
|
||||
|
||||
static const std::string get_serial_number(const libusbp::device& device)
|
||||
{
|
||||
try
|
||||
@@ -21,8 +24,7 @@ static const std::string get_serial_number(const libusbp::device& device)
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<CandidateDevice>> findUsbDevices(
|
||||
const std::set<uint32_t>& ids)
|
||||
std::vector<std::unique_ptr<CandidateDevice>> findUsbDevices()
|
||||
{
|
||||
std::vector<std::unique_ptr<CandidateDevice>> candidates;
|
||||
for (const auto& it : libusbp::list_connected_devices())
|
||||
@@ -31,7 +33,7 @@ std::vector<std::unique_ptr<CandidateDevice>> findUsbDevices(
|
||||
candidate->device = it;
|
||||
|
||||
uint32_t id = (it.get_vendor_id() << 16) | it.get_product_id();
|
||||
if (ids.find(id) != ids.end())
|
||||
if (VALID_DEVICES.find(id) != VALID_DEVICES.end())
|
||||
{
|
||||
candidate->id = id;
|
||||
candidate->serial = get_serial_number(it);
|
||||
|
||||
@@ -12,7 +12,7 @@ struct CandidateDevice
|
||||
std::string serialPort;
|
||||
};
|
||||
|
||||
extern std::vector<std::unique_ptr<CandidateDevice>> findUsbDevices(const std::set<uint32_t>& id);
|
||||
extern std::vector<std::unique_ptr<CandidateDevice>> findUsbDevices();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -565,6 +565,7 @@ buildlibrary libfrontend.a \
|
||||
|
||||
buildlibrary libgui.a \
|
||||
-I$OBJDIR/proto \
|
||||
-Idep/libusbp/include \
|
||||
-d $OBJDIR/proto/libconfig.def \
|
||||
src/gui/main.cc \
|
||||
src/gui/layout.cpp \
|
||||
|
||||
@@ -53,20 +53,17 @@ MainWindowGen::MainWindowGen( wxWindow* parent, wxWindowID id, const wxString& t
|
||||
m_staticText4->Wrap( -1 );
|
||||
fgSizer3->Add( m_staticText4, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL, 5 );
|
||||
|
||||
wxArrayString deviceChoiceChoices;
|
||||
deviceChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, deviceChoiceChoices, 0 );
|
||||
deviceChoice->SetSelection( 0 );
|
||||
fgSizer3->Add( deviceChoice, 0, wxALL|wxEXPAND, 5 );
|
||||
deviceCombo = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_SORT );
|
||||
fgSizer3->Add( deviceCombo, 0, wxALL, 5 );
|
||||
|
||||
m_staticText5 = new wxStaticText( this, wxID_ANY, wxT("Flux source/sink:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText5->Wrap( -1 );
|
||||
fgSizer3->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL, 5 );
|
||||
|
||||
wxString fluxSourceSinkChoiceChoices[] = { wxT("drive:0"), wxT("drive:1"), wxT("file") };
|
||||
int fluxSourceSinkChoiceNChoices = sizeof( fluxSourceSinkChoiceChoices ) / sizeof( wxString );
|
||||
fluxSourceSinkChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, fluxSourceSinkChoiceNChoices, fluxSourceSinkChoiceChoices, 0 );
|
||||
fluxSourceSinkChoice->SetSelection( 0 );
|
||||
fgSizer3->Add( fluxSourceSinkChoice, 0, wxALL|wxEXPAND, 5 );
|
||||
fluxSourceSinkCombo = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
|
||||
fluxSourceSinkCombo->Append( wxT("drive:0") );
|
||||
fluxSourceSinkCombo->Append( wxT("drive:1") );
|
||||
fgSizer3->Add( fluxSourceSinkCombo, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
m_staticText51 = new wxStaticText( this, wxID_ANY, wxT("Format:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText51->Wrap( -1 );
|
||||
|
||||
@@ -310,11 +310,11 @@
|
||||
<property name="wrap">-1</property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
<property name="flag">wxALL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxChoice" expanded="0">
|
||||
<object class="wxComboBox" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
@@ -350,7 +350,7 @@
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">deviceChoice</property>
|
||||
<property name="name">deviceCombo</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
@@ -358,10 +358,10 @@
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="selection">0</property>
|
||||
<property name="selection">-1</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="style">wxCB_SORT</property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
@@ -369,6 +369,7 @@
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="value"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
@@ -435,11 +436,11 @@
|
||||
<property name="wrap">-1</property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxChoice" expanded="0">
|
||||
<object class="wxComboBox" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
@@ -453,7 +454,7 @@
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="choices">"drive:0" "drive:1" "file"</property>
|
||||
<property name="choices">"drive:0" "drive:1"</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
@@ -475,7 +476,7 @@
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">fluxSourceSinkChoice</property>
|
||||
<property name="name">fluxSourceSinkCombo</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
@@ -483,7 +484,7 @@
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="selection">0</property>
|
||||
<property name="selection">-1</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
@@ -494,6 +495,7 @@
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="value"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <wx/icon.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/combobox.h>
|
||||
#include <wx/choice.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/textctrl.h>
|
||||
@@ -41,9 +42,9 @@ class MainWindowGen : public wxFrame
|
||||
VisualisationControl* visualiser;
|
||||
wxButton* stopButton;
|
||||
wxStaticText* m_staticText4;
|
||||
wxChoice* deviceChoice;
|
||||
wxComboBox* deviceCombo;
|
||||
wxStaticText* m_staticText5;
|
||||
wxChoice* fluxSourceSinkChoice;
|
||||
wxComboBox* fluxSourceSinkCombo;
|
||||
wxStaticText* m_staticText51;
|
||||
wxChoice* formatChoice;
|
||||
wxCheckBox* highDensityToggle;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#include "globals.h"
|
||||
#include "proto.h"
|
||||
#include "gui.h"
|
||||
#include "fluxsource/fluxsource.h"
|
||||
#include "decoders/decoders.h"
|
||||
#include "lib/usb/usbfinder.h"
|
||||
#include "fmt/format.h"
|
||||
#include <wx/wx.h>
|
||||
#include "mainwindow.h"
|
||||
@@ -18,10 +21,14 @@ MainWindow::MainWindow(): MainWindowGen(nullptr)
|
||||
continue;
|
||||
|
||||
formatChoice->Append(it.first);
|
||||
_formats[it.first] = std::move(config);
|
||||
_formats.push_back(std::move(config));
|
||||
}
|
||||
|
||||
UpdateDevices();
|
||||
if (deviceCombo->GetCount() > 0)
|
||||
deviceCombo->SetValue(deviceCombo->GetString(0));
|
||||
|
||||
readFluxButton->Bind(wxEVT_BUTTON, &MainWindow::OnReadFluxButton, this);
|
||||
}
|
||||
|
||||
void MainWindow::OnExit(wxCommandEvent& event)
|
||||
@@ -29,8 +36,39 @@ void MainWindow::OnExit(wxCommandEvent& event)
|
||||
Close(true);
|
||||
}
|
||||
|
||||
void MainWindow::UpdateDevices()
|
||||
void MainWindow::OnReadFluxButton(wxCommandEvent&)
|
||||
{
|
||||
//auto candidates = findUsbDevices({FLUXENGINE_ID, GREASEWEAZLE_ID});
|
||||
ConfigProto config = *_formats[formatChoice->GetSelection()];
|
||||
|
||||
FluxSource::updateConfigForFilename(config.mutable_flux_source(),
|
||||
fluxSourceSinkCombo->GetValue().ToStdString());
|
||||
|
||||
auto serial = deviceCombo->GetValue().ToStdString();
|
||||
if (!serial.empty() && (serial[0] = '/'))
|
||||
setProtoByString(&config, "usb.greaseweazle.port", serial);
|
||||
else
|
||||
setProtoByString(&config, "usb.serial", serial);
|
||||
|
||||
runOnWorkerThread(
|
||||
/* Must make another copy of all local parameters. */
|
||||
[=]() {
|
||||
auto fluxSource = FluxSource::create(config.flux_source());
|
||||
auto decoder = AbstractDecoder::create(config.decoder());
|
||||
printf("Worker thread!\n");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void MainWindow::UpdateDevices()
|
||||
{
|
||||
auto candidates = findUsbDevices();
|
||||
|
||||
deviceCombo->Clear();
|
||||
_devices.clear();
|
||||
for (auto& candidate : candidates)
|
||||
{
|
||||
deviceCombo->Append(candidate->serial);
|
||||
_devices.push_back(std::move(candidate));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
#include "layout.h"
|
||||
|
||||
class CandidateDevice;
|
||||
class ConfigProto;
|
||||
|
||||
class MainWindow : public MainWindowGen
|
||||
{
|
||||
public:
|
||||
@@ -11,11 +13,13 @@ public:
|
||||
|
||||
private:
|
||||
void OnExit(wxCommandEvent& event);
|
||||
void OnReadFluxButton(wxCommandEvent&);
|
||||
|
||||
void UpdateDevices();
|
||||
|
||||
private:
|
||||
std::map<std::string, std::unique_ptr<ConfigProto>> _formats;
|
||||
std::vector<std::unique_ptr<ConfigProto>> _formats;
|
||||
std::vector<std::unique_ptr<CandidateDevice>> _devices;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user