2020-06-30 11:35:03 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2011-2018,2020 by Jonathan Naylor G4KLX
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SERIALMODEM_H
|
|
|
|
#define SERIALMODEM_H
|
|
|
|
|
|
|
|
#include "Modem.h"
|
|
|
|
|
|
|
|
#include "SerialPort.h"
|
|
|
|
#include "RingBuffer.h"
|
|
|
|
#include "Defines.h"
|
|
|
|
#include "Timer.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
enum RESP_TYPE_MMDVM {
|
|
|
|
RTM_OK,
|
|
|
|
RTM_TIMEOUT,
|
|
|
|
RTM_ERROR
|
|
|
|
};
|
|
|
|
|
|
|
|
enum SERIAL_STATE {
|
|
|
|
SS_START,
|
|
|
|
SS_LENGTH1,
|
|
|
|
SS_LENGTH2,
|
|
|
|
SS_TYPE,
|
|
|
|
SS_DATA
|
|
|
|
};
|
|
|
|
|
|
|
|
class CSerialModem : public IModem {
|
|
|
|
public:
|
2020-07-15 11:15:07 +00:00
|
|
|
CSerialModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, bool useCOSAsLockout, bool trace, bool debug);
|
2020-06-30 11:35:03 +00:00
|
|
|
virtual ~CSerialModem();
|
|
|
|
|
|
|
|
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);
|
2020-11-06 15:43:12 +00:00
|
|
|
virtual void setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, bool p25Enabled, bool nxdnEnabled, bool m17Enabled, bool pocsagEnabled, bool fmEnabled, bool ax25Enabled);
|
|
|
|
virtual void setLevels(float rxLevel, float cwIdTXLevel, float dstarTXLevel, float dmrTXLevel, float ysfTXLevel, float p25TXLevel, float nxdnTXLevel, float m17TXLevel, float pocsagLevel, float fmTXLevel, float ax25TXLevel);
|
2020-06-30 11:35:03 +00:00
|
|
|
virtual void setDMRParams(unsigned int colorCode);
|
|
|
|
virtual void setYSFParams(bool loDev, unsigned int txHang);
|
|
|
|
virtual void setP25Params(unsigned int txHang);
|
|
|
|
virtual void setNXDNParams(unsigned int txHang);
|
2020-11-06 15:43:12 +00:00
|
|
|
virtual void setM17Params(unsigned int txHang);
|
2020-07-01 09:59:46 +00:00
|
|
|
virtual void setAX25Params(int rxTwist, unsigned int txDelay, unsigned int slotTime, unsigned int pPersist);
|
2020-06-30 11:35:03 +00:00
|
|
|
virtual void setTransparentDataParams(unsigned int sendFrameType);
|
|
|
|
|
|
|
|
virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd, bool callsignAtLatch);
|
|
|
|
virtual void setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel);
|
2020-07-28 13:22:26 +00:00
|
|
|
virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssHighThreshold, unsigned int ctcssLowThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, unsigned int accessMode, bool cosInvert, bool noiseSquelch, unsigned int squelchHighThreshold, unsigned int squelchLowThreshold, unsigned int rfAudioBoost, float maxDevLevel);
|
2020-06-30 11:35:03 +00:00
|
|
|
virtual void setFMExtParams(const std::string& ack, unsigned int audioBoost);
|
|
|
|
|
|
|
|
virtual bool open();
|
|
|
|
|
|
|
|
virtual unsigned int readDStarData(unsigned char* data);
|
|
|
|
virtual unsigned int readDMRData1(unsigned char* data);
|
|
|
|
virtual unsigned int readDMRData2(unsigned char* data);
|
|
|
|
virtual unsigned int readYSFData(unsigned char* data);
|
|
|
|
virtual unsigned int readP25Data(unsigned char* data);
|
|
|
|
virtual unsigned int readNXDNData(unsigned char* data);
|
2020-11-06 15:43:12 +00:00
|
|
|
virtual unsigned int readM17Data(unsigned char* data);
|
2020-06-30 11:35:03 +00:00
|
|
|
virtual unsigned int readFMData(unsigned char* data);
|
|
|
|
virtual unsigned int readAX25Data(unsigned char* data);
|
|
|
|
|
|
|
|
virtual bool hasDStarSpace() const;
|
|
|
|
virtual bool hasDMRSpace1() const;
|
|
|
|
virtual bool hasDMRSpace2() const;
|
|
|
|
virtual bool hasYSFSpace() const;
|
|
|
|
virtual bool hasP25Space() const;
|
|
|
|
virtual bool hasNXDNSpace() const;
|
2020-11-06 15:43:12 +00:00
|
|
|
virtual bool hasM17Space() const;
|
2020-06-30 11:35:03 +00:00
|
|
|
virtual bool hasPOCSAGSpace() const;
|
|
|
|
virtual unsigned int getFMSpace() const;
|
|
|
|
virtual bool hasAX25Space() const;
|
|
|
|
|
|
|
|
virtual bool hasTX() const;
|
|
|
|
virtual bool hasCD() const;
|
|
|
|
|
|
|
|
virtual bool hasLockout() const;
|
|
|
|
virtual bool hasError() const;
|
|
|
|
|
|
|
|
virtual bool writeConfig();
|
|
|
|
virtual bool writeDStarData(const unsigned char* data, unsigned int length);
|
|
|
|
virtual bool writeDMRData1(const unsigned char* data, unsigned int length);
|
|
|
|
virtual bool writeDMRData2(const unsigned char* data, unsigned int length);
|
|
|
|
virtual bool writeYSFData(const unsigned char* data, unsigned int length);
|
|
|
|
virtual bool writeP25Data(const unsigned char* data, unsigned int length);
|
|
|
|
virtual bool writeNXDNData(const unsigned char* data, unsigned int length);
|
2020-11-06 15:43:12 +00:00
|
|
|
virtual bool writeM17Data(const unsigned char* data, unsigned int length);
|
2020-06-30 11:35:03 +00:00
|
|
|
virtual bool writePOCSAGData(const unsigned char* data, unsigned int length);
|
|
|
|
virtual bool writeFMData(const unsigned char* data, unsigned int length);
|
|
|
|
virtual bool writeAX25Data(const unsigned char* data, unsigned int length);
|
|
|
|
|
|
|
|
virtual bool writeDStarInfo(const char* my1, const char* my2, const char* your, const char* type, const char* reflector);
|
|
|
|
virtual bool writeDMRInfo(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type);
|
2020-08-09 18:40:37 +00:00
|
|
|
virtual bool writeYSFInfo(const char* source, const char* dest, unsigned char dgid, const char* type, const char* origin);
|
2020-06-30 11:35:03 +00:00
|
|
|
virtual bool writeP25Info(const char* source, bool group, unsigned int dest, const char* type);
|
|
|
|
virtual bool writeNXDNInfo(const char* source, bool group, unsigned int dest, const char* type);
|
2020-11-06 15:43:12 +00:00
|
|
|
virtual bool writeM17Info(const char* source, const char* dest, const char* type);
|
2020-06-30 11:35:03 +00:00
|
|
|
virtual bool writePOCSAGInfo(unsigned int ric, const std::string& message);
|
|
|
|
virtual bool writeIPInfo(const std::string& address);
|
|
|
|
|
|
|
|
virtual bool writeDMRStart(bool tx);
|
|
|
|
virtual bool writeDMRShortLC(const unsigned char* lc);
|
|
|
|
virtual bool writeDMRAbort(unsigned int slotNo);
|
|
|
|
|
2020-11-13 14:56:39 +00:00
|
|
|
virtual bool writeTransparentData(const unsigned char* data, unsigned int length);
|
|
|
|
virtual unsigned int readTransparentData(unsigned char* data);
|
|
|
|
|
2020-06-30 11:35:03 +00:00
|
|
|
virtual bool writeSerial(const unsigned char* data, unsigned int length);
|
2020-11-13 14:56:39 +00:00
|
|
|
virtual unsigned int readSerial(unsigned char* data, unsigned int length);
|
2020-06-30 11:35:03 +00:00
|
|
|
|
2020-11-18 10:42:53 +00:00
|
|
|
virtual bool writeI2CCommand(const unsigned char* data, unsigned int length);
|
|
|
|
virtual bool writeI2CData(const unsigned char* data, unsigned int length);
|
2020-11-13 15:32:43 +00:00
|
|
|
|
2020-06-30 11:35:03 +00:00
|
|
|
virtual unsigned char getMode() const;
|
|
|
|
virtual bool setMode(unsigned char mode);
|
|
|
|
|
|
|
|
virtual bool sendCWId(const std::string& callsign);
|
|
|
|
|
|
|
|
virtual HW_TYPE getHWType() const;
|
|
|
|
|
|
|
|
virtual void clock(unsigned int ms);
|
|
|
|
|
|
|
|
virtual void close();
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string m_port;
|
2020-11-09 14:22:43 +00:00
|
|
|
unsigned int m_protocolVersion;
|
2020-06-30 11:35:03 +00:00
|
|
|
unsigned int m_dmrColorCode;
|
|
|
|
bool m_ysfLoDev;
|
|
|
|
unsigned int m_ysfTXHang;
|
|
|
|
unsigned int m_p25TXHang;
|
|
|
|
unsigned int m_nxdnTXHang;
|
2020-11-06 15:43:12 +00:00
|
|
|
unsigned int m_m17TXHang;
|
2020-06-30 11:35:03 +00:00
|
|
|
bool m_duplex;
|
|
|
|
bool m_rxInvert;
|
|
|
|
bool m_txInvert;
|
|
|
|
bool m_pttInvert;
|
|
|
|
unsigned int m_txDelay;
|
|
|
|
unsigned int m_dmrDelay;
|
|
|
|
float m_rxLevel;
|
|
|
|
float m_cwIdTXLevel;
|
|
|
|
float m_dstarTXLevel;
|
|
|
|
float m_dmrTXLevel;
|
|
|
|
float m_ysfTXLevel;
|
|
|
|
float m_p25TXLevel;
|
|
|
|
float m_nxdnTXLevel;
|
2020-11-06 15:43:12 +00:00
|
|
|
float m_m17TXLevel;
|
2020-06-30 11:35:03 +00:00
|
|
|
float m_pocsagTXLevel;
|
|
|
|
float m_fmTXLevel;
|
|
|
|
float m_ax25TXLevel;
|
|
|
|
float m_rfLevel;
|
2020-07-15 11:15:07 +00:00
|
|
|
bool m_useCOSAsLockout;
|
2020-06-30 11:35:03 +00:00
|
|
|
bool m_trace;
|
|
|
|
bool m_debug;
|
|
|
|
unsigned int m_rxFrequency;
|
|
|
|
unsigned int m_txFrequency;
|
|
|
|
unsigned int m_pocsagFrequency;
|
|
|
|
bool m_dstarEnabled;
|
|
|
|
bool m_dmrEnabled;
|
|
|
|
bool m_ysfEnabled;
|
|
|
|
bool m_p25Enabled;
|
|
|
|
bool m_nxdnEnabled;
|
2020-11-06 15:43:12 +00:00
|
|
|
bool m_m17Enabled;
|
2020-06-30 11:35:03 +00:00
|
|
|
bool m_pocsagEnabled;
|
|
|
|
bool m_fmEnabled;
|
|
|
|
bool m_ax25Enabled;
|
|
|
|
int m_rxDCOffset;
|
|
|
|
int m_txDCOffset;
|
|
|
|
ISerialPort* m_serial;
|
|
|
|
unsigned char* m_buffer;
|
|
|
|
unsigned int m_length;
|
|
|
|
unsigned int m_offset;
|
|
|
|
SERIAL_STATE m_state;
|
|
|
|
unsigned char m_type;
|
|
|
|
CRingBuffer<unsigned char> m_rxDStarData;
|
|
|
|
CRingBuffer<unsigned char> m_txDStarData;
|
|
|
|
CRingBuffer<unsigned char> m_rxDMRData1;
|
|
|
|
CRingBuffer<unsigned char> m_rxDMRData2;
|
|
|
|
CRingBuffer<unsigned char> m_txDMRData1;
|
|
|
|
CRingBuffer<unsigned char> m_txDMRData2;
|
|
|
|
CRingBuffer<unsigned char> m_rxYSFData;
|
|
|
|
CRingBuffer<unsigned char> m_txYSFData;
|
|
|
|
CRingBuffer<unsigned char> m_rxP25Data;
|
|
|
|
CRingBuffer<unsigned char> m_txP25Data;
|
|
|
|
CRingBuffer<unsigned char> m_rxNXDNData;
|
|
|
|
CRingBuffer<unsigned char> m_txNXDNData;
|
2020-11-06 15:43:12 +00:00
|
|
|
CRingBuffer<unsigned char> m_rxM17Data;
|
|
|
|
CRingBuffer<unsigned char> m_txM17Data;
|
2020-06-30 11:35:03 +00:00
|
|
|
CRingBuffer<unsigned char> m_txPOCSAGData;
|
|
|
|
CRingBuffer<unsigned char> m_rxFMData;
|
|
|
|
CRingBuffer<unsigned char> m_txFMData;
|
|
|
|
CRingBuffer<unsigned char> m_rxAX25Data;
|
|
|
|
CRingBuffer<unsigned char> m_txAX25Data;
|
2020-11-13 14:56:39 +00:00
|
|
|
CRingBuffer<unsigned char> m_rxSerialData;
|
2020-06-30 11:35:03 +00:00
|
|
|
CRingBuffer<unsigned char> m_rxTransparentData;
|
|
|
|
CRingBuffer<unsigned char> m_txTransparentData;
|
|
|
|
unsigned int m_sendTransparentDataFrameType;
|
|
|
|
CTimer m_statusTimer;
|
|
|
|
CTimer m_inactivityTimer;
|
|
|
|
CTimer m_playoutTimer;
|
|
|
|
unsigned int m_dstarSpace;
|
|
|
|
unsigned int m_dmrSpace1;
|
|
|
|
unsigned int m_dmrSpace2;
|
|
|
|
unsigned int m_ysfSpace;
|
|
|
|
unsigned int m_p25Space;
|
|
|
|
unsigned int m_nxdnSpace;
|
2020-11-06 15:43:12 +00:00
|
|
|
unsigned int m_m17Space;
|
2020-06-30 11:35:03 +00:00
|
|
|
unsigned int m_pocsagSpace;
|
|
|
|
unsigned int m_fmSpace;
|
|
|
|
unsigned int m_ax25Space;
|
|
|
|
bool m_tx;
|
|
|
|
bool m_cd;
|
|
|
|
bool m_lockout;
|
|
|
|
bool m_error;
|
|
|
|
unsigned char m_mode;
|
|
|
|
HW_TYPE m_hwType;
|
|
|
|
int m_ax25RXTwist;
|
|
|
|
unsigned int m_ax25TXDelay;
|
2020-07-01 09:59:46 +00:00
|
|
|
unsigned int m_ax25SlotTime;
|
|
|
|
unsigned int m_ax25PPersist;
|
2020-06-30 11:35:03 +00:00
|
|
|
|
|
|
|
std::string m_fmCallsign;
|
|
|
|
unsigned int m_fmCallsignSpeed;
|
|
|
|
unsigned int m_fmCallsignFrequency;
|
|
|
|
unsigned int m_fmCallsignTime;
|
|
|
|
unsigned int m_fmCallsignHoldoff;
|
|
|
|
float m_fmCallsignHighLevel;
|
|
|
|
float m_fmCallsignLowLevel;
|
|
|
|
bool m_fmCallsignAtStart;
|
|
|
|
bool m_fmCallsignAtEnd;
|
|
|
|
bool m_fmCallsignAtLatch;
|
|
|
|
std::string m_fmRfAck;
|
|
|
|
std::string m_fmExtAck;
|
|
|
|
unsigned int m_fmAckSpeed;
|
|
|
|
unsigned int m_fmAckFrequency;
|
|
|
|
unsigned int m_fmAckMinTime;
|
|
|
|
unsigned int m_fmAckDelay;
|
|
|
|
float m_fmAckLevel;
|
|
|
|
unsigned int m_fmTimeout;
|
|
|
|
float m_fmTimeoutLevel;
|
|
|
|
float m_fmCtcssFrequency;
|
|
|
|
unsigned int m_fmCtcssHighThreshold;
|
|
|
|
unsigned int m_fmCtcssLowThreshold;
|
|
|
|
float m_fmCtcssLevel;
|
|
|
|
unsigned int m_fmKerchunkTime;
|
|
|
|
unsigned int m_fmHangTime;
|
2020-07-15 11:15:07 +00:00
|
|
|
unsigned int m_fmAccessMode;
|
2020-06-30 11:35:03 +00:00
|
|
|
bool m_fmCOSInvert;
|
2020-07-28 13:22:26 +00:00
|
|
|
bool m_fmNoiseSquelch;
|
|
|
|
unsigned int m_fmSquelchHighThreshold;
|
|
|
|
unsigned int m_fmSquelchLowThreshold;
|
2020-06-30 11:35:03 +00:00
|
|
|
unsigned int m_fmRFAudioBoost;
|
|
|
|
unsigned int m_fmExtAudioBoost;
|
|
|
|
float m_fmMaxDevLevel;
|
|
|
|
bool m_fmExtEnable;
|
|
|
|
|
|
|
|
bool readVersion();
|
|
|
|
bool readStatus();
|
2020-11-09 14:22:43 +00:00
|
|
|
bool setConfig1();
|
|
|
|
bool setConfig2();
|
2020-06-30 11:35:03 +00:00
|
|
|
bool setFrequency();
|
|
|
|
bool setFMCallsignParams();
|
|
|
|
bool setFMAckParams();
|
|
|
|
bool setFMMiscParams();
|
|
|
|
bool setFMExtParams();
|
|
|
|
|
|
|
|
void printDebug();
|
|
|
|
|
|
|
|
RESP_TYPE_MMDVM getResponse();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|