Fix timing behavior and a potential null pointer derefernce in the serial port driver. Fix an off-by-one error that caused short packets to be discarded. Update version to 1.1.1.

fsk9600
Rob Riggs 2019-01-31 18:01:27 -06:00
rodzic 15e86e72ad
commit 0eb70c4746
3 zmienionych plików z 14 dodań i 6 usunięć

Wyświetl plik

@ -222,7 +222,7 @@ struct Decoder
}
if (have_flag()) {
if (frame_->size() > 17) {
if (frame_->size() > 15) {
ready_ = true;
}
}
@ -237,7 +237,7 @@ struct Decoder
// Framing error. Drop the frame. If there is a FLAG
// in the buffer, go into HUNT otherwise SEARCH.
if (frame_->size() > 17) {
if (frame_->size() > 15) {
ready_ = true;
return;
}
@ -296,7 +296,7 @@ IoFrame* Decoder::operator()(bool bit, bool pll)
if (nullptr == frame_) frame_ = acquire();
if (not pll) {
if ((state_ == FRAMING) and (frame_->size() > 17) and passall_) {
if ((state_ == FRAMING) and (frame_->size() > 15) and passall_) {
frame_->parse_fcs();
if (passall_ or frame_->ok()) {
result = frame_;

Wyświetl plik

@ -26,7 +26,7 @@ int powerOffViaUSB(void)
namespace mobilinkd { namespace tnc { namespace kiss {
const char FIRMWARE_VERSION[] = "1.1.0";
const char FIRMWARE_VERSION[] = "1.1.1";
const char HARDWARE_VERSION[] = "Mobilinkd TNC3 2.1.1";
Hardware& settings()

Wyświetl plik

@ -60,6 +60,9 @@ extern "C" void startSerialTask(void const* arg)
HAL_UART_Receive_IT(&huart3, &rxBuffer, 1);
uint32_t last_sent_time = osKernelSysTick();
uint32_t current_sent_time = 0;
while (true) {
osEvent evt = osMessageGet(serialPort->queue(), osWaitForever);
@ -78,6 +81,7 @@ extern "C" void startSerialTask(void const* arg)
}
uint8_t c = evt.value.v;
INFO("%02x - %c", c, c);
switch (state) {
case WAIT_FBEGIN:
if (c == FEND) state = WAIT_FRAME_TYPE;
@ -98,7 +102,11 @@ extern "C" void startSerialTask(void const* arg)
{
hdlc::release(frame);
}
osDelay(50);
current_sent_time = osKernelSysTick();
if (last_sent_time + 50 > current_sent_time) {
uint32_t delay = (last_sent_time + 50) - current_sent_time;
osDelay(delay);
}
frame = hdlc::acquire_wait();
state = WAIT_FBEGIN;
break;
@ -106,7 +114,7 @@ extern "C" void startSerialTask(void const* arg)
if (not frame->push_back(c)) {
hdlc::release(frame);
state = WAIT_FBEGIN; // Drop frame;
frame = hdlc::acquire();
frame = hdlc::acquire_wait();
}
}
break;