mirror of
https://github.com/EnhancedRadioDevices/HamShield_KISS
synced 2023-10-28 07:05:50 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56161805a4 | ||
|
|
07fbb1af2f | ||
|
|
ba97bd4702 | ||
|
|
5fc9e7abbd | ||
|
|
0689f95f74 | ||
|
|
74d7724843 | ||
|
|
d365fee768 |
@@ -1,5 +1,5 @@
|
|||||||
name=HamShield_KISS
|
name=HamShield_KISS
|
||||||
version=1.0.2
|
version=1.0.5
|
||||||
author=Morgan Redfield <morgan@enhancedradio.com>, Casey Halverson <casey@enhancedradio.com>
|
author=Morgan Redfield <morgan@enhancedradio.com>, Casey Halverson <casey@enhancedradio.com>
|
||||||
maintainer=Morgan Redfield <morgan@enhancedradio.com>
|
maintainer=Morgan Redfield <morgan@enhancedradio.com>
|
||||||
sentence=A library for use with HamShield by Enhanced Radio Devices.
|
sentence=A library for use with HamShield by Enhanced Radio Devices.
|
||||||
|
|||||||
19
src/KISS.cpp
19
src/KISS.cpp
@@ -2,6 +2,7 @@
|
|||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
#include "KISS.h"
|
#include "KISS.h"
|
||||||
|
|
||||||
|
|
||||||
//AFSK::Packet kissPacket;
|
//AFSK::Packet kissPacket;
|
||||||
bool inFrame = false;
|
bool inFrame = false;
|
||||||
uint8_t kissBuffer[PACKET_MAX_LEN];
|
uint8_t kissBuffer[PACKET_MAX_LEN];
|
||||||
@@ -11,11 +12,11 @@ uint16_t kissLen = 0;
|
|||||||
// KISS equipment, and look if we have anything to relay along
|
// KISS equipment, and look if we have anything to relay along
|
||||||
void KISS::loop() {
|
void KISS::loop() {
|
||||||
static bool currentlySending = false;
|
static bool currentlySending = false;
|
||||||
if(afsk.decoder.read() || afsk.rxPacketCount()) {
|
if(afsk->decoder.read() || afsk->rxPacketCount()) {
|
||||||
// A true return means something was put onto the packet FIFO
|
// A true return means something was put onto the packet FIFO
|
||||||
// If we actually have data packets in the buffer, process them all now
|
// If we actually have data packets in the buffer, process them all now
|
||||||
while(afsk.rxPacketCount()) {
|
while(afsk->rxPacketCount()) {
|
||||||
AFSK::Packet *packet = afsk.getRXPacket();
|
AFSK::Packet *packet = afsk->getRXPacket();
|
||||||
if(packet) {
|
if(packet) {
|
||||||
writePacket(packet);
|
writePacket(packet);
|
||||||
AFSK::PacketBuffer::freePacket(packet);
|
AFSK::PacketBuffer::freePacket(packet);
|
||||||
@@ -23,7 +24,7 @@ void KISS::loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check if we have incoming data to turn into a packet
|
// Check if we have incoming data to turn into a packet
|
||||||
while(io->available()) {
|
while(currentlySending == false && io->available()) {
|
||||||
uint8_t c = (uint8_t)io->read();
|
uint8_t c = (uint8_t)io->read();
|
||||||
if(c == KISS_FEND) {
|
if(c == KISS_FEND) {
|
||||||
if(inFrame && kissLen > 0) {
|
if(inFrame && kissLen > 0) {
|
||||||
@@ -34,7 +35,7 @@ void KISS::loop() {
|
|||||||
packet->appendFCS(kissBuffer[i]);
|
packet->appendFCS(kissBuffer[i]);
|
||||||
}
|
}
|
||||||
packet->finish();
|
packet->finish();
|
||||||
afsk.encoder.putPacket(packet);
|
afsk->encoder.putPacket(packet);
|
||||||
}
|
}
|
||||||
kissLen = 0;
|
kissLen = 0;
|
||||||
inFrame = false;
|
inFrame = false;
|
||||||
@@ -57,15 +58,15 @@ void KISS::loop() {
|
|||||||
inFrame = true;
|
inFrame = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(afsk.txReady()) {
|
if(afsk->txReady()) {
|
||||||
radio->setModeTransmit();
|
radio->setModeTransmit();
|
||||||
currentlySending = true;
|
currentlySending = true;
|
||||||
if(!afsk.txStart()) { // Unable to start for some reason
|
if(!afsk->txStart()) { // Unable to start for some reason
|
||||||
radio->setModeReceive();
|
radio->setModeReceive();
|
||||||
currentlySending = false;
|
currentlySending = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(currentlySending && afsk.encoder.isDone()) {
|
if(currentlySending && afsk->encoder.isDone()) {
|
||||||
radio->setModeReceive();
|
radio->setModeReceive();
|
||||||
currentlySending = false;
|
currentlySending = false;
|
||||||
}
|
}
|
||||||
@@ -76,7 +77,7 @@ void KISS::writePacket(AFSK::Packet *p) {
|
|||||||
io->write(KISS_FEND);
|
io->write(KISS_FEND);
|
||||||
io->write((uint8_t)0); // Host to TNC port identifier
|
io->write((uint8_t)0); // Host to TNC port identifier
|
||||||
for(i = 0; i < p->len-2; i++) {
|
for(i = 0; i < p->len-2; i++) {
|
||||||
char c = p->getByte(i);
|
unsigned char c = p->getByte(i);
|
||||||
if(c == KISS_FEND || c == KISS_FESC) {
|
if(c == KISS_FEND || c == KISS_FESC) {
|
||||||
io->write(KISS_FESC);
|
io->write(KISS_FESC);
|
||||||
io->write((c==KISS_FEND?KISS_TFEND:KISS_TFESC));
|
io->write((c==KISS_FEND?KISS_TFEND:KISS_TFESC));
|
||||||
|
|||||||
15
src/KISS.h
15
src/KISS.h
@@ -11,26 +11,15 @@
|
|||||||
|
|
||||||
class KISS {
|
class KISS {
|
||||||
public:
|
public:
|
||||||
KISS(Stream *_io, HamShield *h, DDS *d) : io(_io), radio(h), dds(d) {}
|
KISS(Stream *_io, HamShield *h, DDS *d, AFSK *a) : io(_io), radio(h), dds(d), afsk(a) {}
|
||||||
bool read();
|
bool read();
|
||||||
AFSK afsk;
|
|
||||||
void writePacket(AFSK::Packet *);
|
void writePacket(AFSK::Packet *);
|
||||||
void loop();
|
void loop();
|
||||||
inline void isr() {
|
|
||||||
static uint8_t tcnt = 0;
|
|
||||||
TIFR1 = _BV(ICF1); // Clear the timer flag
|
|
||||||
dds->clockTick();
|
|
||||||
if(++tcnt == (DDS_REFCLK_DEFAULT/9600)) {
|
|
||||||
//PORTD |= _BV(2); // Diagnostic pin (D2)
|
|
||||||
afsk.timer();
|
|
||||||
tcnt = 0;
|
|
||||||
}
|
|
||||||
//PORTD &= ~(_BV(2));
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
Stream *io;
|
Stream *io;
|
||||||
HamShield *radio;
|
HamShield *radio;
|
||||||
DDS *dds;
|
DDS *dds;
|
||||||
|
AFSK *afsk;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _KISS_H_ */
|
#endif /* _KISS_H_ */
|
||||||
|
|||||||
Reference in New Issue
Block a user