Multiple SoftwareSerials connections

Support forum for MegunoLink
Post Reply
User avatar
RoboBill
Posts: 31
Joined: Mon May 23, 2016 4:13 pm

Mon Oct 30, 2017 4:31 am

I'm using Megunolink to monitor and (hopefully) adjust variables of a modified version of this sketch https://github.com/ArduPilot/ardupilot/ ... Loiter.ino.

I connect Megunolink to the Arduino Uno sketch via a standard XBee shield and using SoftwareSerial "XBeeSerial". But the sketch also includes another SoftwareSerial connection "fcboardSerial" which connects the Uno to an Ardupilot Pixhawk controller via a wired serial connection.

I'm able to monitor the data produced by the sketch via the XBeeSerial connection but am unable to send any data from my interface panel to the sketch.

To find the problem, I started with a simple single SoftwareSerial XBeeSerial sketch. I discovered that as soon as I included the second SoftwareSerial connection (fcboardSerial), the data coming from the Megunolink interface panel stopped being recognized by the Arduino sketch.

Question: Are there any tricks I need to do in order to work with multiple SoftwareSerial connections.

UPDATE: OK I just read up about the Listen() function. I'll let you'all know if it helps.


Thanks

RoboBill
philr
Posts: 446
Joined: Mon May 26, 2014 10:58 am

Tue Oct 31, 2017 5:20 am

Good question. I don't believe it should matter. I would have thought the instances of software serial objects should be separate. Let us know how you go!
User avatar
RoboBill
Posts: 31
Joined: Mon May 23, 2016 4:13 pm

Tue Oct 31, 2017 1:31 pm

Well it turns out that only one SoftwareSerial port can "listen" at any given time. So if the program was listening to the Pixhawk/fcboardserial port, it would never receive any data from my XBee/Megunolink interface panel port. There is the SoftwareSerialPort.listen() function, but given that I'm not a programmer and these serial ports seem to rely on complex internal interrupts, timers, etc, I decided to switch my uno to a mega where I can use real hardware serial ports ....

All is much better

Thanks

RoboBill
philr
Posts: 446
Joined: Mon May 26, 2014 10:58 am

Sun Nov 05, 2017 10:59 pm

That sounds like a good (and probably more reliable) solution.
Phil
Post Reply