Skip to content

Issue With UART Send/Receive #58

Description

@michaelwro

Hi, I really like your SerialTransfer library. I think it would be a great product to integrate into my quadcopter flight controller.

I am using your library to communicate between a Teensy 4.1 and Arduino Nano via XBee3 radios. I am following your uart_rx_datum.ino and uart_tx_datum.ino examples to send a struct from the Teensy to the Nano. I have debug messages enabled and am frequently getting ERROR: CRC_ERROR and ERROR: STOP_BYTE_ERROR messages at the receiver (Nano). These errors are significantly slowing down my data rate, since I assume you discard a packet if an error is encountered. I am not very familiar with the inner workings of your library, and thought I'd bring this issue to your attention. I wonder if I am using it improperly, or if there is a potential issue buried within the code.

Thank you for your time addressing this issue and for creating this great project!

Teensy 4.1 (Transmitter)

#include "SerialTransfer.h"
#define XBEE_UART Serial8
SerialTransfer XbeeTelem;

typedef struct
{
    float mx;
    float my;
    float mz;
} MagnetometerData_s;
MagnetometerData_s DataPacket {1.0f, 2.0f, 3.0f};

void setup()
{
    Serial.begin(115200);
    XBEE_UART.begin(115200);
    XbeeTelem.begin(XBEE_UART, true, Serial);  // send, debug, debug interface
    delay(200);
}

void loop()
{
    XbeeTelem.sendDatum(DataPacket, sizeof(DataPacket));
    delay(50);
}

Arduino Nano (Receiver)

#include <Arduino.h>
#include <SoftwareSerial.h>
#include "SerialTransfer.h"

SoftwareSerial XbeeSerial(2, 3);
SerialTransfer TelemStream;
void PrintData();

typedef struct
{
  float mx;
  float my;
  float mz;
} MagnetometerData_s;
MagData_s RecPacket;

void setup() {
  XbeeSerial.begin(115200);
  Serial.begin(115200);
  TelemStream.begin(XbeeSerial, true, Serial);
delay(200);
}

void loop() {
  if (TelemStream.available()) {
    TelemStream.rxObj(RecPacket);
    PrintData();
  }
}

void PrintData() {
  Serial.print("mx: "); Serial.print(RecPacket.mx, 2);
  Serial.print("  my: "); Serial.print(RecPacket.my, 2);
  Serial.print("  mz: "); Serial.println(RecPacket.mz, 2);
}

Receiver Serial Output (Nano)

mx: 1.00  my: 2.00  mz: 3.00
ERROR: CRC_ERROR
mx: 1.00  my: 2.00  mz: 3.00
ERROR: CRC_ERROR
mx: 1.00  my: 2.00  mz: 3.00
mx: 1.00  my: 2.00  mz: 3.00
mx: 1.00  my: 2.00  mz: 3.00
ERROR: STOP_BYTE_ERROR
ERROR: CRC_ERROR
mx: 1.00  my: 2.00  mz: 3.00
mx: 1.00  my: 2.00  mz: 3.00
mx: 1.00  my: 2.00  mz: 3.00
mx: 1.00  my: 2.00  mz: 3.00
mx: 1.00  my: 2.00  mz: 3.00

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions