Raduino changes are getting to TeensyDSP over I2C. TeensyDSP successfully receiving some CAT.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <Arduino.h>
|
||||
#include "TS590.h"
|
||||
#include "Debug.h"
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
@@ -71,26 +72,26 @@ void TS590Command::process(const char* cmd) {
|
||||
theError = NoError;
|
||||
|
||||
if (isReadCommand(cmd)) {
|
||||
sendResponse(cmd);
|
||||
DBGCMD( sendResponse(cmd) );
|
||||
} else {
|
||||
handleCommand(cmd);
|
||||
DBGCMD( handleCommand(cmd) );
|
||||
switch(theError) {
|
||||
case NoError:
|
||||
if (theRig->getAI()) {
|
||||
sendResponse(cmd);
|
||||
DBGCMD( sendResponse(cmd) );
|
||||
}
|
||||
break;
|
||||
|
||||
case SyntaxError:
|
||||
ts590SyntaxError();
|
||||
DBGCMD( ts590SyntaxError() );
|
||||
break;
|
||||
|
||||
case CommError:
|
||||
ts590CommError();
|
||||
DBGCMD( ts590CommError() );
|
||||
break;
|
||||
|
||||
case ProcessError:
|
||||
ts590ProcessError();
|
||||
DBGCMD( ts590ProcessError() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -225,18 +226,36 @@ TS590Command* catCommands[] = {
|
||||
&cmdFR,
|
||||
&cmdFT
|
||||
};
|
||||
int numCatCommands = sizeof(catCommands) / sizeof(catCommands[0]);
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
void UBitxTS590::begin() {
|
||||
Serial.begin(9600); // USB is always 12 Mbit/sec
|
||||
#ifdef DEBUG
|
||||
delay(500);
|
||||
Serial.print("DBG: Number of CAT commands: ");
|
||||
Serial.println(numCommands);
|
||||
for (int i = 0; i < numCommands; i++) {
|
||||
Serial.print(" ");
|
||||
Serial.println(commands[i]->prefix());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void UBitxTS590::update() {
|
||||
char incomingChar;
|
||||
|
||||
while (Serial.available()) {
|
||||
if (bufLen < ts590CommandMaxLength) {
|
||||
incomingChar = Serial.read();
|
||||
incomingChar = Serial.read();
|
||||
if (incomingChar == ';') {
|
||||
buf[bufLen++] = '\0';
|
||||
strupr(buf);
|
||||
processCommand();
|
||||
} else if (incomingChar == '\n' && bufLen == 0) {
|
||||
;
|
||||
} else {
|
||||
buf[bufLen++] = incomingChar;
|
||||
}
|
||||
@@ -248,19 +267,32 @@ void UBitxTS590::update() {
|
||||
}
|
||||
}
|
||||
|
||||
typedef class TS590Command* PCmd;
|
||||
|
||||
int compareCATCommands(const void* a, const void* b) {
|
||||
return strcmp(((TS590Command*)a)->prefix(), ((TS590Command*)b)->prefix());
|
||||
TS590Command const *B = *(TS590Command const **)b;
|
||||
int cmp = strncmp((char*)a, (char*)B->prefix(), 2);
|
||||
#ifdef DEBUG
|
||||
Serial.print("Comparison: ");
|
||||
Serial.print((char*)a);
|
||||
Serial.print(" ? ");
|
||||
Serial.print((char*)B->prefix());
|
||||
Serial.print(" --> ");
|
||||
Serial.println(cmp);
|
||||
#endif
|
||||
return cmp;
|
||||
}
|
||||
|
||||
void UBitxTS590::processCommand() {
|
||||
TS590Command* cmd = (TS590Command*)bsearch((void*)buf, (void*)commands, sizeof(commands) / sizeof(commands[0]), sizeof(commands[0]), compareCATCommands);
|
||||
TS590Command** cmd = (TS590Command**)bsearch(buf, commands, numCommands, sizeof(TS590Command*), compareCATCommands);
|
||||
if (cmd == NULL) {
|
||||
ts590SyntaxError();
|
||||
} else {
|
||||
cmd->process(buf);
|
||||
(*cmd)->process(buf);
|
||||
}
|
||||
bufLen = 0;
|
||||
}
|
||||
|
||||
UBitxTS590 TS590(catCommands);
|
||||
UBitxTS590 TS590(catCommands, numCatCommands);
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user