Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional secondary serial device to ESP32 receivers #2605

Open
wants to merge 28 commits into
base: master
Choose a base branch
from

Conversation

mha1
Copy link
Contributor

@mha1 mha1 commented Mar 21, 2024

This PR intends to enable more possible use cases mostly for but not limited to fixed wing and helicopter pilots.

As an example consider the classical use cases:

  • a fixed wing setup with external CRSF telemetry and an external gyro connected to a receiver
  • a helicopter setup with a flybarless unit and external telemetry sensors (e.g. a telemetry capable ESC)

Currently ELRS receivers only allow using one serial interface (I call it the primary one) for the implemented set of protocols (CRSF, CRSF INV, SBUS, SBUS INV, DJI RS PRO HoTT Telemetry) making the above use cases impossible. This PR adds a secondary serial device on ESP32 receivers which enables running an additional protocol. This opens up the possibility to run two different protocols concurrently. In the above uses cases a setup could look like:

  • primary serial CRSF, secondary serial SBUS
  • primary serial HoTT Telemetry, secondary serial SUMD

Here's an example using a Radiomaster ER6 receiver showing protocol HoTT Telemetry with a GPS/Vario connected on the primary serial (RX and TX used) and SBUS on the secondary serial (only TX used) configured to use the signal pin of channel connector 6 which might be used to feed channel data to a flybarless unit or gyro. ER6 channels 1 to 5 still output PWM data.

pr

The secondary serial device can be configured using the WebUI or LUA script

Extensions to the code base:

  • added an additional serial device
  • added configuration options to WebUI and LUA
  • added logic to run any of the known serial protocols on the secondary serial device

@pkendall64
Copy link
Collaborator

The second serial and protocol should be selectable from the PWM page not the hardware page.
We may still keep the second serial pins on the hardware page for non-PWM receivers.

The hardware page should only be used to configure the actual hardware layout. Users should not be going to the hardware page to configure normal features.

@mha1 mha1 force-pushed the PR_secondary_serial_device branch from 9648df1 to 4601472 Compare March 22, 2024 08:40
@mha1
Copy link
Contributor Author

mha1 commented Mar 22, 2024

I first started thinking this might be an expert option but of course I see your point. To do a proper user UI I need some discussion on how to present this and also on how to implement this. scan.js is not self explanatory. Is there a UI guy we could try to pull in?

@pkendall64
Copy link
Collaborator

Is there a UI guy we could try to pull in?
That would be me as well 😭

@mha1 mha1 marked this pull request as draft March 25, 2024 13:29
@mha1
Copy link
Contributor Author

mha1 commented Mar 25, 2024

Example: SuperP 14CH configured to have SBUS on the primary serial and HoTT telemetry on the primary serial defined to be on channel 11 and 12 (JST connector):

image
image

2: ch11/12 on JST
3: ch14

image

@JyeSmith
Copy link
Member

Nice. The current changes are looking good.

My only comment for now is naming. Most users wont think in zero indexing, so something like "Serial2" or "Serial TX 2" in the Ui might be better?

@mha1
Copy link
Contributor Author

mha1 commented Mar 25, 2024

Thanks for your review. I think "Serial2 RX" and "Serial2 TX" would be fine. The Serial2 prefix can be used for WebUI protocol selection too. I'd name it "Serial2 Protocol" while keeping the first one at the known "Serial Protocol". But too long for LUA, so how about Protocol (unchanged) and Protocol2?

@JyeSmith
Copy link
Member

Protocol2 get my vote.

@mha1
Copy link
Contributor Author

mha1 commented Mar 26, 2024

names updated

@mha1
Copy link
Contributor Author

mha1 commented Mar 26, 2024

This is what it looks like currently. Let me know if you have other ideas.

image
image
image
image
image

@mha1 mha1 marked this pull request as ready for review March 27, 2024 12:33
@mha1 mha1 force-pushed the PR_secondary_serial_device branch from d391096 to 26f42b7 Compare March 28, 2024 18:35
@pkendall64 pkendall64 added the enhancement 🪄 New feature or request label Mar 31, 2024
@mha1 mha1 force-pushed the PR_secondary_serial_device branch from 356407e to 8a9d0ca Compare April 1, 2024 14:05
@55Laurent
Copy link

For your info some feedback, I made some tests of this feature on RM ER6 and Betafpv super P + a graupner +T70 esc and I also checked the Sbus output with a MC8 checker.
Everything work fine, telemetry is ok (I got the same sensors data that I can get with a genuin graupner receiver) and the Sbus is also working fine with both receivers. I used the web UI to set serial interfaces (Hott telem and Sbus), I also checked that thoses setting can be done with the lua srcipt.
Anything is perfect and very handy. Very nice job

@mha1 mha1 mentioned this pull request Apr 9, 2024
11 tasks
Copy link
Collaborator

@pkendall64 pkendall64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will also need to provide a config upgrader

src/html/scan.js Outdated Show resolved Hide resolved
@mha1 mha1 force-pushed the PR_secondary_serial_device branch from aebeaf2 to d0f7b86 Compare April 19, 2024 09:47
@mha1 mha1 force-pushed the PR_secondary_serial_device branch from afb8b7c to 558b75d Compare May 19, 2024 07:14
@pkendall64
Copy link
Collaborator

