kopia lustrzana https://github.com/sq8vps/vp-digi
KISS handling improvements
rodzic
a11eca1c28
commit
c0d90a3793
|
@ -23,7 +23,8 @@ along with VP-Digi. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
#define AX25_FRAME_MAX_SIZE (308) //single frame max length for RX
|
||||
//308 bytes is the theoretical max size assuming 2-byte Control, 256-byte info field and 5 digi address fields
|
||||
|
||||
|
||||
enum Ax25RxStage
|
||||
|
@ -43,12 +44,6 @@ struct Ax25ProtoConfig
|
|||
|
||||
extern struct Ax25ProtoConfig Ax25Config;
|
||||
|
||||
/**
|
||||
* @brief Transmit one or more frames encoded in KISS format
|
||||
* @param *buf Inout buffer
|
||||
* @param len Buffer size
|
||||
*/
|
||||
void Ax25TxKiss(uint8_t *buf, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief Write frame to transmit buffer
|
||||
|
|
|
@ -25,7 +25,7 @@ along with VP-Digi. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "usbd_cdc_if.h"
|
||||
#include "ax25.h"
|
||||
|
||||
#define UART_BUFFER_SIZE 250
|
||||
#define UART_BUFFER_SIZE 130
|
||||
|
||||
enum UartMode
|
||||
{
|
||||
|
@ -37,7 +37,6 @@ enum UartMode
|
|||
enum UartDataType
|
||||
{
|
||||
DATA_NOTHING = 0,
|
||||
DATA_KISS,
|
||||
DATA_TERM,
|
||||
DATA_USB,
|
||||
};
|
||||
|
@ -55,20 +54,14 @@ typedef struct
|
|||
uint16_t txBufferHead, txBufferTail;
|
||||
uint8_t txBufferFull : 1;
|
||||
enum UartMode mode;
|
||||
uint32_t kissTimer;
|
||||
uint16_t lastRxBufferHead; //for special characters handling
|
||||
uint8_t kissBuffer[AX25_FRAME_MAX_SIZE + 1];
|
||||
uint16_t kissBufferHead;
|
||||
} Uart;
|
||||
|
||||
extern Uart Uart1, Uart2, UartUsb;
|
||||
|
||||
|
||||
///**
|
||||
// * \brief Copy KISS frame(s) from input buffer to APRS TX buffer
|
||||
// * \param[in] *buf Input buffer
|
||||
// * \param[in] len Input buffer size
|
||||
// */
|
||||
//uint8_t Uart_txKiss(uint8_t *buf, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief Send byte
|
||||
* @param[in] *port UART
|
||||
|
@ -113,11 +106,4 @@ void UartConfig(Uart *port, uint8_t state);
|
|||
*/
|
||||
void UartClearRx(Uart *port);
|
||||
|
||||
/**
|
||||
* @brief Handle KISS timeout
|
||||
* @param *port UART pointer
|
||||
* @attention This function must be polled constantly in main loop for USB UART.
|
||||
*/
|
||||
void UartHandleKissTimeout(Uart *port);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
Copyright 2020-2023 Piotr Wilkon
|
||||
|
||||
This file is part of VP-Digi.
|
||||
|
||||
VP-Digi is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
VP-Digi is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with VP-Digi. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef KISS_H_
|
||||
#define KISS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "drivers/uart.h"
|
||||
|
||||
/**
|
||||
* @brief Convert AX.25 frame to KISS and send
|
||||
* @param *port UART structure
|
||||
* @param *buf Frame buffer
|
||||
* @param size Frame size
|
||||
*/
|
||||
void KissSend(Uart *port, uint8_t *buf, uint16_t size);
|
||||
|
||||
/**
|
||||
* @brief Parse bytes received from UART to form a KISS frame (possibly) and send this frame
|
||||
* @param *port UART structure
|
||||
* @param data Received byte
|
||||
*/
|
||||
void KissParse(Uart *port, uint8_t data);
|
||||
|
||||
#endif /* KISS_H_ */
|
70
Src/ax25.c
70
Src/ax25.c
|
@ -27,11 +27,9 @@ along with VP-Digi. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
struct Ax25ProtoConfig Ax25Config;
|
||||
|
||||
//values below must be kept consistent so that FRAME_BUFFER_SIZE >= FRAME_MAX_SIZE * FRAME_MAX_COUNT
|
||||
#define FRAME_MAX_SIZE (308) //single frame max length for RX
|
||||
//308 bytes is the theoretical max size assuming 2-byte Control, 256-byte info field and 5 digi address fields
|
||||
|
||||
#define FRAME_MAX_COUNT (10) //max count of frames in buffer
|
||||
#define FRAME_BUFFER_SIZE (FRAME_MAX_COUNT * FRAME_MAX_SIZE) //circular frame buffer length
|
||||
#define FRAME_BUFFER_SIZE (FRAME_MAX_COUNT * AX25_FRAME_MAX_SIZE) //circular frame buffer length
|
||||
|
||||
#define STATIC_HEADER_FLAG_COUNT 4 //number of flags sent before each frame
|
||||
#define STATIC_FOOTER_FLAG_COUNT 8 //number of flags sent after each frame
|
||||
|
@ -98,7 +96,7 @@ static enum TxStage txStage; //current TX stage
|
|||
struct RxState
|
||||
{
|
||||
uint16_t crc; //current CRC
|
||||
uint8_t frame[FRAME_MAX_SIZE]; //raw frame buffer
|
||||
uint8_t frame[AX25_FRAME_MAX_SIZE]; //raw frame buffer
|
||||
uint16_t frameIdx; //index for raw frame buffer
|
||||
uint8_t receivedByte; //byte being currently received
|
||||
uint8_t receivedBitIdx; //bit index for recByte
|
||||
|
@ -115,7 +113,7 @@ static uint16_t rxMultiplexDelay = 0; //simple delay for decoder multiplexer to
|
|||
static uint16_t txDelay; //number of TXDelay bytes to send
|
||||
static uint16_t txTail; //number of TXTail bytes to send
|
||||
|
||||
static uint8_t outputFrameBuffer[FRAME_MAX_SIZE];
|
||||
static uint8_t outputFrameBuffer[AX25_FRAME_MAX_SIZE];
|
||||
|
||||
#define GET_FREE_SIZE(max, head, tail) (((head) < (tail)) ? ((tail) - (head)) : ((max) - (head) + (tail)))
|
||||
#define GET_USED_SIZE(max, head, tail) (max - GET_FREE_SIZE(max, head, tail))
|
||||
|
@ -146,62 +144,6 @@ void Ax25ClearReceivedFrameBitmap(void)
|
|||
frameReceived = 0;
|
||||
}
|
||||
|
||||
void Ax25TxKiss(uint8_t *buf, uint16_t len)
|
||||
{
|
||||
if(len < 18) //frame is too small
|
||||
{
|
||||
return;
|
||||
}
|
||||
for(uint16_t i = 0; i < len; i++)
|
||||
{
|
||||
if((buf[i] == 0xC0) && ((buf[i + 1] & 0xF) == 0)) //frame start marker and type is data frame
|
||||
{
|
||||
i += 2; //skip 0xC0 and type
|
||||
uint16_t end = i;
|
||||
while(end < len)
|
||||
{
|
||||
if(buf[end] == 0xC0)
|
||||
break;
|
||||
end++;
|
||||
}
|
||||
if(end == len) //no frame end marker found
|
||||
return;
|
||||
|
||||
uint16_t modifiedEnd = end;
|
||||
|
||||
for(uint16_t j = i; j < modifiedEnd; j++)
|
||||
{
|
||||
if(buf[j] == 0xDB) //escape character
|
||||
{
|
||||
if(buf[j + 1] == 0xDC) //transposed frame end
|
||||
{
|
||||
buf[j] = 0xC0;
|
||||
}
|
||||
else if(buf[j + 1] == 0xDD) //transposed frame escape
|
||||
{
|
||||
buf[j] = 0xDB;
|
||||
}
|
||||
else
|
||||
{
|
||||
j++;
|
||||
continue;
|
||||
}
|
||||
|
||||
j++;
|
||||
modifiedEnd--;
|
||||
for(uint16_t k = j; k < modifiedEnd; k++)
|
||||
{
|
||||
buf[k] = buf[k + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ax25WriteTxFrame(&buf[i], modifiedEnd - i); //skip modem number and send frame
|
||||
DigiStoreDeDupe(&buf[i], modifiedEnd - i);
|
||||
i = end; //move pointer to the next byte if there are more consecutive frames
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void *Ax25WriteTxFrame(uint8_t *data, uint16_t size)
|
||||
{
|
||||
|
@ -340,7 +282,7 @@ void Ax25BitParse(uint8_t bit, uint8_t modem)
|
|||
}
|
||||
|
||||
|
||||
if((rx->rawData & 0x7F) == 0x7F) //received 7 consecutive ones, this is an error (sometimes called "escape byte")
|
||||
if((rx->rawData & 0x7F) == 0x7F) //received 7 consecutive ones, this is an error
|
||||
{
|
||||
rx->rx = RX_STAGE_FLAG;
|
||||
ModemClearRMS(modem);
|
||||
|
@ -365,7 +307,7 @@ void Ax25BitParse(uint8_t bit, uint8_t modem)
|
|||
|
||||
if(++rx->receivedBitIdx >= 8) //received full byte
|
||||
{
|
||||
if(rx->frameIdx > FRAME_MAX_SIZE) //frame is too long
|
||||
if(rx->frameIdx > AX25_FRAME_MAX_SIZE) //frame is too long
|
||||
{
|
||||
rx->rx = RX_STAGE_IDLE;
|
||||
ModemClearRMS(modem);
|
||||
|
|
|
@ -52,8 +52,7 @@ static struct DeDupeData deDupe[DEDUPE_SIZE]; //duplicate protection hash buffer
|
|||
static uint8_t deDupeCount = 0; //duplicate protection buffer index
|
||||
|
||||
|
||||
#define DIGI_BUFFER_SIZE 308 //308 is the theoretical max under some assumptions, see ax25.c
|
||||
static uint8_t buf[DIGI_BUFFER_SIZE];
|
||||
static uint8_t buf[AX25_FRAME_MAX_SIZE];
|
||||
|
||||
/**
|
||||
* @brief Check if frame with specified hash is already in viscous-delay buffer and delete it if so
|
||||
|
|
|
@ -24,6 +24,7 @@ along with VP-Digi. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "common.h"
|
||||
#include <string.h>
|
||||
#include "digipeater.h"
|
||||
#include "kiss.h"
|
||||
|
||||
Uart Uart1, Uart2, UartUsb;
|
||||
|
||||
|
@ -32,28 +33,21 @@ static void handleInterrupt(Uart *port)
|
|||
if(port->port->SR & USART_SR_RXNE) //byte received
|
||||
{
|
||||
port->port->SR &= ~USART_SR_RXNE;
|
||||
port->rxBuffer[port->rxBufferHead++] = port->port->DR; //store it
|
||||
uint8_t data = port->port->DR;
|
||||
port->rxBuffer[port->rxBufferHead++] = data; //store it
|
||||
port->rxBufferHead %= UART_BUFFER_SIZE;
|
||||
|
||||
KissParse(port, data);
|
||||
TermHandleSpecial(port);
|
||||
|
||||
if(port->mode == MODE_KISS)
|
||||
port->kissTimer = SysTickGet() + (5000 / SYSTICK_INTERVAL); //set timeout to 5s in KISS mode
|
||||
}
|
||||
if(port->port->SR & USART_SR_IDLE) //line is idle, end of data reception
|
||||
{
|
||||
port->port->DR; //reset idle flag by dummy read
|
||||
if(port->rxBufferHead != 0)
|
||||
{
|
||||
if((port->rxBuffer[0] == 0xC0) && (port->rxBuffer[port->rxBufferHead - 1] == 0xC0)) //data starts with 0xc0 and ends with 0xc0 - this is a KISS frame
|
||||
{
|
||||
port->rxType = DATA_KISS;
|
||||
port->kissTimer = 0;
|
||||
}
|
||||
else if(((port->rxBuffer[port->rxBufferHead - 1] == '\r') || (port->rxBuffer[port->rxBufferHead - 1] == '\n'))) //data ends with \r or \n, process as data
|
||||
if(((port->rxBuffer[port->rxBufferHead - 1] == '\r') || (port->rxBuffer[port->rxBufferHead - 1] == '\n'))) //data ends with \r or \n, process as data
|
||||
{
|
||||
port->rxType = DATA_TERM;
|
||||
port->kissTimer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +55,7 @@ static void handleInterrupt(Uart *port)
|
|||
{
|
||||
if((port->txBufferHead != port->txBufferTail) || port->txBufferFull) //if there is anything to transmit
|
||||
{
|
||||
port->port->DR = port->txBuffer[port->txBufferTail++]; //push it to the refister
|
||||
port->port->DR = port->txBuffer[port->txBufferTail++]; //push it to the register
|
||||
port->txBufferTail %= UART_BUFFER_SIZE;
|
||||
port->txBufferFull = 0;
|
||||
}
|
||||
|
@ -70,13 +64,6 @@ static void handleInterrupt(Uart *port)
|
|||
port->port->CR1 &= ~USART_CR1_TXEIE;
|
||||
}
|
||||
}
|
||||
|
||||
if((port->kissTimer > 0) && (SysTickGet() >= port->kissTimer)) //KISS timer timeout
|
||||
{
|
||||
port->kissTimer = 0;
|
||||
port->rxBufferHead = 0;
|
||||
memset(port->rxBuffer, 0, sizeof(port->rxBuffer));
|
||||
}
|
||||
}
|
||||
|
||||
void USART1_IRQHandler(void) __attribute__ ((interrupt));
|
||||
|
@ -160,12 +147,13 @@ void UartInit(Uart *port, USART_TypeDef *uart, uint32_t baud)
|
|||
port->txBufferHead = 0;
|
||||
port->txBufferTail = 0;
|
||||
port->txBufferFull = 0;
|
||||
port->kissBufferHead = 0;
|
||||
port->mode = MODE_KISS;
|
||||
port->enabled = 0;
|
||||
port->kissTimer = 0;
|
||||
port->lastRxBufferHead = 0;
|
||||
memset(port->rxBuffer, 0, sizeof(port->rxBuffer));
|
||||
memset(port->txBuffer, 0, sizeof(port->txBuffer));
|
||||
memset(port->kissBuffer, 0, sizeof(port->kissBuffer));
|
||||
}
|
||||
|
||||
|
||||
|
@ -236,13 +224,3 @@ void UartClearRx(Uart *port)
|
|||
port->rxBufferHead = 0;
|
||||
port->rxType = DATA_NOTHING;
|
||||
}
|
||||
|
||||
void UartHandleKissTimeout(Uart *port)
|
||||
{
|
||||
if((port->kissTimer > 0) && (SysTickGet() >= port->kissTimer)) //KISS timer timeout
|
||||
{
|
||||
port->kissTimer = 0;
|
||||
port->rxBufferHead = 0;
|
||||
memset(port->rxBuffer, 0, sizeof(port->rxBuffer));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
Copyright 2020-2023 Piotr Wilkon
|
||||
|
||||
This file is part of VP-Digi.
|
||||
|
||||
VP-Digi is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
VP-Digi is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with VP-Digi. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "kiss.h"
|
||||
#include "ax25.h"
|
||||
#include "digipeater.h"
|
||||
|
||||
void KissSend(Uart *port, uint8_t *buf, uint16_t size)
|
||||
{
|
||||
if(port->mode == MODE_KISS)
|
||||
{
|
||||
UartSendByte(port, 0xC0);
|
||||
UartSendByte(port, 0x00);
|
||||
for(uint16_t i = 0; i < size; i++)
|
||||
{
|
||||
if(buf[i] == 0xC0) //frame end in data
|
||||
{
|
||||
UartSendByte(port, 0xDB); //frame escape
|
||||
UartSendByte(port, 0xDC); //transposed frame end
|
||||
}
|
||||
else if(buf[i] == 0xDB) //frame escape in data
|
||||
{
|
||||
UartSendByte(port, 0xDB); //frame escape
|
||||
UartSendByte(port, 0xDD); //transposed frame escape
|
||||
}
|
||||
else
|
||||
UartSendByte(port, buf[i]);
|
||||
}
|
||||
UartSendByte(port, 0xC0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KissParse(Uart *port, uint8_t data)
|
||||
{
|
||||
if(data == 0xC0) //frame end marker
|
||||
{
|
||||
if(port->kissBufferHead < 17) //command+source+destination+PID+Control=17
|
||||
{
|
||||
port->kissBufferHead = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if((port->kissBuffer[0] & 0xF) != 0) //check if this is an actual frame
|
||||
{
|
||||
port->kissBufferHead = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
//simple sanity check
|
||||
//check if LSbits in the first 13 bytes are set to 0
|
||||
//they should always be in an AX.25 frame
|
||||
for(uint8_t i = 0; i < 13; i++)
|
||||
{
|
||||
if((port->kissBuffer[i + 1] & 1) != 0)
|
||||
{
|
||||
port->kissBufferHead = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Ax25WriteTxFrame(&port->kissBuffer[1], port->kissBufferHead - 1);
|
||||
DigiStoreDeDupe(&port->kissBuffer[1], port->kissBufferHead - 1);
|
||||
port->kissBufferHead = 0;
|
||||
return;
|
||||
}
|
||||
else if(port->kissBufferHead > 0)
|
||||
{
|
||||
if((data == 0xDC) && (port->kissBuffer[port->kissBufferHead - 1] == 0xDB)) //escape character with transposed frame end
|
||||
{
|
||||
port->kissBuffer[port->kissBufferHead - 1] = 0xC0;
|
||||
return;
|
||||
}
|
||||
else if((data == 0xDD) && (port->kissBuffer[port->kissBufferHead - 1] == 0xDB)) //escape character with transposed escape character
|
||||
{
|
||||
port->kissBuffer[port->kissBufferHead - 1] = 0xDB;
|
||||
return;
|
||||
}
|
||||
}
|
||||
port->kissBuffer[port->kissBufferHead++] = data;
|
||||
port->kissBufferHead %= sizeof(port->kissBuffer);
|
||||
}
|
|
@ -290,7 +290,6 @@ int main(void)
|
|||
TermParse(&Uart2);
|
||||
UartClearRx(&Uart2);
|
||||
}
|
||||
UartHandleKissTimeout(&UartUsb);
|
||||
|
||||
BeaconCheck(); //check beacons
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ along with VP-Digi. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "drivers/modem.h"
|
||||
#include "ax25.h"
|
||||
#include "drivers/systick.h"
|
||||
#include "kiss.h"
|
||||
|
||||
void TermHandleSpecial(Uart *u)
|
||||
{
|
||||
|
@ -60,38 +61,13 @@ void TermHandleSpecial(Uart *u)
|
|||
}
|
||||
|
||||
|
||||
static void sendKiss(Uart *port, uint8_t *buf, uint16_t len)
|
||||
{
|
||||
if(port->mode == MODE_KISS)
|
||||
{
|
||||
UartSendByte(port, 0xC0);
|
||||
UartSendByte(port, 0x00);
|
||||
for(uint16_t i = 0; i < len; i++)
|
||||
{
|
||||
if(buf[i] == 0xC0) //frame end in data
|
||||
{
|
||||
UartSendByte(port, 0xDB); //frame escape
|
||||
UartSendByte(port, 0xDC); //transposed frame end
|
||||
}
|
||||
else if(buf[i] == 0xDB) //frame escape in data
|
||||
{
|
||||
UartSendByte(port, 0xDB); //frame escape
|
||||
UartSendByte(port, 0xDD); //transposed frame escape
|
||||
}
|
||||
else
|
||||
UartSendByte(port, buf[i]);
|
||||
}
|
||||
UartSendByte(port, 0xC0);
|
||||
}
|
||||
}
|
||||
|
||||
void TermSendToAll(enum UartMode mode, uint8_t *data, uint16_t size)
|
||||
{
|
||||
if(MODE_KISS == mode)
|
||||
{
|
||||
sendKiss(&Uart1, data, size);
|
||||
sendKiss(&Uart2, data, size);
|
||||
sendKiss(&UartUsb, data, size);
|
||||
KissSend(&Uart1, data, size);
|
||||
KissSend(&Uart2, data, size);
|
||||
KissSend(&UartUsb, data, size);
|
||||
}
|
||||
else if(MODE_MONITOR == mode)
|
||||
{
|
||||
|
@ -119,9 +95,6 @@ void TermSendNumberToAll(enum UartMode mode, int32_t n)
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static const char monitorHelp[] = "\r\nCommans available in monitor mode:\r\n"
|
||||
"help - shows this help page\r\n"
|
||||
"cal {low|high|alt|stop} - transmits/stops transmitter calibration pattern\r\n"
|
||||
|
@ -391,14 +364,6 @@ void TermParse(Uart *src)
|
|||
src->mode = MODE_MONITOR;
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* KISS parsing
|
||||
*/
|
||||
else if((src->mode == MODE_KISS) && (src->rxType == DATA_KISS))
|
||||
{
|
||||
Ax25TxKiss(src->rxBuffer, src->rxBufferHead);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* Monitor mode handling
|
||||
*/
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "drivers/uart.h"
|
||||
#include "drivers/systick.h"
|
||||
#include "terminal.h"
|
||||
#include "kiss.h"
|
||||
/* USER CODE END INCLUDE */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
|
@ -274,6 +275,7 @@ static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len)
|
|||
for(uint16_t i = 0; i < *Len; i++)
|
||||
{
|
||||
UartUsb.rxBuffer[UartUsb.rxBufferHead++] = Buf[i];
|
||||
KissParse(&UartUsb, Buf[i]);
|
||||
UartUsb.rxBufferHead %= UART_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
|
@ -322,20 +324,11 @@ uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len)
|
|||
/* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */
|
||||
static void handleUsbInterrupt(Uart *port)
|
||||
{
|
||||
if(port->mode == MODE_KISS)
|
||||
port->kissTimer = SysTickGet() + (5000 / SYSTICK_INTERVAL); //set timeout to 5s in KISS mode
|
||||
|
||||
if(port->rxBufferHead != 0)
|
||||
{
|
||||
if((port->rxBuffer[0] == 0xC0) && (port->rxBuffer[port->rxBufferHead - 1] == 0xC0)) //data starts with 0xc0 and ends with 0xc0 - this is a KISS frame
|
||||
{
|
||||
port->rxType = DATA_KISS;
|
||||
port->kissTimer = 0;
|
||||
}
|
||||
else if(((port->rxBuffer[port->rxBufferHead - 1] == '\r') || (port->rxBuffer[port->rxBufferHead - 1] == '\n'))) //data ends with \r or \n, process as data
|
||||
if(((port->rxBuffer[port->rxBufferHead - 1] == '\r') || (port->rxBuffer[port->rxBufferHead - 1] == '\n'))) //data ends with \r or \n, process as data
|
||||
{
|
||||
port->rxType = DATA_TERM;
|
||||
port->kissTimer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue