Got basic 3-way comm (CAT-Teensy-Raduino) working. CAT commands are received via Serial by the Teensy. Data is passed on to the Raduino via I2C. Had to add an intermediate step in the protocol in order for the Raduino to request a byte as a flag for whether or not any changed data was coming, and then if so, request the changed data. There are certainly some optimizations that could be made on this number. Currently, the Raduino code is very clunky. In addition, the Rig and RigState classes have deteriorated somewhat.

This commit is contained in:
Rob French
2021-02-10 00:10:24 -06:00
parent aeeec69daf
commit c3cc9a7cf7
5 changed files with 69 additions and 19 deletions

View File

@@ -312,6 +312,7 @@ void doRaduinoToTeensy(UBitxRigState* r) {
Wire.write(ptr, sizeof(UBitxRigState));
Wire.endTransmission();
Serial.println("BEFORE:");
Serial.print("VFO A: ");
Serial.print(r->vfo[0]);
Serial.print(", VFO B: ");
@@ -319,18 +320,33 @@ void doRaduinoToTeensy(UBitxRigState* r) {
Serial.print(", Data Size: ");
Serial.print(sizeof(UBitxRigState));
Serial.println();
Wire.requestFrom(I2CMETER_ADDR, sizeof(UBitxRigState));
UBitxRigState tmp;
// First we need to see if there's any updated state.
Wire.requestFrom(I2CMETER_ADDR, sizeof(uint8_t));
int len = 0;
ptr = (uint8_t*)&tmp;
while (Wire.available() > 0) {
uint8_t b = Wire.read();
if (len < sizeof(UBitxRigState)) {
ptr[len++] = b;
int readflag = Wire.read();
if (readflag != 0) {
Wire.requestFrom(I2CMETER_ADDR, sizeof(UBitxRigState));
UBitxRigState tmp;
//int len = 0;
//ptr = (uint8_t*)&tmp;
while (Wire.available() > 0) {
uint8_t b = Wire.read();
if (len < sizeof(UBitxRigState)) {
ptr[len++] = b;
}
}
}
Serial.println("AFTER:");
Serial.print("VFO A: ");
Serial.print(r->vfo[0]);
Serial.print(", VFO B: ");
Serial.print(r->vfo[1]);
Serial.print(", Data Size: ");
Serial.print(len);
Serial.println();
}