Make the modem speed dynamic with a default of 115200.

This commit is contained in:
Jonathan Naylor
2020-05-23 13:03:55 +01:00
parent 9d08f1605c
commit 303a0163d3
13 changed files with 746 additions and 746 deletions

1400
Conf.cpp

File diff suppressed because it is too large Load Diff

2
Conf.h
View File

@@ -71,6 +71,7 @@ public:
// The Modem section // The Modem section
std::string getModemPort() const; std::string getModemPort() const;
std::string getModemProtocol() const; std::string getModemProtocol() const;
unsigned int getModemSpeed() const;
unsigned int getModemAddress() const; unsigned int getModemAddress() const;
bool getModemRXInvert() const; bool getModemRXInvert() const;
bool getModemTXInvert() const; bool getModemTXInvert() const;
@@ -360,6 +361,7 @@ private:
std::string m_modemPort; std::string m_modemPort;
std::string m_modemProtocol; std::string m_modemProtocol;
unsigned int m_modemSpeed;
unsigned int m_modemAddress; unsigned int m_modemAddress;
bool m_modemRXInvert; bool m_modemRXInvert;
bool m_modemTXInvert; bool m_modemTXInvert;

View File

@@ -511,7 +511,7 @@ CDisplay* CDisplay::createDisplay(const CConf& conf, CUMP* ump, CModem* modem)
if (port == "modem") if (port == "modem")
serial = new CModemSerialPort(modem); serial = new CModemSerialPort(modem);
else else
serial = new CSerialController(port, (type == "TFT Serial") ? SERIAL_9600 : SERIAL_115200); serial = new CSerialController(port, (type == "TFT Serial") ? 9600U : 115200U);
if (type == "TFT Surenoo") if (type == "TFT Surenoo")
display = new CTFTSurenoo(conf.getCallsign(), dmrid, serial, brightness, conf.getDuplex()); display = new CTFTSurenoo(conf.getCallsign(), dmrid, serial, brightness, conf.getDuplex());
@@ -565,11 +565,11 @@ CDisplay* CDisplay::createDisplay(const CConf& conf, CUMP* ump, CModem* modem)
display = new CNullDisplay; display = new CNullDisplay;
} }
} else { } else {
SERIAL_SPEED baudrate = SERIAL_9600; unsigned int baudrate = 9600U;
if (screenLayout==4U) if (screenLayout == 4U)
baudrate = SERIAL_115200; baudrate = 115200U;
LogInfo(" Display baudrate: %u ",baudrate); LogInfo(" Display baudrate: %u ", baudrate);
ISerialPort* serial = new CSerialController(port, baudrate); ISerialPort* serial = new CSerialController(port, baudrate);
display = new CNextion(conf.getCallsign(), dmrid, serial, brightness, displayClock, utc, idleBrightness, screenLayout, txFrequency, rxFrequency, displayTempInF, conf.getLocation()); display = new CNextion(conf.getCallsign(), dmrid, serial, brightness, displayClock, utc, idleBrightness, screenLayout, txFrequency, rxFrequency, displayTempInF, conf.getLocation());
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2002-2004,2007-2011,2013,2014-2017 by Jonathan Naylor G4KLX * Copyright (C) 2002-2004,2007-2011,2013,2014-2017,2020 by Jonathan Naylor G4KLX
* Copyright (C) 1999-2001 by Thomas Sailor HB9JNX * Copyright (C) 1999-2001 by Thomas Sailor HB9JNX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -30,7 +30,7 @@
#include <setupapi.h> #include <setupapi.h>
#include <winioctl.h> #include <winioctl.h>
CI2CController::CI2CController(const std::string& device, SERIAL_SPEED speed, unsigned int address, bool assertRTS) : CI2CController::CI2CController(const std::string& device, unsigned int speed, unsigned int address, bool assertRTS) :
CSerialController(device, speed, assertRTS), CSerialController(device, speed, assertRTS),
m_address(address) m_address(address)
{ {
@@ -67,7 +67,7 @@ int CI2CController::write(const unsigned char* buffer, unsigned int length)
#include <linux/i2c-dev.h> #include <linux/i2c-dev.h>
#endif #endif
CI2CController::CI2CController(const std::string& device, SERIAL_SPEED speed, unsigned int address, bool assertRTS) : CI2CController::CI2CController(const std::string& device, unsigned int speed, unsigned int address, bool assertRTS) :
CSerialController(device, speed, assertRTS), CSerialController(device, speed, assertRTS),
m_address(address) m_address(address)
{ {
@@ -89,13 +89,13 @@ bool CI2CController::open()
} }
if (::ioctl(m_fd, I2C_TENBIT, 0) < 0) { if (::ioctl(m_fd, I2C_TENBIT, 0) < 0) {
LogError("CI2C: failed to set 7bitaddress"); LogError("I2C: failed to set 7bitaddress");
::close(m_fd); ::close(m_fd);
return false; return false;
} }
if (::ioctl(m_fd, I2C_SLAVE, m_address) < 0) { if (::ioctl(m_fd, I2C_SLAVE, m_address) < 0) {
LogError("CI2C: Failed to acquire bus access/talk to slave 0x%02X", m_address); LogError("I2C: Failed to acquire bus access/talk to slave 0x%02X", m_address);
::close(m_fd); ::close(m_fd);
return false; return false;
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2002-2004,2007-2009,2011-2013,2015-2017 by Jonathan Naylor G4KLX * Copyright (C) 2002-2004,2007-2009,2011-2013,2015-2017,2020 by Jonathan Naylor G4KLX
* Copyright (C) 1999-2001 by Thomas Sailor HB9JNX * Copyright (C) 1999-2001 by Thomas Sailor HB9JNX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -24,7 +24,7 @@
class CI2CController : public CSerialController { class CI2CController : public CSerialController {
public: public:
CI2CController(const std::string& device, SERIAL_SPEED speed, unsigned int address = 0x22U, bool assertRTS = false); CI2CController(const std::string& device, unsigned int speed, unsigned int address = 0x22U, bool assertRTS = false);
virtual ~CI2CController(); virtual ~CI2CController();
virtual bool open(); virtual bool open();

View File

@@ -45,6 +45,7 @@ Time=24
# Port=/dev/ttyAMA0 # Port=/dev/ttyAMA0
Port=\\.\COM4 Port=\\.\COM4
Protocol=uart Protocol=uart
Speed=115200
# Address=0x22 # Address=0x22
TXInvert=1 TXInvert=1
RXInvert=0 RXInvert=0

View File

@@ -1204,6 +1204,7 @@ bool CMMDVMHost::createModem()
{ {
std::string port = m_conf.getModemPort(); std::string port = m_conf.getModemPort();
std::string protocol = m_conf.getModemProtocol(); std::string protocol = m_conf.getModemProtocol();
unsigned int speed = m_conf.getModemSpeed();
unsigned int address = m_conf.getModemAddress(); unsigned int address = m_conf.getModemAddress();
bool rxInvert = m_conf.getModemRXInvert(); bool rxInvert = m_conf.getModemRXInvert();
bool txInvert = m_conf.getModemTXInvert(); bool txInvert = m_conf.getModemTXInvert();
@@ -1239,7 +1240,8 @@ bool CMMDVMHost::createModem()
LogInfo(" Port: %s", port.c_str()); LogInfo(" Port: %s", port.c_str());
LogInfo(" Protocol: %s", protocol.c_str()); LogInfo(" Protocol: %s", protocol.c_str());
if (protocol == "i2c") if (protocol == "i2c")
LogInfo(" i2c Address: %02X", address); LogInfo(" I2C Address: %02X", address);
LogInfo(" Speed: %u", speed);
LogInfo(" RX Invert: %s", rxInvert ? "yes" : "no"); LogInfo(" RX Invert: %s", rxInvert ? "yes" : "no");
LogInfo(" TX Invert: %s", txInvert ? "yes" : "no"); LogInfo(" TX Invert: %s", txInvert ? "yes" : "no");
LogInfo(" PTT Invert: %s", pttInvert ? "yes" : "no"); LogInfo(" PTT Invert: %s", pttInvert ? "yes" : "no");
@@ -1262,7 +1264,7 @@ bool CMMDVMHost::createModem()
LogInfo(" TX Frequency: %uHz (%uHz)", txFrequency, txFrequency + txOffset); LogInfo(" TX Frequency: %uHz (%uHz)", txFrequency, txFrequency + txOffset);
m_modem = CModem::createModem(port, m_duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, trace, debug); m_modem = CModem::createModem(port, m_duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, trace, debug);
m_modem->setSerialParams(protocol,address); m_modem->setSerialParams(protocol, address, speed);
m_modem->setModeParams(m_dstarEnabled, m_dmrEnabled, m_ysfEnabled, m_p25Enabled, m_nxdnEnabled, m_pocsagEnabled, m_fmEnabled); m_modem->setModeParams(m_dstarEnabled, m_dmrEnabled, m_ysfEnabled, m_p25Enabled, m_nxdnEnabled, m_pocsagEnabled, m_fmEnabled);
m_modem->setLevels(rxLevel, cwIdTXLevel, dstarTXLevel, dmrTXLevel, ysfTXLevel, p25TXLevel, nxdnTXLevel, pocsagTXLevel, fmTXLevel); m_modem->setLevels(rxLevel, cwIdTXLevel, dstarTXLevel, dmrTXLevel, ysfTXLevel, p25TXLevel, nxdnTXLevel, pocsagTXLevel, fmTXLevel);
m_modem->setRFParams(rxFrequency, rxOffset, txFrequency, txOffset, txDCOffset, rxDCOffset, rfLevel, pocsagFrequency); m_modem->setRFParams(rxFrequency, rxOffset, txFrequency, txOffset, txDCOffset, rxDCOffset, rfLevel, pocsagFrequency);

View File

@@ -221,13 +221,13 @@ CModem::~CModem()
delete[] m_buffer; delete[] m_buffer;
} }
void CModem::setSerialParams(const std::string& protocol, unsigned int address) void CModem::setSerialParams(const std::string& protocol, unsigned int address, unsigned int speed)
{ {
// Create the serial controller instance according the protocol specified in conf. // Create the serial controller instance according the protocol specified in conf.
if (protocol == "i2c") if (protocol == "i2c")
m_serial = new CI2CController(m_port, SERIAL_115200, address, true); m_serial = new CI2CController(m_port, speed, address, true);
else else
m_serial = new CSerialController(m_port, SERIAL_115200, true); m_serial = new CSerialController(m_port, speed, true);
} }
void CModem::setRFParams(unsigned int rxFrequency, int rxOffset, unsigned int txFrequency, int txOffset, int txDCOffset, int rxDCOffset, float rfLevel, unsigned int pocsagFrequency) void CModem::setRFParams(unsigned int rxFrequency, int rxOffset, unsigned int txFrequency, int txOffset, int txDCOffset, int rxDCOffset, float rfLevel, unsigned int pocsagFrequency)

View File

@@ -37,7 +37,7 @@ public:
CModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, bool trace, bool debug); CModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, bool trace, bool debug);
virtual ~CModem(); virtual ~CModem();
virtual void setSerialParams(const std::string& protocol, unsigned int address); virtual void setSerialParams(const std::string& protocol, unsigned int address, unsigned int speed);
virtual void setRFParams(unsigned int rxFrequency, int rxOffset, unsigned int txFrequency, int txOffset, int txDCOffset, int rxDCOffset, float rfLevel, unsigned int pocsagFrequency); virtual void setRFParams(unsigned int rxFrequency, int rxOffset, unsigned int txFrequency, int txOffset, int txDCOffset, int rxDCOffset, float rfLevel, unsigned int pocsagFrequency);
virtual void setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, bool p25Enabled, bool nxdnEnabled, bool pocsagEnabled, bool fmEnabled); virtual void setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, bool p25Enabled, bool nxdnEnabled, bool pocsagEnabled, bool fmEnabled);
virtual void setLevels(float rxLevel, float cwIdTXLevel, float dstarTXLevel, float dmrTXLevel, float ysfTXLevel, float p25TXLevel, float nxdnTXLevel, float pocsagLevel, float fmTXLevel); virtual void setLevels(float rxLevel, float cwIdTXLevel, float dstarTXLevel, float dmrTXLevel, float ysfTXLevel, float p25TXLevel, float nxdnTXLevel, float pocsagLevel, float fmTXLevel);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2002-2004,2007-2011,2013,2014-2017,2019 by Jonathan Naylor G4KLX * Copyright (C) 2002-2004,2007-2011,2013,2014-2017,2019,2020 by Jonathan Naylor G4KLX
* Copyright (C) 1999-2001 by Thomas Sailor HB9JNX * Copyright (C) 1999-2001 by Thomas Sailor HB9JNX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -23,12 +23,11 @@
#include <cstring> #include <cstring>
#include <cassert> #include <cassert>
#include <sys/types.h>
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
#include <setupapi.h> #include <setupapi.h>
#include <winioctl.h> #include <winioctl.h>
#else #else
#include <sys/types.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <cerrno> #include <cerrno>
@@ -40,7 +39,7 @@
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
CSerialController::CSerialController(const std::string& device, SERIAL_SPEED speed, bool assertRTS) : CSerialController::CSerialController(const std::string& device, unsigned int speed, bool assertRTS) :
m_device(device), m_device(device),
m_speed(speed), m_speed(speed),
m_assertRTS(assertRTS), m_assertRTS(assertRTS),
@@ -221,7 +220,7 @@ void CSerialController::close()
#else #else
CSerialController::CSerialController(const std::string& device, SERIAL_SPEED speed, bool assertRTS) : CSerialController::CSerialController(const std::string& device, unsigned int speed, bool assertRTS) :
m_device(device), m_device(device),
m_speed(speed), m_speed(speed),
m_assertRTS(assertRTS), m_assertRTS(assertRTS),
@@ -273,40 +272,40 @@ bool CSerialController::open()
#endif #endif
switch (m_speed) { switch (m_speed) {
case SERIAL_1200: case 1200U:
::cfsetospeed(&termios, B1200); ::cfsetospeed(&termios, B1200);
::cfsetispeed(&termios, B1200); ::cfsetispeed(&termios, B1200);
break; break;
case SERIAL_2400: case 2400U:
::cfsetospeed(&termios, B2400); ::cfsetospeed(&termios, B2400);
::cfsetispeed(&termios, B2400); ::cfsetispeed(&termios, B2400);
break; break;
case SERIAL_4800: case 4800U:
::cfsetospeed(&termios, B4800); ::cfsetospeed(&termios, B4800);
::cfsetispeed(&termios, B4800); ::cfsetispeed(&termios, B4800);
break; break;
case SERIAL_9600: case 9600U:
::cfsetospeed(&termios, B9600); ::cfsetospeed(&termios, B9600);
::cfsetispeed(&termios, B9600); ::cfsetispeed(&termios, B9600);
break; break;
case SERIAL_19200: case 19200U:
::cfsetospeed(&termios, B19200); ::cfsetospeed(&termios, B19200);
::cfsetispeed(&termios, B19200); ::cfsetispeed(&termios, B19200);
break; break;
case SERIAL_38400: case 38400U:
::cfsetospeed(&termios, B38400); ::cfsetospeed(&termios, B38400);
::cfsetispeed(&termios, B38400); ::cfsetispeed(&termios, B38400);
break; break;
case SERIAL_115200: case 115200U:
::cfsetospeed(&termios, B115200); ::cfsetospeed(&termios, B115200);
::cfsetispeed(&termios, B115200); ::cfsetispeed(&termios, B115200);
break; break;
case SERIAL_230400: case 230400U:
::cfsetospeed(&termios, B230400); ::cfsetospeed(&termios, B230400);
::cfsetispeed(&termios, B230400); ::cfsetispeed(&termios, B230400);
break; break;
default: default:
LogError("Unsupported serial port speed - %d", int(m_speed)); LogError("Unsupported serial port speed - %u", m_speed);
::close(m_fd); ::close(m_fd);
return false; return false;
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2002-2004,2007-2009,2011-2013,2015-2017 by Jonathan Naylor G4KLX * Copyright (C) 2002-2004,2007-2009,2011-2013,2015-2017,2020 by Jonathan Naylor G4KLX
* Copyright (C) 1999-2001 by Thomas Sailor HB9JNX * Copyright (C) 1999-2001 by Thomas Sailor HB9JNX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -28,21 +28,9 @@
#include <windows.h> #include <windows.h>
#endif #endif
enum SERIAL_SPEED {
SERIAL_1200 = 1200,
SERIAL_2400 = 2400,
SERIAL_4800 = 4800,
SERIAL_9600 = 9600,
SERIAL_19200 = 19200,
SERIAL_38400 = 38400,
SERIAL_76800 = 76800,
SERIAL_115200 = 115200,
SERIAL_230400 = 230400
};
class CSerialController : public ISerialPort { class CSerialController : public ISerialPort {
public: public:
CSerialController(const std::string& device, SERIAL_SPEED speed, bool assertRTS = false); CSerialController(const std::string& device, unsigned int speed, bool assertRTS = false);
virtual ~CSerialController(); virtual ~CSerialController();
virtual bool open(); virtual bool open();
@@ -59,7 +47,7 @@ public:
protected: protected:
std::string m_device; std::string m_device;
SERIAL_SPEED m_speed; unsigned int m_speed;
bool m_assertRTS; bool m_assertRTS;
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
HANDLE m_handle; HANDLE m_handle;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016 by Jonathan Naylor G4KLX * Copyright (C) 2016,2020 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -41,7 +41,7 @@ const unsigned char UMP_STATUS = 0x50U;
const unsigned int BUFFER_LENGTH = 255U; const unsigned int BUFFER_LENGTH = 255U;
CUMP::CUMP(const std::string& port) : CUMP::CUMP(const std::string& port) :
m_serial(port, SERIAL_115200), m_serial(port, 115200U),
m_open(false), m_open(false),
m_buffer(NULL), m_buffer(NULL),
m_length(0U), m_length(0U),

View File

@@ -19,6 +19,6 @@
#if !defined(VERSION_H) #if !defined(VERSION_H)
#define VERSION_H #define VERSION_H
const char* VERSION = "20200512"; const char* VERSION = "20200523";
#endif #endif