-
-
Notifications
You must be signed in to change notification settings - Fork 354
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
User controllable serial port power #1848
Conversation
Thx to @raphaelcoeffic for numerous tips with YAML. Tested with TX16S mkII.
Is there any reason for the power bit to not be the highest, so that it isn't in the middle of the array if more options are added later? Not that it really makes any difference either way. I think the question should more be "what other transmitters support soft power control of the serial power pins... if the answer is none... the answer is pretty clear ;) |
I can change this to the MSBit if that is desired? |
I am presently aware of TX16S only, and thus limited the GUI additions in this PR to TX16S. |
Changed in the latest commit the power bit to the most significant bit in the configuration byte, as suggested. |
@rotorman hear you |
No, better that, you limited it via a feature flag ... thus it should just be a matter of adding that flag to any other transmitters with soft serial power control ;) Changing the position of the power bit was really just up for discussion, but thank you :) Just made more sense to me organisation wise, until we need more bits! :-O |
Still testing but so far I have found a problem with the radio sim in that it is not reading the power value correctly ie always unchecked. Not wishing to point fingers but maybe it is related to the yml to new bit position. serialPort: |
@elecpower Thank you not only for Companion additions, but also pointing me to the right direction - you were perfectly correct about the issue stemming from power bit position shift - I needed to add 3 YAML_PADDING bits to accommodate the change as well. The PR should be in working condition again. |
Confirm power value now interpreted correctly. However, there is a bug in the simulator which I'm not sure will show up in the real radio. Steps to replicate in Ubuntu 20.04:
Would appear the memory space is not initialised so could show anything rather than old values as in my example. @rotorman I've finished my testing so I'll hand back over to you to continue |
I noticed during testing that the serial port mode dropdown choices can vary between Companion and the simulator if the libsim has not been compiled with CLI and/or Debug. |
No, we should assume defaults as used by the GH builds. |
Or rather, perhaps this means |
Preliminary testing suggests there is discrepancy between how Companion and firmware are working... i.e. on the radio, you can toggle the port power regardless of the mode (which IMO is valid as one is not technically dependant on the other, but this also means you you can use the port for power for something else ) but it seems that Companion is only writing the power value when the port has a mode set (i.e. breaking that capability). On a side note, I also notice Companion is not setting the USB-VCP port on TX16S to CLI by default (which is still ok, as the radio will populate this itself if it is missing). This does however mean when setting up a blank profile, CLI is available for AUX1, AUX2, when really it should already be reserved by VCP (btw, can you update that to USB-VCP please while you're in the neighbourhood :) ) |
I am in favor of being able to turn on or off AUX[1|2] power, irrespective of the mode selected, and even if the mode is OFF (e.g. to just tap 5V for some DIY mod w/o data lines involved). |
Radio and companion testing now done... UI is working fine, companion is nuking power state as I expected it would if mode is "OFF". An inconsistency in the AUX1 power state - it seems to be ON by default at powerup (in contrast to the UI state - checkbox was OFF), and you have to toggle it on and off for it to actually turn off. AUX2 is fine - it is off if set off, and toggles normally. This is also reflected in the bootloader - i.e. AUX1 is on in the bootloader, and AUX2 is off. |
Thank you for testing! Hmm... I wonder if it stems from uninitialized |
I had a look at bootloader code and the serial driver is loaded and initialized ONLY, if built with DEBUG: edgetx/radio/src/targets/common/arm/stm32/bootloader/boot.cpp Lines 248 to 250 in 7a6d623
and edgetx/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt Lines 141 to 149 in 7a6d623
Hooked up a scope to TX16S AUX power pins and noticed that with 2.7.0-release AUX1 PWR gets ramped up in bootloader as well, whereas AUX2 remains down. Thus, at least the behaviour in bootloader seems to be unrelated to this PR. |
Found my bug, now the serial power state should come up correctly, irrespective of the mode selected on boot-up (also when serial mode is OFF). When bootloader is running, the serial power delivery pins are turned off (except the little glitch on AUX1 during entering bootloader, that happens before the bootloader I tested all 4 selection possibilities on TX16S (power for AUX1, AUX2 both off, only AUX1 power on and so on) with a scope. Re-booted also after making a selection to make sure the power is delivered as was selected after restart as well - all seems OK to me now. |
Changed Companion to always save serial port settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed, power states are behaving exactly as they should for AUX1 and AUX2, on radio. Momentary bootloader 'glitch' of AUX1 power state is perfectly fine.
I've just pushed a fix for "Telemetry In" not beeing interpreted correctly, but everything else has tested ok, so once a companion test passes it's in.
TELEMETRY_MIRROR
SBUS_TRAINER
LUA
CLI
GPS
DEBUG
were all good.
sorry for jumping in. i wonder if there's a way that we can assign the function for the UART power availability to a toggle switch? that way we can use itu for an ON-OFF switch for a device attached or drawing power from the said UART, say maybe like an audio Bluetooth module or a telemetry Bluetooth module |
Solves #1766 by adding checkboxes into UI, for the user to explicitly enable or disable the power output on supply pins next to serial ports available on some radios (presently only TX16S has this feature).
Two example screenshots from physical TX16S mkII:
As USB VCP has no controllable power, no check box is presented for it.
The augmented serial port section in
radio.yml
, corresponding to the last screenshot:Internally, the
g_eeGeneral.serialPort
was expanded with this PR to 8-bits per serial port, lower 4 bits are used for mode (0 = OFF, 1 = Telemetry Mirror, 2= Telemetry In, 3 = SBUS Trainer, 4 = LUA, 5 = CLI, 6 = GPS),5th bit8th bit for power state (0 = OFF, 1 = ON), the bits 5 to 7 remain presently unused.Update: the power state bit was in a later commit changed to the most-significant bit due to suggestion by @pfeerick
Thx to @raphaelcoeffic for numerous tips with YAML.
Needs Companion support - @elecpower yelp!
Should we limit this feature presently to TX16S target only?