kopia lustrzana https://github.com/mobilinkd/tnc3-firmware
Revert "Statically allocate buffers needed for serial thread and queue."
This reverts commit 0c9135c096
.
m17
rodzic
0c9135c096
commit
b525d5b53b
|
@ -155,7 +155,7 @@ struct M17FrameDecoder
|
|||
|
||||
enum class State {LSF, STREAM, BASIC_PACKET, FULL_PACKET};
|
||||
enum class SyncWordType { LSF, STREAM, PACKET, RESERVED };
|
||||
enum class DecodeResult { FAIL, OK, EOS, INCOMPLETE };
|
||||
enum class DecodeResult { FAIL, OK, EOS };
|
||||
|
||||
State state_ = State::LSF;
|
||||
|
||||
|
@ -206,8 +206,6 @@ struct M17FrameDecoder
|
|||
~M17FrameDecoder()
|
||||
{}
|
||||
|
||||
State state() const { return state_; }
|
||||
|
||||
void reset() { state_ = State::LSF; }
|
||||
|
||||
void passall(bool enabled) { passall_ = enabled; }
|
||||
|
@ -277,9 +275,6 @@ struct M17FrameDecoder
|
|||
for (auto c : current_lsf) crc_(c);
|
||||
auto checksum = crc_.get();
|
||||
INFO("LSF crc = %04x", checksum);
|
||||
#ifdef KISS_LOGGING
|
||||
dump(current_lsf);
|
||||
#endif
|
||||
|
||||
if (checksum == 0)
|
||||
{
|
||||
|
@ -324,7 +319,7 @@ struct M17FrameDecoder
|
|||
return false;
|
||||
}
|
||||
decoded >>= 12; // Remove check bits and parity.
|
||||
TNC_DEBUG("Golay decode good for %08lx (%du)", decoded, i);
|
||||
DEBUG("Golay decode good for %08lx (%du)", decoded, i);
|
||||
// append codeword.
|
||||
if (i & 1)
|
||||
{
|
||||
|
@ -356,7 +351,7 @@ struct M17FrameDecoder
|
|||
|
||||
lich_segments |= (1 << fragment_number); // Indicate segment received.
|
||||
INFO("got segment %d, have %02x", int(fragment_number), int(lich_segments));
|
||||
if (lich_segments != 0x3F) return DecodeResult::INCOMPLETE; // More to go...
|
||||
if (lich_segments != 0x3F) return DecodeResult::FAIL; // More to go...
|
||||
|
||||
crc_.reset();
|
||||
for (auto c : output.lich) crc_(c);
|
||||
|
@ -364,7 +359,6 @@ struct M17FrameDecoder
|
|||
INFO("LICH crc = %04x", checksum);
|
||||
if (checksum == 0)
|
||||
{
|
||||
lich_segments = 0;
|
||||
state_ = State::STREAM;
|
||||
lsf = tnc::hdlc::acquire_wait();
|
||||
for (auto c : output.lich) lsf->push_back(c);
|
||||
|
@ -372,7 +366,6 @@ struct M17FrameDecoder
|
|||
lsf->push_back(0);
|
||||
lsf->source(0x20);
|
||||
ber = 0;
|
||||
dump(output.lich);
|
||||
return DecodeResult::OK;
|
||||
}
|
||||
#ifdef KISS_LOGGING
|
||||
|
@ -382,14 +375,13 @@ struct M17FrameDecoder
|
|||
lich_segments = 0;
|
||||
output.lich.fill(0);
|
||||
ber = 128;
|
||||
return DecodeResult::INCOMPLETE;
|
||||
return DecodeResult::FAIL;
|
||||
}
|
||||
|
||||
[[gnu::noinline]]
|
||||
DecodeResult decode_stream(buffer_t& buffer, tnc::hdlc::IoFrame*& stream, int& ber)
|
||||
{
|
||||
std::array<uint8_t, 20> stream_segment;
|
||||
DecodeResult result = DecodeResult::OK;
|
||||
|
||||
unpack_lich(buffer);
|
||||
|
||||
|
@ -411,12 +403,11 @@ struct M17FrameDecoder
|
|||
{
|
||||
INFO("EOS");
|
||||
state_ = State::LSF;
|
||||
result = DecodeResult::EOS;
|
||||
}
|
||||
stream->push_back(0);
|
||||
stream->push_back(0);
|
||||
stream->source(0x20);
|
||||
return result;
|
||||
return state_ == State::LSF ? DecodeResult::EOS : DecodeResult::OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -307,28 +307,21 @@ extern "C" void HAL_UART_ErrorCallback(UART_HandleTypeDef* huart)
|
|||
|
||||
namespace mobilinkd { namespace tnc {
|
||||
|
||||
|
||||
uint32_t serialTaskBuffer[ 128 ] __attribute__((section(".bss3")));
|
||||
osStaticThreadDef_t serialTaskControlBlock __attribute__((section(".bss3")));
|
||||
|
||||
uint8_t serialQueueBuffer[ 32 * sizeof( void* ) ] __attribute__((section(".bss3")));
|
||||
osStaticMessageQDef_t serialQueueControlBlock __attribute__((section(".bss3")));
|
||||
|
||||
osMutexDef(serialMutex);
|
||||
|
||||
void SerialPort::init()
|
||||
{
|
||||
if (serialTaskHandle_) return;
|
||||
|
||||
osMessageQStaticDef(serialQueue, 32, void*, serialQueueBuffer,
|
||||
&serialQueueControlBlock);
|
||||
queue_ = osMessageCreate(osMessageQ(serialQueue), 0);
|
||||
osMessageQDef(uartQueue, 32, void*);
|
||||
queue_ = osMessageCreate(osMessageQ(uartQueue), 0);
|
||||
|
||||
mutex_ = osMutexCreate(osMutex(serialMutex));
|
||||
osMutexDef(uartMutex);
|
||||
mutex_ = osMutexCreate(osMutex(uartMutex));
|
||||
|
||||
osThreadStaticDef(serialTask, startSerialTask, osPriorityAboveNormal, 0,
|
||||
128, serialTaskBuffer, &serialTaskControlBlock);
|
||||
osThreadDef(serialTask, startSerialTask, osPriorityAboveNormal, 0, 128);
|
||||
serialTaskHandle_ = osThreadCreate(osThread(serialTask), this);
|
||||
#ifndef NUCLEOTNC
|
||||
DEBUG("serialTaskHandle_ = %p", serialTaskHandle_);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SerialPort::open()
|
||||
|
|
Ładowanie…
Reference in New Issue