Update the display and logging on incoming YSF network data.

This commit is contained in:
Jonathan Naylor 2016-05-19 19:08:48 +01:00
parent d5310f1983
commit 14f36a175d
15 changed files with 158 additions and 89 deletions

View file

@ -131,16 +131,17 @@ void CDisplay::clearDMR(unsigned int slotNo)
}
}
void CDisplay::writeFusion(const char* source, const char* dest, const char* type)
void CDisplay::writeFusion(const char* source, const char* dest, const char* type, const char* origin)
{
assert(source != NULL);
assert(dest != NULL);
assert(type != NULL);
assert(origin != NULL);
m_timer1.start();
m_mode1 = MODE_IDLE;
writeFusionInt(source, dest, type);
writeFusionInt(source, dest, type, origin);
}
void CDisplay::clearFusion()

View file

@ -41,7 +41,7 @@ public:
void writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type);
void clearDMR(unsigned int slotNo);
void writeFusion(const char* source, const char* dest, const char* type);
void writeFusion(const char* source, const char* dest, const char* type, const char* origin);
void clearFusion();
virtual void close() = 0;
@ -59,7 +59,7 @@ protected:
virtual void writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) = 0;
virtual void clearDMRInt(unsigned int slotNo) = 0;
virtual void writeFusionInt(const char* source, const char* dest, const char* type) = 0;
virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin) = 0;
virtual void clearFusionInt() = 0;
private:

View file

@ -593,11 +593,12 @@ void CHD44780::clearDMRInt(unsigned int slotNo)
}
}
void CHD44780::writeFusionInt(const char* source, const char* dest, const char* type)
void CHD44780::writeFusionInt(const char* source, const char* dest, const char* type, const char* origin)
{
assert(source != NULL);
assert(dest != NULL);
assert(type != NULL);
assert(origin != NULL);
#ifdef ADAFRUIT_DISPLAY
adafruitLCDColour(AC_RED);

View file

@ -70,7 +70,7 @@ protected:
virtual void writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type);
virtual void clearDMRInt(unsigned int slotNo);
virtual void writeFusionInt(const char* source, const char* dest, const char* type);
virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin);
virtual void clearFusionInt();
private:

View file

@ -181,11 +181,12 @@ void CNextion::clearDMRInt(unsigned int slotNo)
}
}
void CNextion::writeFusionInt(const char* source, const char* dest, const char* type)
void CNextion::writeFusionInt(const char* source, const char* dest, const char* type, const char* origin)
{
assert(source != NULL);
assert(dest != NULL);
assert(type != NULL);
assert(origin != NULL);
if (m_mode != MODE_YSF)
sendCommand("page YSF");
@ -194,8 +195,20 @@ void CNextion::writeFusionInt(const char* source, const char* dest, const char*
::sprintf(text, "t0.txt=\"%s %.10s\"", type, source);
sendCommand(text);
::sprintf(text, "t1.txt=\" %.10s\"", dest);
sendCommand(text);
if (m_size == "2.4" || m_size == "3.2") {
::sprintf(text, "t1.txt=\"%.10s\"", dest);
sendCommand(text);
if (::strcmp(origin, " ") != 0) {
::sprintf(text, "t2.txt=\"via %.10s\"", origin);
sendCommand(text);
}
} else if (m_size == "3.5") {
if (::strcmp(origin, " ") == 0)
::sprintf(text, "t1.txt=\"%.10s\"", dest);
else
::sprintf(text, "t1.txt=\"%.10s <- %-10s\"", dest, origin);
sendCommand(text);
}
m_mode = MODE_YSF;
}
@ -204,6 +217,8 @@ void CNextion::clearFusionInt()
{
sendCommand("t0.txt=\"Listening\"");
sendCommand("t1.txt=\"\"");
if (m_size == "2.4" || m_size == "3.2")
sendCommand("t2.txt=\"\"");
}
void CNextion::close()

View file

@ -46,7 +46,7 @@ protected:
virtual void writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type);
virtual void clearDMRInt(unsigned int slotNo);
virtual void writeFusionInt(const char* source, const char* dest, const char* type);
virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin);
virtual void clearFusionInt();
private:

View file

@ -60,7 +60,7 @@ void CNullDisplay::clearDMRInt(unsigned int slotNo)
{
}
void CNullDisplay::writeFusionInt(const char* source, const char* dest, const char* type)
void CNullDisplay::writeFusionInt(const char* source, const char* dest, const char* type, const char* origin)
{
}

View file

@ -44,7 +44,7 @@ protected:
virtual void writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type);
virtual void clearDMRInt(unsigned int slotNo);
virtual void writeFusionInt(const char* source, const char* dest, const char* type);
virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin);
virtual void clearFusionInt();
private:

