1
0
mirror of https://github.com/peterantypas/maiana.git synced 2025-05-15 23:10:11 -07:00

Leaving this branch alone

This commit is contained in:
Peter Antypas 2023-06-19 06:58:10 -07:00
parent 0f0424361a
commit 19ae8c48a8
3 changed files with 45 additions and 3 deletions

View File

@ -37,6 +37,7 @@ public:
private: private:
void ensureChannelIsTracked(VHFChannel ch); void ensureChannelIsTracked(VHFChannel ch);
void dumpStats();
private: private:
class PacketStats class PacketStats
{ {
@ -55,6 +56,7 @@ private:
NMEAEncoder mEncoder; NMEAEncoder mEncoder;
std::vector<std::string> mSentences; std::vector<std::string> mSentences;
StationData mStationData; StationData mStationData;
PacketStats mStats;
}; };
#endif /* RXPACKETPROCESSOR_HPP_ */ #endif /* RXPACKETPROCESSOR_HPP_ */

View File

@ -40,7 +40,7 @@ RXPacketProcessor::RXPacketProcessor ()
{ {
mSentences.reserve(4); // We're not going to need more than 2 sentences for the longest AIS message we report ... mSentences.reserve(4); // We're not going to need more than 2 sentences for the longest AIS message we report ...
Configuration::instance().readStationData(mStationData); Configuration::instance().readStationData(mStationData);
EventQueue::instance().addObserver(this, AIS_PACKET_EVENT); EventQueue::instance().addObserver(this, AIS_PACKET_EVENT|CLOCK_EVENT);
} }
RXPacketProcessor::~RXPacketProcessor () RXPacketProcessor::~RXPacketProcessor ()
@ -53,12 +53,28 @@ void RXPacketProcessor::processEvent(const Event &e)
{ {
switch(e.type) switch(e.type)
{ {
case CLOCK_EVENT:
if ( e.clock.utc % 60 == 0 )
{
dumpStats();
}
break;
case AIS_PACKET_EVENT: case AIS_PACKET_EVENT:
{ {
ASSERT(e.rxPacket); ASSERT(e.rxPacket);
if (e.rxPacket->isBad() || !e.rxPacket->checkCRC ()) if ( e.rxPacket->isBad() )
{
mStats.bad++;
return; return;
}
if ( !e.rxPacket->checkCRC ())
{
mStats.invalid++;
return;
}
mStats.good++;
bsp_rx_led_on(); bsp_rx_led_on();
if ( e.rxPacket->messageType() == 15 ) if ( e.rxPacket->messageType() == 15 )
@ -157,3 +173,18 @@ void RXPacketProcessor::processEvent(const Event &e)
} }
} }
void RXPacketProcessor::dumpStats()
{
Event *e = EventPool::instance().newEvent(PROPR_NMEA_SENTENCE);
if ( !e )
return;
sprintf(e->nmeaBuffer.sentence, "$PAISTAT,%lu,%lu,%lu*", mStats.good, mStats.bad, mStats.invalid);
Utils::completeNMEA(e->nmeaBuffer.sentence);
EventQueue::instance().push(e);
mStats.good = 0;
mStats.bad = 0;
mStats.invalid = 0;
}

View File

@ -631,9 +631,18 @@ uint32_t bsp_get_system_clock()
uint8_t bsp_tx_spi_byte(uint8_t data) uint8_t bsp_tx_spi_byte(uint8_t data)
{ {
#if 1
while (!(SPI1->SR & SPI_SR_TXE));
*((__IO uint8_t *)&(SPI1->DR)) = data;
while (!(SPI1->SR & SPI_SR_RXNE));
return SPI1->DR;
#else
uint8_t result = 0; uint8_t result = 0;
HAL_SPI_TransmitReceive(&hspi1, &data, &result, 1, 2); HAL_SPI_TransmitReceive(&hspi1, &data, &result, 1, 2);
return result; return result;
#endif
} }
void bsp_reboot() void bsp_reboot()