Revert "Adding Jonathan’s ring buffer to serial repeater"

This reverts commit 6486bf4efc.
pull/13/head
Andy CA6JAU 9 years ago
parent 6486bf4efc
commit 22f510d167

@ -112,25 +112,5 @@ void CSerialPort::writeInt(uint8_t n, const uint8_t* data, uint16_t length, bool
}
}
int CSerialPort::availableForWriteInt(uint8_t n)
{
switch (n) {
case 1U:
#if defined(STM32_USART1_HOST) && defined(__STM32F1__)
return Serial1.availableForWrite();
#else
return Serial.availableForWrite();
#endif
case 3U:
#if defined(SERIAL_REPEATER) && defined(__STM32F1__)
return Serial2.availableForWrite();
#elif defined(SERIAL_REPEATER) && (defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__))
return Serial1.availableForWrite();
#endif
default:
return false;
}
}
#endif

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013,2015,2016,2017 by Jonathan Naylor G4KLX
* Copyright (C) 2013,2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2016 by Colin Durbridge G4EML
* Copyright (C) 2016, 2017 by Andy Uribe CA6JAU
*
@ -90,8 +90,7 @@ CSerialPort::CSerialPort() :
m_buffer(),
m_ptr(0U),
m_len(0U),
m_debug(false),
m_repeat()
m_debug(false)
{
}
@ -537,11 +536,12 @@ void CSerialPort::process()
}
break;
#if defined(SERIAL_REPEATER)
case MMDVM_SERIAL:
for (uint8_t i = 3U; i < m_len; i++)
m_repeat.put(m_buffer[i]);
writeInt(3U, m_buffer + 3U, m_len - 3U);
break;
#endif
default:
// Handle this, send a NAK back
sendNAK(1U);
@ -555,20 +555,7 @@ void CSerialPort::process()
}
#if defined(SERIAL_REPEATER)
// Write any outgoing serial data
uint16_t space = m_repeat.getData();
if (space > 0U) {
int avail = availableForWriteInt(3U);
if (avail < space)
space = avail;
for (uint16_t i = 0U; i < space; i++) {
uint8_t c = m_repeat.get();
writeInt(3U, &c, 1U);
}
}
// Read any incoming serial data
// Drain any incoming serial data
while (availableInt(3U))
readInt(3U);
#endif

@ -20,7 +20,6 @@
#define SERIALPORT_H
#include "Globals.h"
#include "SerialRB.h"
class CSerialPort {
public:
@ -56,7 +55,6 @@ private:
uint8_t m_ptr;
uint8_t m_len;
bool m_debug;
CSerialRB m_repeat;
void sendACK();
void sendNAK(uint8_t err);
@ -70,7 +68,6 @@ private:
// Hardware versions
void beginInt(uint8_t n, int speed);
int availableInt(uint8_t n);
int availableForWriteInt(uint8_t n);
uint8_t readInt(uint8_t n);
void writeInt(uint8_t n, const uint8_t* data, uint16_t length, bool flush = false);
};

@ -41,8 +41,8 @@ USART2 - TXD PA2 - RXD PA3
*/
#define TX_SERIAL_FIFO_SIZE 256U
#define RX_SERIAL_FIFO_SIZE 256U
#define TX_SERIAL_FIFO_SIZE 512U
#define RX_SERIAL_FIFO_SIZE 512U
#if defined(STM32_USART1_HOST)
@ -208,7 +208,7 @@ void InitUSART1(int speed)
RXSerialfifoinit1();
}
uint8_t AvailUSART1()
uint8_t AvailUSART1(void)
{
if (RXSerialfifolevel1() > 0U)
return 1U;
@ -216,12 +216,7 @@ uint8_t AvailUSART1()
return 0U;
}
int AvailForWriteUSART1()
{
return TX_SERIAL_FIFO_SIZE - TXSerialfifolevel1();
}
uint8_t ReadUSART1()
uint8_t ReadUSART1(void)
{
uint8_t data_c = RXSerialfifo1[RXSerialfifotail1];
@ -408,7 +403,7 @@ void InitUSART2(int speed)
RXSerialfifoinit2();
}
uint8_t AvailUSART2()
uint8_t AvailUSART2(void)
{
if (RXSerialfifolevel2() > 0U)
return 1U;
@ -416,12 +411,7 @@ uint8_t AvailUSART2()
return 0U;
}
int AvailForWriteUSART2()
{
return TX_SERIAL_FIFO_SIZE - TXSerialfifolevel2();
}
uint8_t ReadUSART2()
uint8_t ReadUSART2(void)
{
uint8_t data_c = RXSerialfifo2[RXSerialfifotail2];
@ -478,23 +468,7 @@ int CSerialPort::availableInt(uint8_t n)
return AvailUSART2();
#endif
default:
return 0;
}
}
int CSerialPort::availableForWriteInt(uint8_t n)
{
switch (n) {
case 1U:
#if defined(STM32_USART1_HOST)
return AvailForWriteUSART1();
#endif
#if defined(SERIAL_REPEATER)
case 3U:
return AvailForWriteUSART2();
#endif
default:
return 0;
return false;
}
}

Loading…
Cancel
Save

Powered by TurnKey Linux.