View file

@ -187,7 +187,7 @@ void COLED::clearDMRInt(unsigned int slotNo)
display.display();
}
void COLED::writeFusionInt(const char* source, const char* dest, const char* type)
void COLED::writeFusionInt(const char* source, const char* dest, const char* type, const char* origin)
{
m_mode = MODE_YSF;
display.fillRect(0, OLED_LINE1, display.width(), 10, BLACK);

2
OLED.h
View file

@ -91,7 +91,7 @@ public:
virtual void writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type);
virtual void clearDMRInt(unsigned int slotNo);
virtual void writeFusionInt(const char* source, const char* dest, const char* type);
virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin);
virtual void clearFusionInt();
virtual void close();

View file

@ -259,11 +259,12 @@ void CTFTSerial::clearDMRInt(unsigned int slotNo)
}
}
void CTFTSerial::writeFusionInt(const char* source, const char* dest, const char* type)
void CTFTSerial::writeFusionInt(const char* source, const char* dest, const char* type, const char* origin)
{
assert(source != NULL);
assert(dest != NULL);
assert(type != NULL);
assert(origin != NULL);
if (m_mode != MODE_YSF) {
// Clear the screen
@ -278,24 +279,36 @@ void CTFTSerial::writeFusionInt(const char* source, const char* dest, const char
char text[30U];
::sprintf(text, "%s %.10s", type, source);
gotoPosPixel(5U, 80U);
gotoPosPixel(5U, 70U);
displayText(text);
::sprintf(text, " %.10s", dest);
gotoPosPixel(5U, 100U);
gotoPosPixel(5U, 90U);
displayText(text);
if (::strcmp(origin, " ") != 0) {
::sprintf(text, "via %.10s", origin);
gotoPosPixel(5U, 110U);
displayText(text);
} else {
gotoPosPixel(5U, 110U);
displayText(" ");
}
m_mode = MODE_YSF;
}
void CTFTSerial::clearFusionInt()
{
gotoPosPixel(5U, 80U);
displayText(" Listening ");
gotoPosPixel(5U, 70U);
displayText(" Listening ");
gotoPosPixel(5U, 100U);
displayText(" ");
gotoPosPixel(5U, 90U);
displayText(" ");
gotoPosPixel(5U, 110U);
displayText(" ");
}
void CTFTSerial::close()

View file

@ -46,7 +46,7 @@ protected:
virtual void writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type);
virtual void clearDMRInt(unsigned int slotNo);
virtual void writeFusionInt(const char* source, const char* dest, const char* type);
virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin);
virtual void clearFusionInt();
private:

View file

@ -39,8 +39,10 @@ m_rfFrames(0U),
m_netFrames(0U),
m_rfErrs(0U),
m_rfBits(0U),
m_source(NULL),
m_dest(NULL),
m_rfSource(NULL),
m_rfDest(NULL),
m_netSource(NULL),
m_netDest(NULL),
m_payload(),
m_fp(NULL)
{
@ -48,10 +50,15 @@ m_fp(NULL)
m_payload.setUplink(callsign);
m_payload.setDownlink(callsign);
m_netSource = new unsigned char[YSF_CALLSIGN_LENGTH];
m_netDest = new unsigned char[YSF_CALLSIGN_LENGTH];
}
CYSFControl::~CYSFControl()
{
delete[] m_netSource;
delete[] m_netDest;
}
bool CYSFControl::writeModem(unsigned char *data)
@ -102,44 +109,44 @@ bool CYSFControl::writeModem(unsigned char *data)
valid = m_payload.processHeaderData(data + 2U);
if (valid)
m_rfSource = m_payload.getSource();
unsigned char cm = fich.getCM();
if (cm == YSF_CM_GROUP) {
m_rfDest = (unsigned char*)"ALL ";
} else {
if (valid)
m_rfDest = m_payload.getDest();
}
if (m_rfSource != NULL && m_rfDest != NULL) {
m_display->writeFusion((char*)m_rfSource, (char*)m_rfDest, " ", "R");
LogMessage("YSF, received RF header from %10.10s to %10.10s", m_rfSource, m_rfDest);
} else if (m_rfSource == NULL && m_rfDest != NULL) {
m_display->writeFusion("??????????", (char*)m_rfDest, " ", "R");
LogMessage("YSF, received RF header from ?????????? to %10.10s", m_rfDest);
} else if (m_rfSource != NULL && m_rfDest == NULL) {
m_display->writeFusion((char*)m_rfSource, "??????????", " ", "R");
LogMessage("YSF, received RF header from %10.10s to ??????????", m_rfSource);
} else {
m_display->writeFusion("??????????", "??????????", " ", "R");
LogMessage("YSF, received RF header from ?????????? to ??????????");
}
data[0U] = TAG_DATA;
data[1U] = 0x00U;
writeNetwork(data);
if (m_duplex) {
fich.setMR(YSF_MR_BUSY);
fich.encode(data + 2U);
writeQueueRF(data);
}
if (valid)
m_source = m_payload.getSource();
unsigned char cm = fich.getCM();
if (cm == YSF_CM_GROUP) {
m_dest = (unsigned char*)"ALL ";
} else {
if (valid)
m_dest = m_payload.getDest();
}
#if defined(DUMP_YSF)
writeFile(data + 2U);
#endif
if (m_source != NULL && m_dest != NULL) {
m_display->writeFusion((char*)m_source, (char*)m_dest, "R");
LogMessage("YSF, received RF header from %10.10s to %10.10s", m_source, m_dest);
} else if (m_source == NULL && m_dest != NULL) {
m_display->writeFusion("??????????", (char*)m_dest, "R");
LogMessage("YSF, received RF header from ?????????? to %10.10s", m_dest);
} else if (m_source != NULL && m_dest == NULL) {
m_display->writeFusion((char*)m_source, "??????????", "R");
LogMessage("YSF, received RF header from %10.10s to ??????????", m_source);
} else {
m_display->writeFusion("??????????", "??????????", "R");
LogMessage("YSF, received RF header from ?????????? to ??????????");
if (m_duplex) {
fich.setMR(YSF_MR_BUSY);
fich.encode(data + 2U);
writeQueueRF(data);
}
} else if (valid && fi == YSF_FI_TERMINATOR) {
CSync::addYSFSync(data + 2U);
@ -153,16 +160,16 @@ bool CYSFControl::writeModem(unsigned char *data)
writeNetwork(data);
#if defined(DUMP_YSF)
writeFile(data + 2U);
#endif
if (m_duplex) {
fich.setMR(YSF_MR_BUSY);
fich.encode(data + 2U);
writeQueueRF(data);
}
#if defined(DUMP_YSF)
writeFile(data + 2U);
#endif
LogMessage("YSF, received RF end of transmission, %.1f seconds, BER: %.1f%%", float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits));
writeEndRF();
@ -208,36 +215,36 @@ bool CYSFControl::writeModem(unsigned char *data)
bool change = false;
if (m_dest == NULL) {
if (m_rfDest == NULL) {
unsigned char cm = fich.getCM();
if (cm == YSF_CM_GROUP) {
m_dest = (unsigned char*)"ALL ";
m_rfDest = (unsigned char*)"ALL ";
change = true;
} else if (valid) {
m_dest = m_payload.getDest();
if (m_dest != NULL)
m_rfDest = m_payload.getDest();
if (m_rfDest != NULL)
change = true;
}
}
if (valid && m_source == NULL) {
m_source = m_payload.getSource();
if (m_source != NULL)
if (valid && m_rfSource == NULL) {
m_rfSource = m_payload.getSource();
if (m_rfSource != NULL)
change = true;
}
if (change) {
if (m_source != NULL && m_dest != NULL) {
m_display->writeFusion((char*)m_source, (char*)m_dest, "R");
LogMessage("YSF, received RF data from %10.10s to %10.10s", m_source, m_dest);
if (m_rfSource != NULL && m_rfDest != NULL) {
m_display->writeFusion((char*)m_rfSource, (char*)m_rfDest, " ", "R");
LogMessage("YSF, received RF data from %10.10s to %10.10s", m_rfSource, m_rfDest);
}
if (m_source != NULL && m_dest == NULL) {
m_display->writeFusion((char*)m_source, "??????????", "R");
LogMessage("YSF, received RF data from %10.10s to ??????????", m_source);
if (m_rfSource != NULL && m_rfDest == NULL) {
m_display->writeFusion((char*)m_rfSource, "??????????", " ", "R");
LogMessage("YSF, received RF data from %10.10s to ??????????", m_rfSource);
}
if (m_source == NULL && m_dest != NULL) {
m_display->writeFusion("??????????", (char*)m_dest, "R");
LogMessage("YSF, received RF data from ?????????? to %10.10s", m_dest);
if (m_rfSource == NULL && m_rfDest != NULL) {
m_display->writeFusion("??????????", (char*)m_rfDest, " ", "R");
LogMessage("YSF, received RF data from ?????????? to %10.10s", m_rfDest);
}
}
@ -303,8 +310,8 @@ void CYSFControl::writeEndRF()
m_payload.reset();
// These variables are free'd by YSFPayload
m_source = NULL;
m_dest = NULL;
m_rfSource = NULL;
m_rfDest = NULL;
if (m_netState == RS_NET_IDLE) {
m_display->clearFusion();
@ -344,18 +351,51 @@ void CYSFControl::writeNetwork()
m_networkWatchdog.start();
if (!m_netTimeoutTimer.isRunning()) {
m_display->writeFusion("??????????", "??????????", "N");
LogMessage("YSF, received network data from ?????????? to ??????????");
if (::memcmp(data + 14U, " ", YSF_CALLSIGN_LENGTH) != 0)
::memcpy(m_netSource, data + 14U, YSF_CALLSIGN_LENGTH);
else
::memcpy(m_netSource, "??????????", YSF_CALLSIGN_LENGTH);
if (::memcmp(data + 24U, " ", YSF_CALLSIGN_LENGTH) != 0)
::memcpy(m_netDest, data + 24U, YSF_CALLSIGN_LENGTH);
else
::memcpy(m_netDest, "??????????", YSF_CALLSIGN_LENGTH);
m_display->writeFusion((char*)m_netSource, (char*)m_netDest, (char*)(data + 4U), "N");
LogMessage("YSF, received network data from %10.10s to %10.10s at %10.10s", m_netSource, m_netDest, data + 4U);
m_netTimeoutTimer.start();
m_holdoffTimer.start();
m_netState = RS_NET_AUDIO;
m_netFrames = 0U;
} else {
bool changed = false;
if (::memcmp(data + 14U, " ", YSF_CALLSIGN_LENGTH) != 0 && ::memcmp(m_netSource, "??????????", YSF_CALLSIGN_LENGTH) == 0) {
::memcpy(m_netSource, data + 14U, YSF_CALLSIGN_LENGTH);
changed = true;
}
if (::memcmp(data + 24U, " ", YSF_CALLSIGN_LENGTH) != 0 && ::memcmp(m_netDest, "??????????", YSF_CALLSIGN_LENGTH) == 0) {
::memcpy(m_netDest, data + 24U, YSF_CALLSIGN_LENGTH);
changed = true;
}
if (changed) {
m_display->writeFusion((char*)m_netSource, (char*)m_netDest, (char*)(data + 4U), "N");
LogMessage("YSF, received network data from %10.10s to %10.10s from %10.10s", m_netSource, m_netDest, data + 4U);
}
}
m_netFrames++;
bool end = data[34U] == 0x01U;
data[33U] = end ? TAG_EOT : TAG_DATA;
data[34U] = 0x00U;
CYSFFICH fich;
bool valid = fich.decode(data + 2U);
bool valid = fich.decode(data + 35U);
if (valid) {
// XXX Should set the downlink callsign
fich.setVoIP(true);
@ -363,9 +403,9 @@ void CYSFControl::writeNetwork()
fich.encode(data + 2U);
}
writeQueueNet(data);
writeQueueNet(data + 33U);
if (data[0U] == TAG_EOT) {
if (end) {
LogMessage("YSF, received network end of transmission, %.1f seconds", float(m_netFrames) / 10.0F);
writeEndNet();
}
@ -446,7 +486,7 @@ void CYSFControl::writeNetwork(const unsigned char *data)
if (m_rfTimeoutTimer.isRunning() && m_rfTimeoutTimer.hasExpired())
return;
m_network->write(m_source, m_dest, data + 2U, data[0U] == TAG_EOT);
m_network->write(m_rfSource, m_rfDest, data + 2U, data[0U] == TAG_EOT);
}
bool CYSFControl::openFile()

View file

@ -56,8 +56,10 @@ private:
unsigned int m_netFrames;
unsigned int m_rfErrs;
unsigned int m_rfBits;
unsigned char* m_source;
unsigned char* m_dest;
unsigned char* m_rfSource;
unsigned char* m_rfDest;
unsigned char* m_netSource;
unsigned char* m_netDest;
CYSFPayload m_payload;
FILE* m_fp;

View file

@ -164,10 +164,7 @@ void CYSFNetwork::clock(unsigned int ms)
if (end)
::memset(m_tag, ' ', YSF_CALLSIGN_LENGTH);
buffer[33U] = end ? TAG_EOT : TAG_DATA;
buffer[34U] = 0x00U;
m_buffer.addData(buffer + 33U, YSF_FRAME_LENGTH_BYTES + 2U);
m_buffer.addData(buffer, 155U);
}
unsigned int CYSFNetwork::read(unsigned char* data)
@ -177,9 +174,9 @@ unsigned int CYSFNetwork::read(unsigned char* data)
if (m_buffer.isEmpty())
return 0U;
m_buffer.getData(data, YSF_FRAME_LENGTH_BYTES + 2U);
m_buffer.getData(data, 155U);
return YSF_FRAME_LENGTH_BYTES + 2U;
return 155U;
}
void CYSFNetwork::reset()