New option SendFrameType so one can send transparent data also to the modem serial port.

If set, one then has to specify the frame type (0x80 for modem serial of 0x90 for transparent data) as first byte af the message.
This commit is contained in:
root 2018-08-13 20:39:16 +02:00
parent f58ef17eb7
commit 86fb3b6944
5 changed files with 29 additions and 4 deletions

View file

@ -114,6 +114,7 @@ m_transparentEnabled(false),
m_transparentRemoteAddress(), m_transparentRemoteAddress(),
m_transparentRemotePort(0U), m_transparentRemotePort(0U),
m_transparentLocalPort(0U), m_transparentLocalPort(0U),
m_transparentSendFrameType(0U),
m_umpEnabled(false), m_umpEnabled(false),
m_umpPort(), m_umpPort(),
m_dstarEnabled(false), m_dstarEnabled(false),
@ -464,6 +465,8 @@ bool CConf::read()
m_transparentRemotePort = (unsigned int)::atoi(value); m_transparentRemotePort = (unsigned int)::atoi(value);
else if (::strcmp(key, "LocalPort") == 0) else if (::strcmp(key, "LocalPort") == 0)
m_transparentLocalPort = (unsigned int)::atoi(value); m_transparentLocalPort = (unsigned int)::atoi(value);
else if (::strcmp(key, "SendFrameType") == 0)
m_transparentSendFrameType = (unsigned int)::atoi(value);
} else if (section == SECTION_UMP) { } else if (section == SECTION_UMP) {
if (::strcmp(key, "Enable") == 0) if (::strcmp(key, "Enable") == 0)
m_umpEnabled = ::atoi(value) == 1; m_umpEnabled = ::atoi(value) == 1;
@ -1054,6 +1057,11 @@ unsigned int CConf::getTransparentLocalPort() const
return m_transparentLocalPort; return m_transparentLocalPort;
} }
unsigned int CConf::getTransparentSendFrameType() const
{
return m_transparentSendFrameType;
}
bool CConf::getUMPEnabled() const bool CConf::getUMPEnabled() const
{ {
return m_umpEnabled; return m_umpEnabled;

2
Conf.h
View file

@ -99,6 +99,7 @@ public:
std::string getTransparentRemoteAddress() const; std::string getTransparentRemoteAddress() const;
unsigned int getTransparentRemotePort() const; unsigned int getTransparentRemotePort() const;
unsigned int getTransparentLocalPort() const; unsigned int getTransparentLocalPort() const;
unsigned int getTransparentSendFrameType() const;
// The UMP section // The UMP section
bool getUMPEnabled() const; bool getUMPEnabled() const;
@ -322,6 +323,7 @@ private:
std::string m_transparentRemoteAddress; std::string m_transparentRemoteAddress;
unsigned int m_transparentRemotePort; unsigned int m_transparentRemotePort;
unsigned int m_transparentLocalPort; unsigned int m_transparentLocalPort;
unsigned int m_transparentSendFrameType;
bool m_umpEnabled; bool m_umpEnabled;
std::string m_umpPort; std::string m_umpPort;

View file

@ -315,15 +315,18 @@ int CMMDVMHost::run()
unsigned int transparentPort = 0U; unsigned int transparentPort = 0U;
CUDPSocket* transparentSocket = NULL; CUDPSocket* transparentSocket = NULL;
unsigned int sendFrameType = 0U;
if (m_conf.getTransparentEnabled()) { if (m_conf.getTransparentEnabled()) {
std::string remoteAddress = m_conf.getTransparentRemoteAddress(); std::string remoteAddress = m_conf.getTransparentRemoteAddress();
unsigned int remotePort = m_conf.getTransparentRemotePort(); unsigned int remotePort = m_conf.getTransparentRemotePort();
unsigned int localPort = m_conf.getTransparentLocalPort(); unsigned int localPort = m_conf.getTransparentLocalPort();
sendFrameType = m_conf.getTransparentSendFrameType();
LogInfo("Transparent Data"); LogInfo("Transparent Data");
LogInfo(" Remote Address: %s", remoteAddress.c_str()); LogInfo(" Remote Address: %s", remoteAddress.c_str());
LogInfo(" Remote Port: %u", remotePort); LogInfo(" Remote Port: %u", remotePort);
LogInfo(" Local Port: %u", localPort); LogInfo(" Local Port: %u", localPort);
LogInfo(" Send Frame Type: %u", sendFrameType);
transparentAddress = CUDPSocket::lookup(remoteAddress); transparentAddress = CUDPSocket::lookup(remoteAddress);
transparentPort = remotePort; transparentPort = remotePort;
@ -884,7 +887,7 @@ int CMMDVMHost::run()
unsigned int port = 0U; unsigned int port = 0U;
len = transparentSocket->read(data, 200U, address, port); len = transparentSocket->read(data, 200U, address, port);
if (len > 0U) if (len > 0U)
m_modem->writeTransparentData(data, len); m_modem->writeTransparentData(data, len, sendFrameType);
} }
unsigned int ms = stopWatch.elapsed(); unsigned int ms = stopWatch.elapsed();

View file

@ -1085,7 +1085,7 @@ bool CModem::writePOCSAGData(const unsigned char* data, unsigned int length)
return true; return true;
} }
bool CModem::writeTransparentData(const unsigned char* data, unsigned int length) bool CModem::writeTransparentData(const unsigned char* data, unsigned int length, unsigned int sendFrameType)
{ {
assert(data != NULL); assert(data != NULL);
assert(length > 0U); assert(length > 0U);
@ -1096,7 +1096,19 @@ bool CModem::writeTransparentData(const unsigned char* data, unsigned int length
buffer[1U] = length + 3U; buffer[1U] = length + 3U;
buffer[2U] = MMDVM_TRANSPARENT; buffer[2U] = MMDVM_TRANSPARENT;
if (sendFrameType>0) {
::memcpy(buffer + 2U, data, length);
length--;
buffer[1U]--;
//when sendFrameType==1 , only 0x80 and 0x90 (MMDVM_SERIAL and MMDVM_TRANSPARENT) are allowed
// and reverted to default (MMDVM_TRANSPARENT) for any other value
//when >1, frame type is not checked
if (sendFrameType==1) {
if ((buffer[2U] & 0xE0) != 0x80) buffer[2U] = MMDVM_TRANSPARENT;
}
} else {
::memcpy(buffer + 3U, data, length); ::memcpy(buffer + 3U, data, length);
}
unsigned char len = length + 3U; unsigned char len = length + 3U;
m_txTransparentData.addData(&len, 1U); m_txTransparentData.addData(&len, 1U);

View file

@ -77,7 +77,7 @@ public:
bool writeP25Data(const unsigned char* data, unsigned int length); bool writeP25Data(const unsigned char* data, unsigned int length);
bool writeNXDNData(const unsigned char* data, unsigned int length); bool writeNXDNData(const unsigned char* data, unsigned int length);
bool writePOCSAGData(const unsigned char* data, unsigned int length); bool writePOCSAGData(const unsigned char* data, unsigned int length);
bool writeTransparentData(const unsigned char* data, unsigned int length); bool writeTransparentData(const unsigned char* data, unsigned int length, unsigned int sendFrameType);
bool writeDMRStart(bool tx); bool writeDMRStart(bool tx);
bool writeDMRShortLC(const unsigned char* lc); bool writeDMRShortLC(const unsigned char* lc);