pull/11/head
guido 2020-08-10 16:42:46 +02:00
rodzic 7550788fea
commit 22b3f595c7
1 zmienionych plików z 46 dodań i 72 usunięć

Wyświetl plik

@ -2966,49 +2966,11 @@ void initPins(){
#ifdef CAT
// CAT support from Charlie Morris, ZL2CTM, source: http://zl2ctm.blogspot.com/2020/06/digital-modes-transceiver.html?m=1
// https://www.kenwood.com/i/products/info/amateur/ts_480/pdf/ts_480_pc.pdf
const int CatnumChars = 32;
boolean newCATcmd = false;
char CATcmd[CatnumChars] = {'0'}; // an array to store the received CAT data
int CATMODE = 2;
void rxCATcmd()
{
static int index = 0;
char endMarker = ';';
char data; // CAT commands are ASCII characters
while ((Serial.available() > 0) && (newCATcmd == false))
{
data = (char)Serial.read();
if (data == endMarker)
{
CATcmd[index] = ';'; // Indicate end of command
CATcmd[index + 1] = '\0'; // terminate the array
index = 0; // reset for next CAT command
newCATcmd = true;
}
else
{
CATcmd[index] = data;
index++;
if (index >= CatnumChars)
{
index = CatnumChars - 1; // leave space for the \0 array termination
index=0;
newCATcmd =true;
}
}
}
}
#define CATCMD_SIZE 32
char CATcmd[CATCMD_SIZE];
void analyseCATcmd()
{
if (newCATcmd == true)
{
newCATcmd = false; // reset for next CAT time
if ((CATcmd[0] == 'F') && (CATcmd[1] == 'A') && (CATcmd[2] == ';'))
Command_GETFreqA();
@ -3057,6 +3019,19 @@ void analyseCATcmd()
else if ((CATcmd[0] == 'V') && (CATcmd[1] == 'X') && (CATcmd[2] != ';'))
Command_Vox(CATcmd[2]);
}
static int catidx = 0;
void rxCATcmd(){
if(Serial.available()){
char data = Serial.read();
CATcmd[catidx++] = data;
if((data == ';') || (catidx == (CATCMD_SIZE - 2))){
CATcmd[catidx] = '\0'; // terminate the array
catidx = 0; // reset for next CAT command
analyseCATcmd();
//break;
}
}
}
void Command_GETFreqA()
@ -3490,7 +3465,6 @@ void loop()
{
#ifdef CAT
rxCATcmd();
analyseCATcmd();
#endif
#ifndef SIMPLE_RX