Teensy 3.1 serial communication questions

Status
Not open for further replies.

bargj

New member
Hi all,

For one of my modelbuilding projects I'm trying to override transmitter values depending on sensor measurements.
I'm using a Spektrum DX8i satellite receiver that transmits dataframes of 16 bytes to a flightcontroller.
I know how to decode the frame and change the bytes that need to be changed, but I'm having problems sending this altered frame to the flightcontroller. This results in the following two questions:

1. How can I read the serial stream of 16 bytes on pin RX2 and send it through to TX1 without changing anything in the timing?
2. The dataframe of 32 byte has no clear header frame but follows after a communication pause of 9.5 ms. How can I synchronize to the datastream using this knowledge?

Best regards,

Jan Willem
The Netherlands
 
1. How can I read the serial stream of 16 bytes on pin RX2 and send it through to TX1 without changing anything in the timing?

You can't, really. A small delay is inevitable, if you're receiving on RX2 and retransmitting on TX1.

You might try using RX3, actually. It has no FIFO, which might actually be beneficial. With the FIFO, small groups of bytes tend to arrive all at once. On RX3, you have the best chance to get each byte as soon as possible.

2. The dataframe of 32 byte has no clear header frame but follows after a communication pause of 9.5 ms. How can I synchronize to the datastream using this knowledge?

You could call millis() or micros() upon receiving each byte and look for differences, or use a special elapsedMicros variable to keep track of the time since the last time Serial2.available() gave you data.
 
1. How can I read the serial stream of 16 bytes on pin RX2 and send it through to TX1 without changing anything in the timing?

I think If the delay is constant, the receiving instance will not notice that the data are a bit late :)
So... isn't it possible to receive the data on rx2, do some magic operations with them, and then output through tx1 ?
Just make sure that the delay is always constant.
 
Status
Not open for further replies.
Back
Top