Merge pull request #541 from cjcliffe/serial_detect

Fix rig control menu, add serial port detection and selection dialog
This commit is contained in:
Charles J. Cliffe 2017-04-20 20:52:44 -04:00 committed by GitHub
commit 43ed37b23c
13 changed files with 1704 additions and 10 deletions

View File

@ -390,6 +390,8 @@ SET (cubicsdr_sources
src/forms/Dialog/ActionDialog.cpp src/forms/Dialog/ActionDialog.cpp
src/forms/Dialog/AboutDialogBase.cpp src/forms/Dialog/AboutDialogBase.cpp
src/forms/Dialog/AboutDialog.cpp src/forms/Dialog/AboutDialog.cpp
src/forms/Dialog/PortSelectorDialogBase.cpp
src/forms/Dialog/PortSelectorDialog.cpp
external/lodepng/lodepng.cpp external/lodepng/lodepng.cpp
external/tinyxml/tinyxml.cpp external/tinyxml/tinyxml.cpp
external/tinyxml/tinystr.cpp external/tinyxml/tinystr.cpp
@ -497,6 +499,8 @@ SET (cubicsdr_headers
src/forms/Dialog/ActionDialog.h src/forms/Dialog/ActionDialog.h
src/forms/Dialog/AboutDialogBase.h src/forms/Dialog/AboutDialogBase.h
src/forms/Dialog/AboutDialog.h src/forms/Dialog/AboutDialog.h
src/forms/Dialog/PortSelectorDialogBase.h
src/forms/Dialog/PortSelectorDialog.h
external/lodepng/lodepng.h external/lodepng/lodepng.h
external/tinyxml/tinyxml.h external/tinyxml/tinyxml.h
external/tinyxml/tinystr.h external/tinyxml/tinystr.h
@ -541,11 +545,28 @@ IF (USE_HAMLIB)
SET (cubicsdr_headers SET (cubicsdr_headers
${cubicsdr_headers} ${cubicsdr_headers}
src/rig/RigThread.h src/rig/RigThread.h
external/rs232/rs232.h
) )
SET (cubicsdr_sources SET (cubicsdr_sources
${cubicsdr_sources} ${cubicsdr_sources}
src/rig/RigThread.cpp src/rig/RigThread.cpp
) )
IF(WIN32)
SET (cubicsdr_sources
${cubicsdr_sources}
external/rs232/rs232-win.cpp
)
ELSE()
SET (cubicsdr_sources
${cubicsdr_sources}
external/rs232/rs232-linux.cpp
)
ENDIF()
include_directories (
external/rs232/
)
ENDIF() ENDIF()
@ -583,6 +604,7 @@ SOURCE_GROUP("Forms\\Dialog" REGULAR_EXPRESSION "src/forms/Dialog/${REG_EXT}")
SOURCE_GROUP("SDR" REGULAR_EXPRESSION "src/sdr/${REG_EXT}") SOURCE_GROUP("SDR" REGULAR_EXPRESSION "src/sdr/${REG_EXT}")
IF(USE_HAMLIB) IF(USE_HAMLIB)
SOURCE_GROUP("Rig" REGULAR_EXPRESSION "src/rig/${REG_EXT}") SOURCE_GROUP("Rig" REGULAR_EXPRESSION "src/rig/${REG_EXT}")
SOURCE_GROUP("_ext-RS-232" REGULAR_EXPRESSION "external/rs232/${REG_EXT}")
ENDIF() ENDIF()
SOURCE_GROUP("Demodulator" REGULAR_EXPRESSION "src/demod/${REG_EXT}") SOURCE_GROUP("Demodulator" REGULAR_EXPRESSION "src/demod/${REG_EXT}")
SOURCE_GROUP("Modem" REGULAR_EXPRESSION "src/modules/modem/${REG_EXT}") SOURCE_GROUP("Modem" REGULAR_EXPRESSION "src/modules/modem/${REG_EXT}")

29
external/rs232/README vendored Normal file
View File

@ -0,0 +1,29 @@
Cross-platform serial / RS232 library
Version 0.21, 11/10/2015
The MIT License (MIT)
Supported platforms:
- Windows (XP / Win7, possibly 8 and 10)
- Linux
- MacOS X
Copyright (c) 2007 - 2015 Frédéric Meslin
Contact: fredericmeslin@hotmail.com, @marzacdev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

13
external/rs232/README.md vendored Normal file
View File

@ -0,0 +1,13 @@
# rs232
C / C++ RS232 cross-platform serial library
Version 0.21, 11/10/2015
Supported platforms:
- Windows (XP / Win7, possibly 8 and 10)
- Linux
- MacOS X
Copyright (c) 2013-2015 Frédéric Meslin
Email: fredericmeslin@hotmail.com
Website: www.fredslab.net
Twitter: @marzacdev

261
external/rs232/rs232-linux.cpp vendored Normal file
View File

@ -0,0 +1,261 @@
/*
Cross-platform serial / RS232 library
Version 0.21, 11/10/2015
-> LINUX and MacOS implementation
-> rs232-linux.c
The MIT License (MIT)
Copyright (c) 2013-2015 Frédéric Meslin, Florent Touchard
Email: fredericmeslin@hotmail.com
Website: www.fredslab.net
Twitter: @marzacdev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#if defined(__unix__) || defined(__unix) || \
defined(__APPLE__) && defined(__MACH__)
#define _DARWIN_C_SOURCE
#include "rs232.h"
#include <unistd.h>
#define __USE_MISC // For CRTSCTS
#include <termios.h>
#include <fcntl.h>
#include <dirent.h>
#define __USE_SVID // For strdup
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/*****************************************************************************/
/** Base name for COM devices */
#if defined(__APPLE__) && defined(__MACH__)
static const char * devBases[] = {
"tty."
};
static int noBases = 1;
#else
static const char * devBases[] = {
"ttyACM", "ttyUSB", "rfcomm", "ttyS"
};
static int noBases = 4;
#endif
/*****************************************************************************/
typedef struct {
char * port;
int handle;
} COMDevice;
#define COM_MAXDEVICES 64
static COMDevice comDevices[COM_MAXDEVICES];
static int noDevices = 0;
/*****************************************************************************/
/** Private functions */
void _AppendDevices(const char * base);
int _BaudFlag(int BaudRate);
/*****************************************************************************/
int comEnumerate()
{
for (int i = 0; i < noDevices; i++) {
if (comDevices[i].port) free(comDevices[i].port);
comDevices[i].port = NULL;
}
noDevices = 0;
for (int i = 0; i < noBases; i++)
_AppendDevices(devBases[i]);
return noDevices;
}
void comTerminate()
{
comCloseAll();
for (int i = 0; i < noDevices; i++) {
if (comDevices[i].port) free(comDevices[i].port);
comDevices[i].port = NULL;
}
}
int comGetNoPorts()
{
return noDevices;
}
/*****************************************************************************/
int comFindPort(const char * name)
{
int p;
for (p = 0; p < noDevices; p++)
if (strcmp(name, comDevices[p].port) == 0)
return p;
return -1;
}
const char * comGetInternalName(int index)
{
#define COM_MAXNAME 128
static char name[COM_MAXNAME];
if (index >= noDevices || index < 0)
return NULL;
sprintf(name, "/dev/%s", comDevices[index].port);
return name;
}
const char * comGetPortName(int index) {
if (index >= noDevices || index < 0)
return NULL;
return comDevices[index].port;
}
/*****************************************************************************/
int comOpen(int index, int baudrate)
{
if (index >= noDevices || index < 0)
return 0;
// Close if already open
COMDevice * com = &comDevices[index];
if (com->handle >= 0) comClose(index);
// Open port
printf("Try %s \n", comGetInternalName(index));
int handle = open(comGetInternalName(index), O_RDWR | O_NOCTTY | O_NDELAY);
if (handle < 0)
return 0;
printf("Open %s \n", comGetInternalName(index));
// General configuration
struct termios config;
memset(&config, 0, sizeof(config));
tcgetattr(handle, &config);
config.c_iflag &= ~(INLCR | ICRNL);
config.c_iflag |= IGNPAR | IGNBRK;
config.c_oflag &= ~(OPOST | ONLCR | OCRNL);
config.c_cflag &= ~(PARENB | PARODD | CSTOPB | CSIZE | CRTSCTS);
config.c_cflag |= CLOCAL | CREAD | CS8;
config.c_lflag &= ~(ICANON | ISIG | ECHO);
int flag = _BaudFlag(baudrate);
cfsetospeed(&config, flag);
cfsetispeed(&config, flag);
// Timeouts configuration
config.c_cc[VTIME] = 1;
config.c_cc[VMIN] = 0;
//fcntl(handle, F_SETFL, FNDELAY);
// Validate configuration
if (tcsetattr(handle, TCSANOW, &config) < 0) {
close(handle);
return 0;
}
com->handle = handle;
return 1;
}
void comClose(int index)
{
if (index >= noDevices || index < 0)
return;
COMDevice * com = &comDevices[index];
if (com->handle < 0)
return;
tcdrain(com->handle);
close(com->handle);
com->handle = -1;
}
void comCloseAll()
{
for (int i = 0; i < noDevices; i++)
comClose(i);
}
/*****************************************************************************/
int comWrite(int index, const char * buffer, size_t len)
{
if (index >= noDevices || index < 0)
return 0;
if (comDevices[index].handle <= 0)
return 0;
int res = write(comDevices[index].handle, buffer, len);
if (res < 0)
res = 0;
return res;
}
int comRead(int index, char * buffer, size_t len)
{
if (index >= noDevices || index < 0)
return 0;
if (comDevices[index].handle <= 0)
return 0;
int res = read(comDevices[index].handle, buffer, len);
if (res < 0)
res = 0;
return res;
}
/*****************************************************************************/
int _BaudFlag(int BaudRate)
{
switch(BaudRate)
{
case 50: return B50; break;
case 110: return B110; break;
case 134: return B134; break;
case 150: return B150; break;
case 200: return B200; break;
case 300: return B300; break;
case 600: return B600; break;
case 1200: return B1200; break;
case 1800: return B1800; break;
case 2400: return B2400; break;
case 4800: return B4800; break;
case 9600: return B9600; break;
case 19200: return B19200; break;
case 38400: return B38400; break;
case 57600: return B57600; break;
case 115200: return B115200; break;
case 230400: return B230400; break;
default : return B0; break;
}
}
void _AppendDevices(const char * base)
{
int baseLen = strlen(base);
struct dirent * dp;
// Enumerate devices
DIR * dirp = opendir("/dev");
while ((dp = readdir(dirp)) && noDevices < COM_MAXDEVICES) {
if (strlen(dp->d_name) >= baseLen) {
if (memcmp(base, dp->d_name, baseLen) == 0) {
COMDevice * com = &comDevices[noDevices ++];
com->port = (char *) strdup(dp->d_name);
com->handle = -1;
}
}
}
closedir(dirp);
}
#endif // unix

253
external/rs232/rs232-win.cpp vendored Normal file
View File

@ -0,0 +1,253 @@
/*
Cross-platform serial / RS232 library
Version 0.21, 11/10/2015
-> WIN32 implementation
-> rs232-win.c
The MIT License (MIT)
Copyright (c) 2013-2015 Frédéric Meslin, Florent Touchard
Email: fredericmeslin@hotmail.com
Website: www.fredslab.net
Twitter: @marzacdev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifdef _WIN32
#include "rs232.h"
#include <stdio.h>
#include <string.h>
#include <Windows.h>
/*****************************************************************************/
typedef struct {
int port;
void * handle;
} COMDevice;
/*****************************************************************************/
#define COM_MAXDEVICES 64
static COMDevice comDevices[COM_MAXDEVICES];
static int noDevices = 0;
#define COM_MINDEVNAME 16384
const char * comPtn = "COM???";
/*****************************************************************************/
const char * findPattern(const char * string, const char * pattern, int * value);
const char * portInternalName(int index);
/*****************************************************************************/
int comEnumerate()
{
// Get devices information text
size_t size = COM_MINDEVNAME;
char * list = (char *) malloc(size);
SetLastError(0);
QueryDosDeviceA(NULL, list, size);
while (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
size *= 2;
char * nlist = (char *) realloc(list, size);
if (!nlist) {
free(list);
return 0;
}
list = nlist;
SetLastError(0);
QueryDosDeviceA(NULL, list, size);
}
// Gather all COM ports
int port;
const char * nlist = findPattern(list, comPtn, &port);
noDevices = 0;
while(port > 0 && noDevices < COM_MAXDEVICES) {
COMDevice * com = &comDevices[noDevices ++];
com->port = port;
com->handle = 0;
nlist = findPattern(nlist, comPtn, &port);
}
free(list);
return noDevices;
}
void comTerminate()
{
comCloseAll();
}
int comGetNoPorts()
{
return noDevices;
}
/*****************************************************************************/
const char * comGetPortName(int index)
{
#define COM_MAXNAME 32
static char name[COM_MAXNAME];
if (index < 0 || index >= noDevices)
return 0;
sprintf(name, "COM%i", comDevices[index].port);
return name;
}
int comFindPort(const char * name)
{
for (int i = 0; i < noDevices; i++)
if (strcmp(name, comGetPortName(i)) == 0)
return i;
return -1;
}
const char * comGetInternalName(int index)
{
#define COM_MAXNAME 32
static char name[COM_MAXNAME];
if (index < 0 || index >= noDevices)
return 0;
sprintf(name, "//./COM%i", comDevices[index].port);
return name;
}
/*****************************************************************************/
int comOpen(int index, int baudrate)
{
DCB config;
COMMTIMEOUTS timeouts;
if (index < 0 || index >= noDevices)
return 0;
// Close if already open
COMDevice * com = &comDevices[index];
if (com->handle) comClose(index);
// Open COM port
void * handle = CreateFileA(comGetInternalName(index), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
if (handle == INVALID_HANDLE_VALUE)
return 0;
com->handle = handle;
// Prepare read / write timeouts
SetupComm(handle, 64, 64);
timeouts.ReadIntervalTimeout = MAXDWORD;
timeouts.ReadTotalTimeoutConstant = 0;
timeouts.WriteTotalTimeoutConstant = 0;
timeouts.ReadTotalTimeoutMultiplier = 0;
timeouts.WriteTotalTimeoutMultiplier = 0;
SetCommTimeouts(handle, &timeouts);
// Prepare serial communication format
GetCommState(handle, &config);
config.BaudRate = baudrate;
config.fBinary = true;
config.fParity = 0;
config.fErrorChar = 0;
config.fNull = 0;
config.fAbortOnError = 0;
config.ByteSize = 8;
config.Parity = 0;
config.StopBits = 0;
config.EvtChar = '\n';
// Set the port state
if (SetCommState(handle, &config) == 0) {
CloseHandle(handle);
return 0;
}
return 1;
}
void comClose(int index)
{
if (index < 0 || index >= noDevices)
return;
COMDevice * com = &comDevices[index];
if (!com->handle)
return;
CloseHandle(com->handle);
com->handle = 0;
}
void comCloseAll()
{
for (int i = 0; i < noDevices; i++)
comClose(i);
}
/*****************************************************************************/
int comWrite(int index, const char * buffer, size_t len)
{
if (index < 0 || index >= noDevices)
return 0;
COMDevice * com = &comDevices[index];
uint32_t bytes = 0;
WriteFile(com->handle, buffer, len, (LPDWORD)&bytes, NULL);
return bytes;
}
int comRead(int index, char * buffer, size_t len)
{
if (index < 0 || index >= noDevices)
return 0;
COMDevice * com = &comDevices[index];
uint32_t bytes = 0;
ReadFile(com->handle, buffer, len, (LPDWORD)&bytes, NULL);
return bytes;
}
/*****************************************************************************/
const char * findPattern(const char * string, const char * pattern, int * value)
{
char c, n = 0;
const char * sp = string;
const char * pp = pattern;
// Check for the string pattern
while (1) {
c = *sp ++;
if (c == '\0') {
if (*pp == '?') break;
if (*sp == '\0') break;
n = 0;
pp = pattern;
}else{
if (*pp == '?') {
// Expect a digit
if (c >= '0' && c <= '9') {
n = n * 10 + (c - '0');
if (*pp ++ == '\0') break;
}else{
n = 0;
pp = comPtn;
}
}else{
// Expect a character
if (c == *pp) {
if (*pp ++ == '\0') break;
}else{
n = 0;
pp = comPtn;
}
}
}
}
// Return the value
* value = n;
return sp;
}
#endif // _WIN32

156
external/rs232/rs232.h vendored Normal file
View File

@ -0,0 +1,156 @@
/*
Cross-platform serial / RS232 library
Version 0.21, 11/10/2015
-> All platforms header
-> rs232.h
The MIT License (MIT)
Copyright (c) 2013-2015 Frédéric Meslin, Florent Touchard
Email: fredericmeslin@hotmail.com
Website: www.fredslab.net
Twitter: @marzacdev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef RS232_H
#define RS232_H
// TODO: convert to C++ class
//#ifdef __cplusplus
//extern "C" {
//#endif
#include <stdint.h>
#include <stdlib.h>
/*****************************************************************************/
/* Doxywizard specific */
/**
* \mainpage RS232
* \section intro_sec C / C++ RS232 cross-platform serial library
* <b>Version 0.21 - 11/10/2015</b>
*
* Supported platforms:
* - Windows (XP / Win7, possibly 8 and 10)
* - Linux
* - MacOS X
*
* Copyright (c) 2013-2015 Fr&eacute;d&eacute;ric Meslin, Florent Touchard <br>
* Email: fredericmeslin@hotmail.com <br>
* Website: www.fredslab.net <br>
* Twitter: \@marzacdev <br>
*/
/*****************************************************************************/
/**
* \fn int comEnumerate()
* \brief Enumerate available serial ports (Serial, USB serial, Bluetooth serial)
* \return number of enumerated ports
*/
int comEnumerate();
/**
* \fn int comGetNoPorts()
* \brief Return the number of enumerated ports
* \return number of enumerated ports
*/
int comGetNoPorts();
/**
* \fn int comTerminate()
* \brief Release ports and memory resources used by the library
*/
void comTerminate();
/**
* \fn const char * comGetPortName(int index)
* \brief Get port user-friendly name
* \param[in] index port index
* \return null terminated port name
*/
const char * comGetPortName(int index);
/**
* \fn const char * comGetInternalName(int index)
* \brief Get port operating-system name
* \param[in] index port index
* \return null terminated port name
*/
const char * comGetInternalName(int index);
/**
* \fn int comFindPort(const char * name)
* \brief Try to find a port given its user-friendly name
* \param[in] name port name (case sensitive)
* \return index of found port or -1 if not enumerated
*/
int comFindPort(const char * name);
/*****************************************************************************/
/**
* \fn int comOpen(int index, int baudrate)
* \brief Try to open a port at a specific baudrate
* \brief (No parity, single stop bit, no hardware flow control)
* \param[in] index port index
* \param[in] baudrate port baudrate
* \return 1 if opened, 0 if not available
*/
int comOpen(int index, int baudrate);
/**
* \fn void comClose(int index)
* \brief Close an opened port
* \param[in] index port index
*/
void comClose(int index);
/**
* \fn void comCloseAll()
* \brief Close all opened ports
*/
void comCloseAll();
/*****************************************************************************/
/**
* \fn int comWrite(int index, const char * buffer, size_t len)
* \brief Write data to the port (non-blocking)
* \param[in] index port index
* \param[in] buffer pointer to transmit buffer
* \param[in] len length of transmit buffer in bytes
* \return number of bytes transferred
*/
int comWrite(int index, const char * buffer, size_t len);
/**
* \fn int comRead(int index, const char * buffer, size_t len)
* \brief Read data from the port (non-blocking)
* \param[in] index port index
* \param[in] buffer pointer to receive buffer
* \param[in] len length of receive buffer in bytes
* \return number of bytes transferred
*/
int comRead(int index, char * buffer, size_t len);
//#ifdef __cplusplus
//}
//#endif
#endif // RS232_H

View File

@ -45,6 +45,8 @@ wxEND_EVENT_TABLE()
#ifdef USE_HAMLIB #ifdef USE_HAMLIB
#include "RigThread.h" #include "RigThread.h"
#include "PortSelectorDialog.h"
#include "rs232.h"
#endif #endif
@ -554,7 +556,7 @@ AppFrame::AppFrame() :
rigModel = wxGetApp().getConfig()->getRigModel(); rigModel = wxGetApp().getConfig()->getRigModel();
rigSerialRate = wxGetApp().getConfig()->getRigRate(); rigSerialRate = wxGetApp().getConfig()->getRigRate();
rigPort = wxGetApp().getConfig()->getRigPort(); rigPort = wxGetApp().getConfig()->getRigPort();
rigPortDialog = nullptr;
rigMenu = new wxMenu; rigMenu = new wxMenu;
rigEnableMenuItem = rigMenu->AppendCheckItem(wxID_RIG_TOGGLE, wxT("Enable Rig")); rigEnableMenuItem = rigMenu->AppendCheckItem(wxID_RIG_TOGGLE, wxT("Enable Rig"));
@ -941,6 +943,31 @@ void AppFrame::disableRig() {
wxGetApp().unlockFrequency(); wxGetApp().unlockFrequency();
wxGetApp().getConfig()->setRigEnabled(false); wxGetApp().getConfig()->setRigEnabled(false);
} }
void AppFrame::setRigControlPort(std::string portName) {
if (rigPortDialog == nullptr) {
return;
}
if (portName != "") {
rigPort = portName;
wxGetApp().stopRig();
wxGetApp().initRig(rigModel, rigPort, rigSerialRate);
Refresh();
}
rigPortDialog->EndModal(0);
delete rigPortDialog;
rigPortDialog = nullptr;
}
void AppFrame::dismissRigControlPortDialog() {
rigPortDialog->EndModal(0);
delete rigPortDialog;
rigPortDialog = nullptr;
}
#endif #endif
bool AppFrame::actionOnMenuDisplay(wxCommandEvent& event) { bool AppFrame::actionOnMenuDisplay(wxCommandEvent& event) {
@ -1247,6 +1274,8 @@ bool AppFrame::actionOnMenuAudioSampleRate(wxCommandEvent& event) {
//audioSampleRateMenuItems[menu_id+j]; //audioSampleRateMenuItems[menu_id+j];
//std::cout << "Would set audio sample rate on device " << mdevices_i->second.name << " (" << mdevices_i->first << ") to " << (*srate) << "Hz" << std::endl; //std::cout << "Would set audio sample rate on device " << mdevices_i->second.name << " (" << mdevices_i->first << ") to " << (*srate) << "Hz" << std::endl;
AudioThread::setDeviceSampleRate(mdevices_i->first, *srate); AudioThread::setDeviceSampleRate(mdevices_i->first, *srate);
return true;
} }
j++; j++;
@ -1254,7 +1283,6 @@ bool AppFrame::actionOnMenuAudioSampleRate(wxCommandEvent& event) {
i++; i++;
} }
return true;
} }
return false; return false;
@ -1337,13 +1365,10 @@ bool AppFrame::actionOnMenuRig(wxCommandEvent& event) {
} }
if (event.GetId() == wxID_RIG_PORT) { if (event.GetId() == wxID_RIG_PORT) {
wxString stringVal = wxGetTextFromUser("Rig Serial / COM / Address", "Rig Control Port", rigPort); if (rigPortDialog == nullptr) {
std::string rigPortStr = stringVal.ToStdString(); rigPortDialog = new PortSelectorDialog(this, wxID_ANY, rigPort);
if (rigPortStr != "") { rigPortDialog->ShowModal();
rigPort = rigPortStr;
resetRig = true;
} }
bManaged = true;
} }
if (event.GetId() == wxID_RIG_TOGGLE) { if (event.GetId() == wxID_RIG_TOGGLE) {
@ -2284,6 +2309,13 @@ int AppFrame::OnGlobalKeyDown(wxKeyEvent &event) {
if (!this->IsActive()) { if (!this->IsActive()) {
return -1; return -1;
} }
#ifdef USE_HAMLIB
if (rigPortDialog != nullptr) {
return -1;
}
#endif
if (modemProps && (modemProps->HasFocus() || modemProps->isMouseInView())) { if (modemProps && (modemProps->HasFocus() || modemProps->isMouseInView())) {
return -1; return -1;
} }
@ -2398,6 +2430,13 @@ int AppFrame::OnGlobalKeyUp(wxKeyEvent &event) {
if (!this->IsActive()) { if (!this->IsActive()) {
return -1; return -1;
} }
#ifdef USE_HAMLIB
if (rigPortDialog != nullptr) {
return -1;
}
#endif
if (modemProps && (modemProps->HasFocus() || modemProps->isMouseInView())) { if (modemProps && (modemProps->HasFocus() || modemProps->isMouseInView())) {
return -1; return -1;
} }

View File

@ -81,6 +81,10 @@
#define wxID_RIG_MODEL_BASE 12000 #define wxID_RIG_MODEL_BASE 12000
#endif #endif
#ifdef USE_HAMLIB
class PortSelectorDialog;
#endif
// Define a new frame type // Define a new frame type
class AppFrame: public wxFrame { class AppFrame: public wxFrame {
public: public:
@ -133,6 +137,11 @@ public:
void setStatusText(wxWindow* window, std::string statusText); void setStatusText(wxWindow* window, std::string statusText);
void setStatusText(std::string statusText, int value); void setStatusText(std::string statusText, int value);
#ifdef USE_HAMLIB
void setRigControlPort(std::string portName);
void dismissRigControlPortDialog();
#endif
private: private:
void OnMenu(wxCommandEvent& event); void OnMenu(wxCommandEvent& event);
void OnClose(wxCloseEvent& event); void OnClose(wxCloseEvent& event);
@ -231,7 +240,6 @@ private:
wxMenuItem *rigFollowMenuItem; wxMenuItem *rigFollowMenuItem;
wxMenuItem *rigCenterLockMenuItem; wxMenuItem *rigCenterLockMenuItem;
wxMenuItem *rigFollowModemMenuItem; wxMenuItem *rigFollowModemMenuItem;
wxMenuItem *sdrIFMenuItem;
std::map<int, wxMenuItem *> rigSerialMenuItems; std::map<int, wxMenuItem *> rigSerialMenuItems;
std::map<int, wxMenuItem *> rigModelMenuItems; std::map<int, wxMenuItem *> rigModelMenuItems;
@ -241,7 +249,7 @@ private:
std::vector<int> rigSerialRates; std::vector<int> rigSerialRates;
std::string rigPort; std::string rigPort;
int numRigs; int numRigs;
bool rigInit; PortSelectorDialog *rigPortDialog;
#endif #endif
wxDECLARE_EVENT_TABLE(); wxDECLARE_EVENT_TABLE();

View File

@ -0,0 +1,39 @@
#include "PortSelectorDialog.h"
#include "rs232.h"
#include "CubicSDR.h"
PortSelectorDialog::PortSelectorDialog( wxWindow* parent, wxWindowID id, std::string defaultPort ) : PortSelectorDialogBase(parent, id) {
comEnumerate();
int nPorts = comGetNoPorts();
for (int i = 0; i < nPorts; i++) {
#ifdef WIN32
m_portList->Append(comGetPortName(i));
#else
m_portList->Append(comGetInternalName(i));
#endif
}
comTerminate();
m_portSelection->SetValue(defaultPort);
}
void PortSelectorDialog::onListSelect( wxCommandEvent& event ) {
int pSelect = m_portList->GetSelection();
if (pSelect != -1) {
m_portSelection->SetValue(m_portList->GetString(pSelect));
}
}
void PortSelectorDialog::onCancelButton( wxCommandEvent& event ) {
wxGetApp().getAppFrame()->dismissRigControlPortDialog();
}
void PortSelectorDialog::onOKButton( wxCommandEvent& event ) {
wxGetApp().getAppFrame()->setRigControlPort(m_portSelection->GetValue().ToStdString());
}

View File

@ -0,0 +1,727 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="13" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
<property name="disconnect_events">1</property>
<property name="disconnect_mode">source_name</property>
<property name="disconnect_php_events">0</property>
<property name="disconnect_python_events">0</property>
<property name="embedded_files_path">res</property>
<property name="encoding">UTF-8</property>
<property name="event_generation">connect</property>
<property name="file">PortSelectorDialogBase</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="internationalize">0</property>
<property name="name">PortSelectorDialog</property>
<property name="namespace"></property>
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
<property name="center">wxBOTH</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="enabled">1</property>
<property name="event_handler">impl_virtual</property>
<property name="extra_style"></property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">PortSelectorDialogBase</property>
<property name="pos"></property>
<property name="size">304,197</property>
<property name="style">wxDEFAULT_DIALOG_STYLE</property>
<property name="subclass"></property>
<property name="title">Select Port</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnActivate"></event>
<event name="OnActivateApp"></event>
<event name="OnAuiFindManager"></event>
<event name="OnAuiPaneButton"></event>
<event name="OnAuiPaneClose"></event>
<event name="OnAuiPaneMaximize"></event>
<event name="OnAuiPaneRestore"></event>
<event name="OnAuiRender"></event>
<event name="OnChar"></event>
<event name="OnClose"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnHibernate"></event>
<event name="OnIconize"></event>
<event name="OnIdle"></event>
<event name="OnInitDialog"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">dlgSizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Select a detected port or enter your own</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText1</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxListBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices"></property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_portList</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnListBox">onListSelect</event>
<event name="OnListBoxDClick"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size">-1,30</property>
<property name="name">bSizer3</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Port</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText2</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxRIGHT</property>
<property name="proportion">1</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_portSelection</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<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>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnText"></event>
<event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="proportion">0</property>
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_buttonPanel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer2</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_BOTTOM</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Cancel</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_cancelButton</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">onCancelButton</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_BOTTOM</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">OK</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_okButton</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">onOKButton</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</wxFormBuilder_Project>

View File

@ -0,0 +1,11 @@
#include "PortSelectorDialogBase.h"
class PortSelectorDialog : public PortSelectorDialogBase {
public:
PortSelectorDialog( wxWindow* parent, wxWindowID id = wxID_ANY, std::string defaultPort = "" );
protected:
void onListSelect( wxCommandEvent& event );
void onCancelButton( wxCommandEvent& event );
void onOKButton( wxCommandEvent& event );
};

View File

@ -0,0 +1,78 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Aug 23 2015)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "PortSelectorDialogBase.h"
///////////////////////////////////////////////////////////////////////////
PortSelectorDialogBase::PortSelectorDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* dlgSizer;
dlgSizer = new wxBoxSizer( wxVERTICAL );
m_staticText1 = new wxStaticText( this, wxID_ANY, wxT("Select a detected port or enter your own"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( -1 );
dlgSizer->Add( m_staticText1, 0, wxEXPAND|wxALL, 5 );
m_portList = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
dlgSizer->Add( m_portList, 1, wxALL|wxEXPAND, 5 );
wxBoxSizer* bSizer3;
bSizer3 = new wxBoxSizer( wxHORIZONTAL );
bSizer3->SetMinSize( wxSize( -1,30 ) );
m_staticText2 = new wxStaticText( this, wxID_ANY, wxT("Port"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText2->Wrap( -1 );
bSizer3->Add( m_staticText2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_portSelection = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer3->Add( m_portSelection, 1, wxEXPAND|wxRIGHT, 5 );
dlgSizer->Add( bSizer3, 1, wxEXPAND, 5 );
m_buttonPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer2;
bSizer2 = new wxBoxSizer( wxHORIZONTAL );
m_cancelButton = new wxButton( m_buttonPanel, wxID_ANY, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer2->Add( m_cancelButton, 0, wxALL|wxALIGN_BOTTOM, 5 );
bSizer2->Add( 0, 0, 1, wxEXPAND, 5 );
m_okButton = new wxButton( m_buttonPanel, wxID_ANY, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer2->Add( m_okButton, 0, wxALL|wxALIGN_BOTTOM, 5 );
m_buttonPanel->SetSizer( bSizer2 );
m_buttonPanel->Layout();
bSizer2->Fit( m_buttonPanel );
dlgSizer->Add( m_buttonPanel, 0, wxEXPAND | wxALL, 5 );
this->SetSizer( dlgSizer );
this->Layout();
this->Centre( wxBOTH );
// Connect Events
m_portList->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( PortSelectorDialogBase::onListSelect ), NULL, this );
m_cancelButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PortSelectorDialogBase::onCancelButton ), NULL, this );
m_okButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PortSelectorDialogBase::onOKButton ), NULL, this );
}
PortSelectorDialogBase::~PortSelectorDialogBase()
{
// Disconnect Events
m_portList->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( PortSelectorDialogBase::onListSelect ), NULL, this );
m_cancelButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PortSelectorDialogBase::onCancelButton ), NULL, this );
m_okButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PortSelectorDialogBase::onOKButton ), NULL, this );
}

View File

@ -0,0 +1,58 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Aug 23 2015)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __PORTSELECTORDIALOGBASE_H__
#define __PORTSELECTORDIALOGBASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/listbox.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/panel.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class PortSelectorDialogBase
///////////////////////////////////////////////////////////////////////////////
class PortSelectorDialogBase : public wxDialog
{
private:
protected:
wxStaticText* m_staticText1;
wxListBox* m_portList;
wxStaticText* m_staticText2;
wxTextCtrl* m_portSelection;
wxPanel* m_buttonPanel;
wxButton* m_cancelButton;
wxButton* m_okButton;
// Virtual event handlers, overide them in your derived class
virtual void onListSelect( wxCommandEvent& event ) { event.Skip(); }
virtual void onCancelButton( wxCommandEvent& event ) { event.Skip(); }
virtual void onOKButton( wxCommandEvent& event ) { event.Skip(); }
public:
PortSelectorDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Select Port"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 304,197 ), long style = wxDEFAULT_DIALOG_STYLE );
~PortSelectorDialogBase();
};
#endif //__PORTSELECTORDIALOGBASE_H__