inav icon indicating copy to clipboard operation
inav copied to clipboard

Feature request: Sharing UART between SerialRX and uni-directional telemetry

Open rodizio1 opened this issue 9 years ago • 41 comments

Right now, I'm running a setup with Cleanflight and a Raspberry Pi that receives LTM telemetry from the FC and also sends MSP R/C commands to the FC. On the Pi, I use the same serialport for this. In Cleanflight, I have to use two different UARTs.

Now I would like to use iNav with a SPRacing F3 FC and a GPS. UART1 is already used for the USB port, leaving only two UARTs for telemetry, R/C and GPS. If I could run telemetry and R/C over the same UART (like on the Pi) this would work.

Would it be possible to make the UARTs TX/RX lines useable for different 'purposes' like in my example above? Ofcourse, baudrates and settings need to be the same, but this is not a problem for me. Not sure if the hardware supports this or how much effort it would be, all I know is, this works both on APM based FCs and also on the Raspberry Pi linux computer.

rodizio1 avatar Mar 15 '17 13:03 rodizio1

MSP is bi-directional protocol by design. It sends out confirmations to each command.

Is there any problem in connecting SPRacingF3 to RPi via USB? Or using softserial for telemetry output?

digitalentity avatar Mar 15 '17 13:03 digitalentity

If INAV can use Mavlink as communicating protocol not use MSP it will be fine.But it was a big change.

Linjieqiang avatar Mar 15 '17 13:03 Linjieqiang

MSP is bi-directional protocol by design. It sends out confirmations to each command.

True. But it works just fine like I described above and I didn't see any acknowledgements coming out of Cleanflight when sending MSP RC packets to it,

Is there any problem in connecting SPRacingF3 to RPi via USB? Or using softserial for telemetry output?

Softserial for telemetry output would be possible, but I only have one serialport on the Pi, so I'd be forced to the same low baudrate for R/C and telemetry.

The UART1/USB port on the Flightcontrol is already connected to a USB port of the Pi (for bi-directional MSP that will be forwarded to EZ-GUI).

rodizio1 avatar Mar 15 '17 13:03 rodizio1

The UART1/USB port on the Flightcontrol is already connected to a USB port of the Pi (for bi-directional MSP that will be forwarded to EZ-GUI).

Use that to inject MSP_RC packets into the flight controller and use UART only for telemetry data.

digitalentity avatar Mar 15 '17 13:03 digitalentity

I don't see a point in implementing something that can be easily solved by better utilization of existing features.

digitalentity avatar Mar 15 '17 13:03 digitalentity

Use that to inject MSP_RC packets into the flight controller and use UART only for telemetry data.

This is not easily possible, as there is already a datastream being forwarded from the Pi on the aircraft to the Pi on the ground and from there to the EZ-GUI (and vice versa). Doing it like that would require me to add some complicated "serial-proxy" type of application, i.e forwarding the EZ-GUI data and also additionally injects the MSP RC data. Not very nice. I'd like to keep this seperated, so people can decide if they want to use EZ-Wifibroadcast R/C or "traditional" R/C and still use the EZ-GUI features.

I don't see a point in implementing something that can be easily solved by better utilization of existing features.

I realize that my EZ-Wifibroadcast Raspberry Pi thing is a somewhat unusual kind of application, however, it's being used by more and more people, so I think there could be some demand in the future.

And in general, my feeling is, having more hardware UARTs useable/available is always a good thing, after all, many people buy F3 based FCs just because of the additional UARTs, not because of CPU/FPU power.

rodizio1 avatar Mar 15 '17 13:03 rodizio1

I realize that my EZ-Wifibroadcast Raspberry Pi thing is a somewhat unusual kind of application, however, it's being used by more and more people, so I think there could be some demand in the future.

A few thoughs on this:

  • Using one MSP stream to pass R/C from your app and the other MSP to task to EzGUI can lead to unsafe behavior if both your app and EzGUI will start sending MSP_RC frames. You have to implement filtering which is one step from becoming a true MSP proxy.

  • MSP is bi-directional by design. Hacking it to become uni-directional is generally a bad idea which may lead to issues.

  • You have enough serial ports to have two MSP streams plus telemetry plus GPS if you so desire. You just need to use them wisely

digitalentity avatar Mar 15 '17 13:03 digitalentity

Using one MSP stream to pass R/C from your app and the other MSP to task to EzGUI can lead to unsafe behavior if both your app and EzGUI will start sending MSP_RC frames. You have to implement filtering which is one step from becoming a true MSP proxy

Indeed, but I don't plan to use the R/C function of EZ-GUI anyway, it's experimental, and there are a lot of warning messages, so it's unlikely somebody will use it accidently.

MSP is bi-directional by design. Hacking it to become uni-directional is generally a bad idea which may lead to issues.

I've used that setup for a few flights, it works just fine.

You have enough serial ports to have two MSP streams plus telemetry plus GPS if you so desire. You just need to use them wisely

Again, this is not possible with my setup. Using softserial would limit my baudrate to 19.200 since I only have one UART on the Pi. Or I'd have to use an additional USB2Serial converter on the Pi, additional devices and wiring, also not very nice.

Like you say, the only viable solution would be some kind of "MSP proxy", but that just adds additional software-logic that complicates things and that can have bugs and fail. The solution I have now (generating MSP packets from Joystick-Input on the ground Pi, sending them to the Pi on the aircraft and sending them out on the serialport) is simple and proven.

rodizio1 avatar Mar 15 '17 14:03 rodizio1

The other viable solution is to talk MSP_RC via USB and use 19200 software serial for communication with EzGUI (works fine btw)

digitalentity avatar Mar 15 '17 14:03 digitalentity

Nope. I only have one serialport on the Pi. If I use that one for the bi-directional EZ-GUI link and an USB port for the MSP RC stuff, I don't have anything left for the LTM telemetry on the Pi.

rodizio1 avatar Mar 15 '17 14:03 rodizio1

Actually, you don't need LTM or any other telemetry - you have MSP which can provide you with all data you need. Use polling to pull what you need from FC (like MWOSD does). Ultimately only one USB connection to FC would be required.

digitalentity avatar Mar 15 '17 14:03 digitalentity

I would prefer that we did not open up the possibility of an attacker hijacking my aircraft over the telemetry port.

stronnag avatar Mar 15 '17 14:03 stronnag

The wifibroadcast_osd I use doesn't support MSP telemetry, only mavlink, LTM and Frsky and no polling. I'd have to add MSP support with polling, which is far from trivial. Apart from that, polling is not really useable with wifibroadcast, as upstream bandwidth is limited due to the underlying wifi medium access.

Digitalentity, I realize you guys have lots of stuff to do (and there are more urgent things), but I really have thought about this for weeks and tried all kinds of stuff. I wouldn't be bothering you with this feature request if there was a more viable solution or even a "not-too bad workaround" on my side. But as I see it, there isn't.

rodizio1 avatar Mar 15 '17 14:03 rodizio1

It's not that I'm entirely against this idea. I don't see a point in hacking MSP implementation to allow uni-directional communication. This creates all sorts of issues - here are a few that just came to me:

  1. A separate configuration setting to distinguish when to replace MSP with telemetry entirely and when to release only TX and keep listening on RX for MSP packets.

  2. MSP expects to be able to send response data. Hacking well-debugged implementation to ignore this is not a good idea considering very low demand for this feature.

  3. Considering upcoming bi-directional telemetry (MAVLink for starters) the feature you are requesting is becoming even less clean in terms of implementation.

I would really like to also know @martinbudden, @DzikuVx and @oleost 's oppinion on this feature.

digitalentity avatar Mar 15 '17 14:03 digitalentity

@rodizio1 please take no offense, but I think it would be better if EZ-Wifibroadcast would adapt to support more different flight controllers. If you add canonical polled MSP OSD you'll instantly become compatible with all (with some caveats) MSP-talking firmwares starting from ancient MultiWii.

Similarly - when we wanted support for Crossfire telemetry - it was created in INAV instead of trying to convince TBS to better support something we already have.

digitalentity avatar Mar 15 '17 14:03 digitalentity

I have not got a chance to read entire issue.

But as far I understand implementing mavlink will sort his issue?

And mavlink is already being wanted by multiple users and it would also open up a lot of ground stations for INAV.

So I vote for going forward with mavlink support.

oleost avatar Mar 15 '17 14:03 oleost

It's not that I'm entirely against this idea. I don't see a point in hacking MSP implementation to allow uni-directional communication. This creates all sorts of issues - here are a few that just came to me:

Sorry, but there is no "hack", it's already working fine with a "stock" Cleanflight version.

I simply took Cleanflight 1.14, configured it for MSP_RC on UARTx, connected that UARTs Rx pin to the Tx pin of the UART on the Pi and let the Pi send MSP RC packets over it. That's it. Works just fine, delay is low, high updates rates are possible, failsafe also works as expected.

please take no offense, but I think it would be better if EZ-Wifibroadcast would adapt to support more different flight controllers. If you add canonical polled MSP OSD you'll instantly become compatible with all (with some caveats) MSP-talking firmwares starting from ancient MultiWii

It already supports Mavlink, LTM and Frsky, I think that's already plenty of protocols. I would even spend the time to implement MSP one-way, but doing it polled is pointless with wifibroadcast, as every single request would have to be sent upstream over the air. The telemetry data is being parsed and rendered on the ground Pi. For the typical analog OSDs which sit on the aircraft, this is fine of course.

Of course, I could also write something that does the polling on the air Pi and only forwards the outgoing telemetry to the ground Pi (plus sending MSP RC packets from Pi to FC ...), but that would be a big-ass monster proxy ;) and just complicate everything and make it a lot more error-prone (especially with my bad C-skills ...)

The solution I proposed above would allow me to:

  • forward the bi-directional MSP stream to the EZ-GUI connected to the ground Pi (and back to the FC) over one link
  • forward the uni-directional LTM stream to the OSD on the ground Pi over another seperate link
  • forward the uni-directional MSP RC packets from ground Pi to air Pi over another seperate link

In a very simple and non-error-prone way and without having to resort to ugly solutions like an additional USB2Serial adapter on the aircraft.

rodizio1 avatar Mar 15 '17 14:03 rodizio1

But as far I understand implementing mavlink will sort his issue?

And mavlink is already being wanted by multiple users and it would also open up a lot of ground stations for INAV.

No, this is not about telemetry protocols. I simply would like to not "waste" serial port hardware.

As it is now, when one UART is being used only uni-directional (for example the TX pin for outgoing LTM telemetry), the complete UART is "used-up" as the corresponding RX pin of that UART is not useable anymore for anything else.

rodizio1 avatar Mar 15 '17 15:03 rodizio1

So far I see two arguments from your side, digitalentity:

  • Do it somehow differently using a different combination of serialports or software. Like re-writing my whole software, using additional ugly usb2serial converters and usb hubs on the aircraft, implement a completely different telemetry protocol, implement polling.

I have explained why those options are not good options for my case. Apart from that, there might be other use cases that could benefit from this. Like I wrote, APM supports this, I figure they've added it because somebody had a use for it.

  • MSP is bi-directional which can cause whatever issues:

Again, MSP_SET_RAW_RC is not bi-directional, Cleanflight works just fine receiving MSP packets and does not send anything back.

It's not that I'm entirely against this idea. I don't see a point in hacking MSP implementation to allow uni-directional communication. This creates all sorts of issues - here are a few that just came to me:

To me it looks like you already made up your mind about this when you closed this issue (just 20mins after creation and without even bothering to wait for an answer ...) and then you look for technical arguments that support your gut decision. You, obviously working with computers, I'd expected to be more on the side of science ;)

image

@rodizio1 please take no offense, but I think it would be better if EZ-Wifibroadcast would adapt to support more different flight controllers.

Giving different ideas or approaches to find a solution is fine. Closing the issue after 20mins without knowing any details or even waiting for an answer I'd consider offensive though.

rodizio1 avatar Mar 15 '17 17:03 rodizio1

@rodizio1 I gave you several options to make your solution work without modifying the INAV code.

How many users do you have using your solution? I understand that it's easier for your to have somebody adapt INAV to your needs, but I will consider spending time modifying INAV to make it compatible with something that is widely adopted already, not with something that only a handfull of people use.

If you still feel that you need to modify INAV to suite your needs - please consider implementing it yourself and submitting a pull-request into INAV - this is how opensource development usually works.

Regarding other things. As I said before - your problem can be solved on your end without any hacks on INAV side, that was the very reason for closing this issue. No other technical evidence is necessary to support that decision.

Also, @oleost has a point. MAVLink (when it goes bidirectional) can also be used for telemetry and control and it will also occupy only one UART. It will happen naturally in 1.7 maybe you should consider migrating to MAVLink instead?

digitalentity avatar Mar 16 '17 01:03 digitalentity