Commit 1bd0f6b9 authored by Andreas Bombe's avatar Andreas Bombe

New upstream version 0.2.2+dfsg

parent 8d7db041
......@@ -7,7 +7,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
SET(CUBICSDR_VERSION_MAJOR "0")
SET(CUBICSDR_VERSION_MINOR "2")
SET(CUBICSDR_VERSION_PATCH "2")
SET(CUBICSDR_VERSION_SUFFIX "-alpha")
SET(CUBICSDR_VERSION_SUFFIX "")
SET(CUBICSDR_VERSION "${CUBICSDR_VERSION_MAJOR}.${CUBICSDR_VERSION_MINOR}.${CUBICSDR_VERSION_PATCH}${CUBICSDR_VERSION_SUFFIX}")
SET(CPACK_PACKAGE_VERSION "${CUBICSDR_VERSION_MAJOR}.${CUBICSDR_VERSION_MINOR}.${CUBICSDR_VERSION_PATCH}")
......@@ -27,6 +27,8 @@ IF(CUSTOM_BUILD)
# feature flags
SET (CUBICSDR_ENABLE_VIEW_DEMOD ON CACHE BOOL "Enable Second Demodulator Spectrum/Waterfall view.")
SET (CUBICSDR_ENABLE_VIEW_SCOPE ON CACHE BOOL "Enable Demodulator Scope/Spectrum view.")
SET (CUBICSDR_ENABLE_ABOUT_DIALOG ON CACHE BOOL "Enable About Dialog.")
SET (CUBICSDR_DEFAULT_HIDE_BOOKMARKS OFF CACHE BOOL "Hide Bookmarks by Default.")
SET (CUBICSDR_MODEM_EXCLUDE CACHE "" "Comma-separated list of modems to exclude.")
IF (NOT CUBICSDR_HEADER_IMAGE STREQUAL "")
......@@ -52,8 +54,10 @@ ELSE()
SET (CUBICSDR_HEADER_IMAGE "")
SET (CUBICSDR_HEADER_BG "")
# feature flags
SET (CUBICSDR_ENABLE_VIEW_DEMOD TRUE)
SET (CUBICSDR_ENABLE_VIEW_SCOPE TRUE)
SET (CUBICSDR_ENABLE_VIEW_DEMOD ON)
SET (CUBICSDR_ENABLE_VIEW_SCOPE ON)
SET (CUBICSDR_DEFAULT_HIDE_BOOKMARKS OFF)
SET (CUBICSDR_ENABLE_ABOUT_DIALOG ON)
SET (CUBICSDR_EXCLUDE_MODEM "")
ENDIF()
......@@ -65,6 +69,14 @@ IF(CUBICSDR_ENABLE_VIEW_SCOPE)
ADD_DEFINITIONS( -DCUBICSDR_ENABLE_VIEW_SCOPE=1 )
ENDIF()
IF(CUBICSDR_DEFAULT_HIDE_BOOKMARKS)
ADD_DEFINITIONS( -DCUBICSDR_DEFAULT_HIDE_BOOKMARKS=1 )
ENDIF()
IF(CUBICSDR_ENABLE_ABOUT_DIALOG)
ADD_DEFINITIONS( -DCUBICSDR_ENABLE_ABOUT_DIALOG=1 )
ENDIF()
ADD_DEFINITIONS(
-DCUBICSDR_INSTALL_NAME="${CUBICSDR_INSTALL_NAME}"
-DCUBICSDR_VERSION="${CUBICSDR_VERSION}"
......@@ -528,12 +540,33 @@ ENDIF()
IF (USE_HAMLIB)
SET (cubicsdr_headers
${cubicsdr_headers}
src/forms/Dialog/PortSelectorDialogBase.h
src/forms/Dialog/PortSelectorDialog.h
src/rig/RigThread.h
external/rs232/rs232.h
)
SET (cubicsdr_sources
${cubicsdr_sources}
src/forms/Dialog/PortSelectorDialogBase.cpp
src/forms/Dialog/PortSelectorDialog.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()
......@@ -571,6 +604,7 @@ SOURCE_GROUP("Forms\\Dialog" REGULAR_EXPRESSION "src/forms/Dialog/${REG_EXT}")
SOURCE_GROUP("SDR" REGULAR_EXPRESSION "src/sdr/${REG_EXT}")
IF(USE_HAMLIB)
SOURCE_GROUP("Rig" REGULAR_EXPRESSION "src/rig/${REG_EXT}")
SOURCE_GROUP("_ext-RS-232" REGULAR_EXPRESSION "external/rs232/${REG_EXT}")
ENDIF()
SOURCE_GROUP("Demodulator" REGULAR_EXPRESSION "src/demod/${REG_EXT}")
SOURCE_GROUP("Modem" REGULAR_EXPRESSION "src/modules/modem/${REG_EXT}")
......@@ -733,9 +767,10 @@ IF (APPLE AND BUNDLE_APP)
IF (BUNDLE_SOAPY_MODS)
message(STATUS "SOAPY_ROOT: ${SOAPY_SDR_ROOT}")
SET(SOAPY_SDR_MOD_PATH "${SOAPY_SDR_ROOT}/lib/SoapySDR/modules/${SOAPY_SDR_ABI_VERSION}")
SET(SOAPY_SDR_MOD_PATH "${SOAPY_SDR_ROOT}/lib/SoapySDR/modules${SOAPY_SDR_ABI_VERSION}")
message(STATUS "SOAPY_SDR_MOD_PATH: ${SOAPY_SDR_MOD_PATH}")
file(GLOB SOAPY_MODS ${SOAPY_MOD_PATH}/*.so)
file(GLOB SOAPY_MODS ${SOAPY_SDR_MOD_PATH}/*.so)
FOREACH(SOAPY_MOD_FILE ${SOAPY_MODS})
INSTALL( FILES "${SOAPY_MOD_FILE}"
......
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.
# 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 Frdric Meslin
Email: fredericmeslin@hotmail.com
Website: www.fredslab.net
Twitter: @marzacdev
/*
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
/*
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
/*
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