@mha1 One oddity I noticed is that if I set Serial2RX on pin13 and then Serial2TX on pin 14, pin 13 goes back to 50Hz in the web UI. Probably not a big deal.

@mha1
Copy link
Contributor Author

mha1 commented May 21, 2024

@mha1 One oddity I noticed is that if I set Serial2RX on pin13 and then Serial2TX on pin 14, pin 13 goes back to 50Hz in the web UI. Probably not a big deal.

ch13/14 on the SuperP?

@mha1 mha1 force-pushed the PR_secondary_serial_device branch from bdf12a6 to 9cf8d99 Compare May 21, 2024 06:48
@pkendall64
Copy link
Collaborator

@mha1 One oddity I noticed is that if I set Serial2RX on pin13 and then Serial2TX on pin 14, pin 13 goes back to 50Hz in the web UI. Probably not a big deal.

ch13/14 on the SuperP?

Yes, SuperP sorry.

@mha1
Copy link
Contributor Author

mha1 commented May 21, 2024

@mha1 One oddity I noticed is that if I set Serial2RX on pin13 and then Serial2TX on pin 14, pin 13 goes back to 50Hz in the web UI. Probably not a big deal.

ch13/14 on the SuperP?

Yes, SuperP sorry.

Thanks for pointing out this problem. This needed a little features logic refinement. PWM pins can only be featured as Serial1 or Serial2. Serial1 takes priority. Updated feature logic accordingly.

No more Serial2 feature badges on PWM pins for receivers having Serial1 U0RXD/U0TXD assigned to PWM pins:

image

@mha1 mha1 force-pushed the PR_secondary_serial_device branch from 5652ccc to fd971a4 Compare May 21, 2024 10:34
mha1 added 28 commits May 22, 2024 13:43
…are defined in hardware.html

fixes feature selections not greyed out at initialization
… pin

WebUI: show Serial2 mode selection only if Serial2 TX is assigned
- added logic to prevent multiple assignments of SCL/SDA and RX2/TX2
- SBUS driver object needs to know which serial stream it is running on to allow SBUS on one and DJI on the other serial device
changes:
- _('is-airport').onchange to call serial and serial1 onchange()
- added serial1 protocol to SetDefaults()
…s is handled in SerialIO driver which is always on)
cleanup rebase

first shot at LUA and WebUI user interface for selecting scondary serial pins and protocol

fixes build checks

cosmetics and added comment about DShot not working on GPIO0

PWM testing/fixes (ExpressLRS#2588)

* Revert "Fix for 10KHz 0% and 100% on 8285 receviers (ExpressLRS#2496)"

This reverts commit 12659fb.

* Much simpler handling of 0 high/low times

* Optimisation of timing in PWM timer interrupt

t

* Extend minimum time for next NMI

* Rename pin/i to gpio as thats what it really is.

cleanup

name changes for WebUI and LUA

fixed my serial1-config html extension (one </div> too many)

added Serial2 feature badge

increase-SX1276-SyncPktIntervalDisconnected-for-25Hz (ExpressLRS#2589)

Ignore trailing items with 0 duration (ExpressLRS#2612)

This fixes spurious channel data for inverted PPM and glitches

cleanup rebase

fixes build checks

cleanup

name changes for WebUI and LUA

fixed my serial1-config html extension (one </div> too many)

added Serial2 feature badge

Fix "Not set" UID badge (ExpressLRS#2619)

Allow choosing the SubGHz domain for LR1121 modules (ExpressLRS#2618)

restrict selection of Serial2 RX/TX to specific pins if Serial2 pins are defined in hardware.html

fixes feature selections not greyed out at initialization

include fix ExpressLRS#2623

LUA: bind Serial2 RX/TX to pins if defined for target, else allow any pin

WebUI: show Serial2 mode selection only if Serial2 TX is assigned

proper solution to showing/hiding Serial2 protocol selection.

WebUI: prevent multiple I2C SCL/SDA selections (ExpressLRS#2624)

* fixes issue ExpressLRS#2623

* do it properly

fix antenna value for Diversity/Gemini receivers (ExpressLRS#2622)

Fix LR1121 binding (ExpressLRS#2617)

* fix LR1121 binding

* remove magic

LUA script for assigning I2C and Serial2 modes:

- added logic to prevent multiple assignments of SCL/SDA and RX2/TX2

add r flag to encode string as raw string to fix deprecation (ExpressLRS#2598)

- SBUS Serial2 init with 8E2 instead of 8N2

- SBUS driver object needs to know which serial stream it is running on to allow SBUS on one and DJI on the other serial device

cleanup

updated to @pkendall64's review comments

changes:
- _('is-airport').onchange to call serial and serial1 onchange()
- added serial1 protocol to SetDefaults()

removed duplicate line of code
…s is handled in SerialIO driver which is always on)
@mha1 mha1 force-pushed the PR_secondary_serial_device branch from fd971a4 to 1653253 Compare May 22, 2024 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🪄 New feature or request V3.5 🍩
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants