new experimental KISS handling

pull/32/head
Piotr Wilkon 2023-09-12 11:16:22 +02:00
rodzic dfb13fa356
commit 040ce42764
5 zmienionych plików z 52 dodań i 19 usunięć

Wyświetl plik

@ -38,4 +38,6 @@ void KissSend(Uart *port, uint8_t *buf, uint16_t size);
*/
void KissParse(Uart *port, uint8_t data);
void KissProcess(Uart *port);
#endif /* KISS_H_ */

Wyświetl plik

@ -37,6 +37,7 @@ enum UartDataType
{
DATA_NOTHING = 0,
DATA_TERM,
DATA_KISS,
DATA_USB,
};

Wyświetl plik

@ -96,19 +96,9 @@ void KissParse(Uart *port, uint8_t data)
__disable_irq();
port->kissProcessingOngoing = 1;
port->kissTempBufferHead = 0;
__enable_irq();
Ax25WriteTxFrame((uint8_t*)&port->kissBuffer[1], port->kissBufferHead - 1);
DigiStoreDeDupe((uint8_t*)&port->kissBuffer[1], port->kissBufferHead - 1);
port->kissBufferHead = 0;
__disable_irq();
port->kissProcessingOngoing = 0;
if(port->kissTempBufferHead > 0)
{
memcpy((uint8_t*)port->kissBuffer, (uint8_t*)port->kissTempBuffer, port->kissTempBufferHead);
port->kissBufferHead = port->kissTempBufferHead;
port->kissTempBufferHead = 0;
}
__enable_irq();
port->rxType = DATA_KISS;
return;
}
else if(*index > 0)
@ -131,3 +121,23 @@ void KissParse(Uart *port, uint8_t data)
else
port->kissTempBufferHead %= sizeof(port->kissTempBuffer);
}
void KissProcess(Uart *port)
{
if(port->rxType == DATA_KISS)
{
Ax25WriteTxFrame((uint8_t*)&port->kissBuffer[1], port->kissBufferHead - 1);
DigiStoreDeDupe((uint8_t*)&port->kissBuffer[1], port->kissBufferHead - 1);
port->kissBufferHead = 0;
__disable_irq();
port->kissProcessingOngoing = 0;
if(port->kissTempBufferHead > 0)
{
memcpy((uint8_t*)port->kissBuffer, (uint8_t*)port->kissTempBuffer, port->kissTempBufferHead);
port->kissBufferHead = port->kissTempBufferHead;
port->kissTempBufferHead = 0;
}
__enable_irq();
port->rxType = DATA_NOTHING;
}
}

Wyświetl plik

@ -51,6 +51,7 @@ along with VP-Digi. If not, see <http://www.gnu.org/licenses/>.
#include "config.h"
#include "uart.h"
#include "drivers/usb.h"
#include "kiss.h"
#ifdef ENABLE_FX25
#include "fx25.h"
#endif
@ -260,8 +261,13 @@ int main(void)
if(UartUsb.rxType != DATA_NOTHING)
{
TermHandleSpecial(&UartUsb);
if(UartUsb.rxType != DATA_USB)
if(UartUsb.rxType == DATA_KISS)
{
KissProcess(&UartUsb);
}
else if(UartUsb.rxType != DATA_USB)
{
TermParse(&UartUsb);
UartClearRx(&UartUsb);
}
@ -269,13 +275,27 @@ int main(void)
}
if(Uart1.rxType != DATA_NOTHING)
{
TermParse(&Uart1);
UartClearRx(&Uart1);
if(Uart1.rxType == DATA_KISS)
{
KissProcess(&Uart1);
}
else
{
TermParse(&Uart1);
UartClearRx(&Uart1);
}
}
if(Uart2.rxType != DATA_NOTHING)
{
TermParse(&Uart2);
UartClearRx(&Uart2);
if(Uart2.rxType == DATA_KISS)
{
KissProcess(&Uart2);
}
else
{
TermParse(&Uart2);
UartClearRx(&Uart2);
}
}
BeaconCheck(); //check beacons

Wyświetl plik

@ -269,8 +269,8 @@ static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len)
KissParse(&UartUsb, Buf[i]);
UartUsb.rxBufferHead %= UART_BUFFER_SIZE;
}
UartUsb.rxType = DATA_USB;
if(UartUsb.rxType != DATA_KISS)
UartUsb.rxType = DATA_USB;
handleUsbInterrupt(&UartUsb);
return (USBD_OK);