-
-
Notifications
You must be signed in to change notification settings - Fork 361
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
Corrupt data using SPort soft serial for external modules #3285
Comments
First of all I was wrong tagging this as a 2.8.1 problem. It's a main problem tested with the latest nightly and I think got introduced with the module ports renovation. 2.8.1 is working fine. Back to the problem I suspected the sampling might be off but actually looks pretty good. The start bit is detected after 500ns (first pulse generated at entry into the falling edge ISR static void _softserial_exti()) and the following 8 samples (pulses generated in the timer ISR at the point where the GPIO is read - void stm32_softserial_rx_timer_isr()) are positioned right at half the bit time. So the soft serial driver is working fine. But even with this perfect sampling example sporadic data corruption occurs. Most likely some higher priority interrupt hitting in between bit samples throwing the timing off. @pfeerick @raphaelcoeffic any ideas? PS: With a little patience I caught one The first UART line is the feed in at the SPort pin, the second line is telemetry mirror output. Note the first 4 bytes. In: 02 55 AA 22, Out: 02 55 AA 91. The 22 was not sampled correctly. Check out the 9,75us delay instead of the usual 500ns delay detecting the falling edge of the start bit. We missed an entire bit and everything else after that goes wrong because we are one bit out of sequence. It's gotta be a high priority interrupt that delayed firing the the falling edge detection ISR. If you want to see for yourself please use the attached DSLogic data file. Can be opened in DSView which is available free of charge. |
I think it is the change of IRQ priority, old code uses 0 for both EXTI and TIM irq priority, but new code did not. |
Yes, I changed the falling edge detection IRQ prio from 5 to 0 for target Horus a few days ago after talking with @raphaelcoeffic. This solved the problem for Horus type radios. Tested on TX16s and X10express ok. Not sure about the other targets Taranis and NV14. Need feedback from @raphaelcoeffic |
Already replied you in your PR, please go ahead to fix taranis target as well. |
I'd like to do some testing on this. Do you have a Taranis type radio and a FTDI? |
I do not have a Taranis, need somebody have it to test anyway, however it didn't blocks you from changing the taranis as well in your PR. The old code uses 0 priority as well. |
@pfeerick I'm sure you have a Taranis type radio and a FTIDI, haven't you? |
I plead the fifth. |
Overruled, there is no 5th in Australia |
Let me know the Cmake for your radio and I'll send you 2.9 firmware to test soft serial and a corresponding Windows command line tool to stimulate soft serial via the SPort pin. |
Welp... tough crowd! 😮 The X9D+2019 will be more reliable atm, so |
Thanks for your precious time. Attached is a .zip with test firmware for X9D+2019 and X9D+ with changed IRQ priority for soft serial, the Windows command line tool and notes.txt. Please read notes.txt on how to set this up. As a reference the same build for TX16s which tested ok on my TX16s with the setup described in notes.txt |
For the X9D+2019, when switching between 2.8.1 and your build, this seemed to have no change in behaviour - all sensors, but rolling values for some.
X9D+2019 X9D+ X9D+ (including discovery) TX16S |
Thank you very much for testing. Can you please verify the fw versions for your comparisons 2.8.1 -> my self build. There is no way you'd be able to set the external module to subtype MLink (PPM MLINK) in 2.8.1 for any radio. This option of selecting a subtype only exists in my self build. And please make sure after my self build is flashed you go into settings/external module to select PPM MLINK. If that's the case you should see only the sensors discovered with main.exe running I listed in notes.txt Flashing 2.8.1 and selecting PPM in settings/ external module (no subtype selection possible) might show some sensors after discovery with main.exe running but sensors should be different to the 10 as listed in notes.txt |
I should have explained this better: my self build implements two major differences to 2.8.1 and 2.9. In 2.8.1/2.9 you can only select PPM as external module type without further specifying the telemetry protocol that is fed to the SPort pin. 2.8.1 is special here as by default it interprets any serial data coming in through the SPort pin as FrSky SPort telemetry. The switch to the new serial/module API in 2.9 disabled this feature. So if you'd try a recent 2.9 nightly you wouldn't be able to discover any telemetry sensors with a PPM module. I think it was never deliberately chosen to decode SPort telemetry with PPM. The port was just open. Fact is 2.9 after the serial/module API has disabled decoding SPort telemetry which I think is correct. My change uses 2.9 and starts fresh with allowing deliberate telemetry protocol selection for module type PPM. I started with implementing a new protocol for a Multiplex PPM JR type module that is able to deliver serial telemetry too. Main.exe simulates this protocol, not SPort telemetry. Feeding main.exe's data to a 2.8.1 radio will produce random results as 2.8.1 tries to decode this as SPort telemetry (this is what your videos show). Having my self build flashed and having set the external module to PPM NOTLM should show no discovered sensors, setting it to PPM MLINK should shown exactly the 10 sensors I listed in notes.txt. Make sure you delete all sensors and rediscover sensors after switching firmware versions. While implementing based on a recent 2.9 versions I found this serial problem which has it's roots in the IRQ priority change that came with the big serial/module API renovation. This is also corrected in my self build and is the test focus. The major changes in my self build vs 2.9: Expected results:
2.9 current nightly (any after the serial/module API renovation)
2.9. Michael's self build:
So if you really wanted to do a comparison you should compare a 2.9 nightly build after Raphael's big change to my self build. |
Ok, this monkey didn't read the instructions properly... I still had Lemon DSMP in my head when I was trying this, so had the module type set to that... regardless... on this X9D+ something changed between 2.8.1 and your build for the better (even with the wrong setting 😆) ... which is actually no surprise given it was playing up before but another user couldn't repo it... so will try again and will put my glasses on this time 😇 |
No problem. Knowing I am good at confusing people, I should have explained the context much better. Here's my new attempt to confuse you but with good intentions: to save your time 😇
|
You'll have to try harder - that made sense 🤭 TX16, X9D+2019 and X9D+ with the correct protocol setting worked perfectly this time... https://drive.google.com/file/d/1DmCd00J95WnSCzcN8PxjrbEeEyJ3IrcZ/view?usp=sharing, https://drive.google.com/file/d/1DomngIV4dqANCyqNpFkiBLNvCyORBmwJ/view?usp=sharing, https://drive.google.com/file/d/1DpgTSfdR9y2mtgSqhYaa_ANM_i9Hg-hz/view?usp=sharing |
Hi Peter, thanks again for your time and patience. I have updated PR #3285 accordingly and think it's ready to go. You actually tested quite a bit more than just the fix for this issue. The test setup and firmware files you used for testing fully reflect PR #3352 (Support for external Multiplex MLink JR type module) and PR #3328 (fix: UI - not all detected sensors displayed at detection time). I'd appreciate you checking out both PRs and hopefully green light them too. |
Is there an existing issue for this problem?
What part of EdgeTX is the focus of this bug?
Transmitter firmware
Current Behavior
Working with an external module using SPort serial input for telemetry I noticed unexpected glitches.
The glitches are caused by soft serial sampling. To prove this claim I have a simple test setup which uses an existing external module protocol using SPort telemetry (LemonRX DSMP - physical module not required) and feeding arbitrary data to the SPort Pin. The data is read back using telemetry mirror and compared to the fed in data.
Note: 2.8.1 works fine, no data corruption
Test setup:
TX16s
set External Module to mode LemonRX DSMP
set AUX1 to Telem Mirror
connect FTDI GND to module bay GND
connect FTDI TX to module bay SPort pin
connect FTDI RX to AUX1 TX
Feed a 22 byte data frame at 115200 every 100ms, e.g. using HTerm (ASend 0,1) to the module bay SPort pin:
02 01 1B 22 1B 23 04 05 06 46 3A 5B 00 00 6E 01 14 15 16 17 18 03
Log of Telemetry Mirror output:
Expected Behavior
No data corruption using module bay Sport pin.
Steps To Reproduce
see above
Version
2.9 latest nightly, been in there since the major driver and ports overhaul
Transmitter
Radiomaster TX16S / TX16SMK2
Anything else?
No response
The text was updated successfully, but these errors were encountered: