Using Multiple Serial Ports is Extremely Difficult

I am using an arduino uno to attempt to create an automonous drone. The main issue I am having is with the different serial protocols and using multiple serial ports. I have to read 2 seperate signals and output 1 signal. The input and output is S-BUS format at 100000bps which is a strange baud rate to me. I have gotton it to read and output these types of signals properly. The other input is to read a DJI naza gps signal by tapping one of the lines, this signal uses a standard 115200 bps rate. Again I was able to get this to work succesfully.

One of my main problems is to run everything together. I mainly want to run multiple loops at the same time, two loops reading and saving information as global variables while the main loop uses those stored values to do things. I do not believe it is possible to do this in one loop because the serial ports could be recieving data at the same time or the arduino takes too long doing a task and overflows occur. I just want a gurenteed way of being able to recieve and store those signals into global arrays.

I am using an i2c lcd library, dji naza gps library, alternative software serial library(because I believe the dji naza gps library interferes normal software serial), and a library to read the sbus signal.

I am using 2 seperate transister inverters on the sbus inputs and outputs.

My main goal is to run 2 or more loops at the same time

Search for Robin2's Serial Input Basics - updated thread and his (her?) thread how to do multple things at the same time.

S-Bus is not a standard serial protocol.

My main goal is to run 2 or more loops at the same time

That is not going to happen, especially if you say you can't do it in one loop. By the way do you mean loop function?

Link to (his) (my) Serial Input Basics - simple reliable ways to receive data.

If you need to receive data from other serial ports then just make duplicate copies of the recvXXX function and the array in which to put the incoming data.

...R

I do not believe it is possible to do this in one loop

Rats!

... because the serial ports could be receiving data at the same time

I hope you're not using SoftwareSerial!

... or the Arduino takes too long doing a task and overflows occur.

I hope you're not using delay or any kind of blocking functions (or libraries that do)!

Of course, we have no idea what your sketch is doing. -_-

I just want a guaranteed way of being able to receive and store those signals into global arrays.

Yep, there's a way. With two copies of the data, you can have one copy that is the latest complete set of data. Use this one throughout your sketch when you need lat/lon, etc.

The other set gets assembled from the characters as they are received. When the final character is received, copy this new set to the "latest complete data" set.

There are several ways to do this, so let's see what you've tried.

Robin2: Link to (his) (my)

:D :D

It sounds like you will need multiple serial ports, which on an Uno can be done with SoftwareSerial but that won't stretch to the baud rates you are talking about. Can you go to a Mega 2560 which has four hardware serial ports? It also means you can keep that standard serial port free for debugging.

A Mega is way too big and heavy for a drone. Try a Teensy.