Q: does broken serial connection block the main loop?

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Q: does broken serial connection block the main loop?

Post by Hamburger »

Hi,

I want to write continuously to a serial device (LCD or LCD via 2 BT modules) from within the main loop.
Now consider the connection breaks for some reason, eg. distance too far for BT or LCD firmware too slow
What is the effect on the arduino, namely on the main loop?
Do al the writes get buffered and we experience an overrun/halt/crash or are the bytes in the queue discarded or what?

Reason for me asking is I want to write a continuous stream of telemetry data. Of course this requires a wireless connection. And so I am afraid of side effects on MultiWii in case of BT signal loss or disturbance.

anyone?

Hamburger

noobee
Posts: 66
Joined: Fri Feb 25, 2011 2:57 pm

Re: Q: does broken serial connection block the main loop?

Post by noobee »

if you only use tx/rx and gnd connections from your arduino (tx) to your bt module (rx), then there is no hardware flow control between the two and data would just be lost if the bt connection breaks. don't think the arduino will even realize this condition (for one way telemetry transfers).

foomatic
Posts: 17
Joined: Fri Jan 21, 2011 1:33 pm

Re: Q: does broken serial connection block the main loop?

Post by foomatic »

noobee wrote: don't think the arduino will even realize this condition (for one way telemetry transfers).

I strongly agree.

The single wire that's used for transmitting data doesn't get any acknowledgement from the receiver. The Atmel would continue to send its data but nobody would receive anything.

What does cause the main loop to hang is if data is announced but not sent, i.e. if settings are to be updated but you don't actually send the complete block.

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Q: does broken serial connection block the main loop?

Post by Hamburger »

ok, thanks guys,

you got me. I will give it a try and modify the telemetry code to continuously transfer data. Will be interesting to see how it goes.

Hamburger

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Q: does broken serial connection block the main loop?

Post by Alexinparis »

In normal situations, there should't be any problem.
But I think there is an exception:

Code: Select all

case 'C': //GUI to arduino param

once a 'C' is received (and not a part of other frames) , the arduino will wait for other char

Code: Select all

while (Serial.available()<21) {}

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Q: does broken serial connection block the main loop?

Post by Hamburger »

I can now positively attest that a broken BT connection does not have any negative impact on the MultiWii main loop, if MultiWii is writing data (as is the case for sending telemetry data). That data is just lost. No further harm done.

thanks to all who encouraged me to try this.
Hamburger

Post Reply