mirror of
https://github.com/peterantypas/maiana.git
synced 2025-06-05 09:10:30 -07:00
Multiplexing to single UART
This commit is contained in:
parent
2c114fd11f
commit
dcf4fdd6e5
@ -360,5 +360,12 @@
|
|||||||
</scannerConfigBuildInfo>
|
</scannerConfigBuildInfo>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||||
<storageModule moduleId="refreshScope"/>
|
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||||
|
<configuration configurationName="Debug">
|
||||||
|
<resource resourceType="PROJECT" workspacePath="/ais_transponder"/>
|
||||||
|
</configuration>
|
||||||
|
<configuration configurationName="Release">
|
||||||
|
<resource resourceType="PROJECT" workspacePath="/ais_transponder"/>
|
||||||
|
</configuration>
|
||||||
|
</storageModule>
|
||||||
</cproject>
|
</cproject>
|
||||||
|
@ -111,6 +111,25 @@ void write_char(USART_TypeDef* USARTx, char c)
|
|||||||
USART_SendData(USARTx, c);
|
USART_SendData(USARTx, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MULTIPLEXED_OUTPUT
|
||||||
|
|
||||||
|
void DataTerminal::write(const char *cls, const char* s, bool interactive)
|
||||||
|
{
|
||||||
|
if ( mInteractive && !interactive )
|
||||||
|
return;
|
||||||
|
|
||||||
|
write_char(USART3, '[');
|
||||||
|
for ( size_t i = 0; i < strlen(cls); ++i )
|
||||||
|
write_char(USART3, cls[i]);
|
||||||
|
write_char(USART3, ']');
|
||||||
|
|
||||||
|
for ( int i = 0; s[i] != 0; ++i )
|
||||||
|
write_char(USART3, s[i]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
void DataTerminal::write(const char* s, bool interactive)
|
void DataTerminal::write(const char* s, bool interactive)
|
||||||
{
|
{
|
||||||
if ( mInteractive && !interactive )
|
if ( mInteractive && !interactive )
|
||||||
@ -119,6 +138,7 @@ void DataTerminal::write(const char* s, bool interactive)
|
|||||||
for ( int i = 0; s[i] != 0; ++i )
|
for ( int i = 0; s[i] != 0; ++i )
|
||||||
write_char(USART3, s[i]);
|
write_char(USART3, s[i]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void DataTerminal::clearScreen()
|
void DataTerminal::clearScreen()
|
||||||
{
|
{
|
||||||
@ -128,7 +148,11 @@ void DataTerminal::clearScreen()
|
|||||||
|
|
||||||
void DataTerminal::_write(const char *s)
|
void DataTerminal::_write(const char *s)
|
||||||
{
|
{
|
||||||
|
#ifdef MULTIPLEXED_OUTPUT
|
||||||
|
write("", s, true);
|
||||||
|
#else
|
||||||
write(s, true);
|
write(s, true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataTerminal::showScreen(MenuScreen screen)
|
void DataTerminal::showScreen(MenuScreen screen)
|
||||||
|
@ -21,8 +21,11 @@ public:
|
|||||||
void init();
|
void init();
|
||||||
|
|
||||||
void processEvent(Event *e);
|
void processEvent(Event *e);
|
||||||
|
#ifdef MULTIPLEXED_OUTPUT
|
||||||
|
void write(const char* cls, const char* line, bool interactive=false);
|
||||||
|
#else
|
||||||
void write(const char* line, bool interactive = false);
|
void write(const char* line, bool interactive = false);
|
||||||
|
#endif
|
||||||
void processCharacter(char c);
|
void processCharacter(char c);
|
||||||
private:
|
private:
|
||||||
DataTerminal();
|
DataTerminal();
|
||||||
|
@ -248,9 +248,13 @@ void GPS::parseSentence(const char *buff)
|
|||||||
if ( sentence.code().find("RMC") == 2 ) {
|
if ( sentence.code().find("RMC") == 2 ) {
|
||||||
#ifdef ENABLE_TERMINAL
|
#ifdef ENABLE_TERMINAL
|
||||||
#ifdef OUTPUT_GPS_NMEA
|
#ifdef OUTPUT_GPS_NMEA
|
||||||
|
#ifdef MULTIPLEXED_OUTPUT
|
||||||
|
DataTerminal::instance().write("NMEA", buff);
|
||||||
|
#else
|
||||||
DataTerminal::instance().write(buff);
|
DataTerminal::instance().write(buff);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// This is the time that corresponds to the previous PPS
|
// This is the time that corresponds to the previous PPS
|
||||||
const vector<string> &fields = sentence.fields();
|
const vector<string> &fields = sentence.fields();
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "printf2.h"
|
#include "printf2.h"
|
||||||
#include "AISChannels.h"
|
#include "AISChannels.h"
|
||||||
|
|
||||||
|
static char __buff[100];
|
||||||
|
|
||||||
RXPacketProcessor::RXPacketProcessor ()
|
RXPacketProcessor::RXPacketProcessor ()
|
||||||
: mLastDumpTime(0), mGoodCount(0), mBadCRCCount(0), mInvalidCount(0), mLat(-200), mLng(-200)
|
: mLastDumpTime(0), mGoodCount(0), mBadCRCCount(0), mInvalidCount(0), mLat(-200), mLng(-200)
|
||||||
@ -48,8 +49,10 @@ void RXPacketProcessor::processEvent(Event *e)
|
|||||||
else if ( pe->mTime - mLastDumpTime >= 60 ) {
|
else if ( pe->mTime - mLastDumpTime >= 60 ) {
|
||||||
mLastDumpTime = pe->mTime;
|
mLastDumpTime = pe->mTime;
|
||||||
float yield = (float)mGoodCount / (float)(mGoodCount+mBadCRCCount+mInvalidCount);
|
float yield = (float)mGoodCount / (float)(mGoodCount+mBadCRCCount+mInvalidCount);
|
||||||
printf2("\n[Yield: %.1fpct, Valid: %d, Wrong CRC: %d, Malformed: %d]\r\n", yield*100.0, mGoodCount, mBadCRCCount, mInvalidCount);
|
printf2("\r\n");
|
||||||
printf2("[Unique MMSIs: %d]\r\n\n", mUniqueMMSIs.size());
|
printf2("[Yield: %.1fpct, Valid: %d, Wrong CRC: %d, Malformed: %d]\r\n", yield*100.0, mGoodCount, mBadCRCCount, mInvalidCount);
|
||||||
|
printf2("[Unique MMSIs: %d]\r\n", mUniqueMMSIs.size());
|
||||||
|
printf2("\r\n");
|
||||||
mUniqueMMSIs.clear();
|
mUniqueMMSIs.clear();
|
||||||
mBadCRCCount = 0;
|
mBadCRCCount = 0;
|
||||||
mInvalidCount = 0;
|
mInvalidCount = 0;
|
||||||
@ -125,8 +128,13 @@ void RXPacketProcessor::processEvent(Event *e)
|
|||||||
mSentences.clear();
|
mSentences.clear();
|
||||||
mEncoder.encode(*pe->mPacket, mSentences);
|
mEncoder.encode(*pe->mPacket, mSentences);
|
||||||
for (vector<string>::iterator i = mSentences.begin(); i != mSentences.end(); ++i) {
|
for (vector<string>::iterator i = mSentences.begin(); i != mSentences.end(); ++i) {
|
||||||
|
#ifdef MULTIPLEXED_OUTPUT
|
||||||
|
sprintf(__buff, "%s\r\n", i->c_str());
|
||||||
|
DataTerminal::instance().write("NMEA", __buff);
|
||||||
|
#else
|
||||||
DataTerminal::instance().write(i->c_str());
|
DataTerminal::instance().write(i->c_str());
|
||||||
DataTerminal::instance().write("\r\n");
|
DataTerminal::instance().write("\r\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
switch (pe->mPacket->messageType()) {
|
switch (pe->mPacket->messageType()) {
|
||||||
|
@ -132,8 +132,10 @@ void TXScheduler::processEvent(Event *event)
|
|||||||
|
|
||||||
void TXScheduler::scheduleTestPacket()
|
void TXScheduler::scheduleTestPacket()
|
||||||
{
|
{
|
||||||
/*
|
VHFChannel channel = CH_84;
|
||||||
TXPacket *p = TXPacketPool::instance().newTXPacket(AIS_CHANNELS[rand() % 2 + 18].vhf, mUTC);
|
if ( rand() % 2 == 0 )
|
||||||
|
channel = CH_85;
|
||||||
|
TXPacket *p = TXPacketPool::instance().newTXPacket(channel, mUTC);
|
||||||
if ( !p )
|
if ( !p )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -141,7 +143,6 @@ void TXScheduler::scheduleTestPacket()
|
|||||||
p->addBit(rand() % 2);
|
p->addBit(rand() % 2);
|
||||||
}
|
}
|
||||||
RadioManager::instance().scheduleTransmission(p);
|
RadioManager::instance().scheduleTransmission(p);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,12 +31,12 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifdef CALIBRATION_MODE
|
#ifdef CALIBRATION_MODE
|
||||||
#define TX_POWER_LEVEL PWR_M16
|
#define TX_POWER_LEVEL PWR_M10
|
||||||
#else
|
#else
|
||||||
#ifdef TX_TEST_MODE
|
#ifdef TX_TEST_MODE
|
||||||
#define TX_POWER_LEVEL PWR_P16
|
#define TX_POWER_LEVEL PWR_P27
|
||||||
#else
|
#else
|
||||||
#define TX_POWER_LEVEL PWR_M27
|
#define TX_POWER_LEVEL PWR_M10
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -77,5 +77,16 @@
|
|||||||
// Extra debugging using halting assertions
|
// Extra debugging using halting assertions
|
||||||
#define DEV_MODE 1
|
#define DEV_MODE 1
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Defining this symbol forces all output (NMEA + printf2 + LED status) to the high-speed UART3 for tunneling to an application that demuxes it.
|
||||||
|
* Multiplexed output is still ASCII, but every line of text begins with a message class in square brackets. Examples:
|
||||||
|
*
|
||||||
|
* [NMEA]!AIVDM,....
|
||||||
|
* [DEBUG]GPS Initialized
|
||||||
|
* [LED]0:BLINK
|
||||||
|
* [ASSERT]...
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define MULTIPLEXED_OUTPUT 1
|
||||||
|
|
||||||
#endif /* GLOBALS_H_ */
|
#endif /* GLOBALS_H_ */
|
||||||
|
@ -95,10 +95,10 @@ main(int argc, char* argv[])
|
|||||||
RadioManager::instance().init();
|
RadioManager::instance().init();
|
||||||
RadioManager::instance().transmitCW(CH_86);
|
RadioManager::instance().transmitCW(CH_86);
|
||||||
#elif defined TX_TEST_MODE
|
#elif defined TX_TEST_MODE
|
||||||
Radio::instance().init();
|
RadioManager::instance().init();
|
||||||
GPS::instance().init();
|
GPS::instance().init();
|
||||||
Radio::instance().start();
|
RadioManager::instance().start();
|
||||||
Radio::instance().startReceiving(4);
|
//Radio::instance().startReceiving(4);
|
||||||
txScheduler.startTXTesting();
|
txScheduler.startTXTesting();
|
||||||
#else
|
#else
|
||||||
RXPacketProcessor packetProcessor;
|
RXPacketProcessor packetProcessor;
|
||||||
|
@ -11,12 +11,15 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "Events.hpp"
|
#include "Events.hpp"
|
||||||
#include "Utils.hpp"
|
#include "Utils.hpp"
|
||||||
|
#include "globals.h"
|
||||||
#include "EventQueue.hpp"
|
#include "EventQueue.hpp"
|
||||||
#include <diag/Trace.h>
|
#include <diag/Trace.h>
|
||||||
|
#include "DataTerminal.hpp"
|
||||||
|
|
||||||
|
|
||||||
void printf2_Init(int baudrate)
|
void printf2_Init(int baudrate)
|
||||||
{
|
{
|
||||||
|
#ifndef MULTIPLEXED_OUTPUT
|
||||||
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
|
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
|
||||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
@ -34,10 +37,11 @@ void printf2_Init(int baudrate)
|
|||||||
USART_Init(USART2, &USART_InitStructure);
|
USART_Init(USART2, &USART_InitStructure);
|
||||||
|
|
||||||
USART_Cmd(USART2, ENABLE);
|
USART_Cmd(USART2, ENABLE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef MULTIPLEXED_OUTPUT
|
||||||
void USART_putc(USART_TypeDef* USARTx, char c)
|
void USART_putc(USART_TypeDef* USARTx, char c)
|
||||||
{
|
{
|
||||||
while (!(USARTx->ISR & 0x00000040))
|
while (!(USARTx->ISR & 0x00000040))
|
||||||
@ -45,11 +49,13 @@ void USART_putc(USART_TypeDef* USARTx, char c)
|
|||||||
USART_SendData(USARTx, c);
|
USART_SendData(USARTx, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void USART_puts(USART_TypeDef* USARTx, const char *s)
|
void USART_puts(USART_TypeDef* USARTx, const char *s)
|
||||||
{
|
{
|
||||||
for ( int i = 0; s[i] != 0; ++i )
|
for ( int i = 0; s[i] != 0; ++i )
|
||||||
USART_putc(USARTx, s[i]);
|
USART_putc(USARTx, s[i]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static char __buffer[256];
|
static char __buffer[256];
|
||||||
|
|
||||||
@ -59,13 +65,16 @@ void printf2_now(const char *format, ...)
|
|||||||
va_start(list, format);
|
va_start(list, format);
|
||||||
vsnprintf(__buffer, 255, format, list);
|
vsnprintf(__buffer, 255, format, list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
|
#ifdef MULTIPLEXED_OUTPUT
|
||||||
|
DataTerminal::instance().write("DEBUG", __buffer);
|
||||||
|
#else
|
||||||
USART_puts(USART2, __buffer);
|
USART_puts(USART2, __buffer);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_PRINTF2
|
#ifdef ENABLE_PRINTF2
|
||||||
void printf2(const char *format, ...)
|
void printf2(const char *format, ...)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( Utils::inISR() ) {
|
if ( Utils::inISR() ) {
|
||||||
DebugEvent *e = static_cast<DebugEvent*>(EventPool::instance().newEvent(DEBUG_EVENT));
|
DebugEvent *e = static_cast<DebugEvent*>(EventPool::instance().newEvent(DEBUG_EVENT));
|
||||||
if ( e == NULL )
|
if ( e == NULL )
|
||||||
@ -83,7 +92,11 @@ void printf2(const char *format, ...)
|
|||||||
va_start(list, format);
|
va_start(list, format);
|
||||||
vsnprintf(__buffer, 255, format, list);
|
vsnprintf(__buffer, 255, format, list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
|
#ifdef MULTIPLEXED_OUTPUT
|
||||||
|
DataTerminal::instance().write("DEBUG", __buffer);
|
||||||
|
#else
|
||||||
USART_puts(USART2, __buffer);
|
USART_puts(USART2, __buffer);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user