[Solved] Disable libcec in Mythwelcome

Have a MythTV related problem? Ask for help from other MythTV users here.

Moderator: Forum Moderators

Post Reply
trx-913
Newcomer
Posts: 8
Joined: Sun Mar 10, 2019 4:33 pm
United States of America

[Solved] Disable libcec in Mythwelcome

Post by trx-913 »

Hi,
I am trying to use hdmi-cec functionality in mythfrontend, but find I am unable to do so since mythwelcome has already opened the COM port /dev/ttyACM0. Mythfrontend which is started from mythwelcome from my setup, tries to open the same COM port and fails since it is already open.

mywelcome.log:
2019-05-28 17:19:46.018370 I [1676/1676] CoreContext cecadapter.cpp:211 (Open) - CECAdapter: Opened CEC device.
2019-05-28 17:19:46.018480 I [1676/1676] CoreContext mythudplistener.cpp:32 (Enable) - UDPListener: Enabling
2019-05-28 17:19:46.018867 I [1676/1694] thread_unknown cecadapter.cpp:271 (LogMessage) - CECAdapter: << powering on 'TV' (0)

Is there anyway I can disable mythwelcome from opening the CEC port ? I tried mythwelcome -O libCECEnabled=0, but that does not seem to work.
I am running debian linux on an intel NUC8i3BEH.

Thanks in advance.
User avatar
bill6502
Developer
Posts: 2323
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Disable libcec in Mythwelcome

Post by bill6502 »

Looks like a bug. If you build from source, read on. Otherwise, the fix will be in master
and we'll see if anyone else tests it. I don't have access to a CEC device. Seems to
work OK as I get "... Setting 'libCECEnabled' being forced to '0'" in mythwelcome.log.

Back in 2011, mythwelcome was converted to use the new ConfigureLogging method
but the ApplySettingsOverride method wasn't added. The fix is:

Code: Select all

diff --git a/mythtv/programs/mythwelcome/main.cpp b/mythtv/programs/mythwelcome/main.cpp
index bcc27c7359..5f5edcf9cd 100644
--- a/mythtv/programs/mythwelcome/main.cpp
+++ b/mythtv/programs/mythwelcome/main.cpp
@@ -96,6 +96,8 @@ int main(int argc, char **argv)
         return GENERIC_EXIT_NO_MYTHCONTEXT;
     }
 
+    cmdline.ApplySettingsOverride();
+
     if (!MSqlQuery::testDBConnection())
     {
         LOG(VB_GENERAL, LOG_ERR,
Without the above, no overrides would work, not limited to CEC. [807c09b]
Last edited by bill6502 on Thu May 30, 2019 7:44 pm, edited 1 time in total.
Reason: Added commit
trx-913
Newcomer
Posts: 8
Joined: Sun Mar 10, 2019 4:33 pm
United States of America

Re: Disable libcec in Mythwelcome

Post by trx-913 »

I tried the fix below by editing mythwelcome/main.cpp. I see the "libCECEnabled being forced to 0" in mythwelcome.log, but the CEC port is opened prior to the message "forced to 0" message and still seems connected later. Relevant portions of log shown below.

2019-05-31 08:53:21.666765 I [1307/1307] CoreContext cecadapter.cpp:172 (Open) - CECAdapter: Found 1 CEC devices(s).
2019-05-31 08:53:21.666790 I [1307/1307] CoreContext cecadapter.cpp:187 (Open) - CECAdapter: Device 1: path '/sys/devices/pci0000:00/0000:00:14.0/usb1/1-5' com port '/dev/ttyACM0' SELECTED
2019-05-31 08:53:21.666792 I [1307/1307] CoreContext cecadapter.cpp:199 (Open) - CECAdapter: Trying to open device /sys/devices/pci0000:00/0000:00:14.0/usb1/1-5 (/dev/ttyACM0).
2019-05-31 08:53:25.192726 E [1307/1698] thread_unknown cecadapter.cpp:271 (LogMessage) - CECAdapter: error opening serial port '/dev/ttyACM0': Device or resource busy
2019-05-31 08:53:25.192742 E [1307/1698] thread_unknown cecadapter.cpp:271 (LogMessage) - CECAdapter: could not open a connection (try 1)
2019-05-31 08:53:28.020572 E [1307/1698] thread_unknown cecadapter.cpp:271 (LogMessage) - CECAdapter: error opening serial port '/dev/ttyACM0': Device or resource busy
2019-05-31 08:53:28.020577 E [1307/1698] thread_unknown cecadapter.cpp:271 (LogMessage) - CECAdapter: could not open a connection (try 2)
2019-05-31 08:53:29.385076 I [1307/1698] thread_unknown cecadapter.cpp:271 (LogMessage) - CECAdapter: connection opened
2019-05-31 08:53:29.778344 I [1307/1698] thread_unknown cecadapter.cpp:271 (LogMessage) - CECAdapter: registering new CEC client - v4.0.4
2019-05-31 08:53:30.578217 I [1307/1698] thread_unknown cecadapter.cpp:271 (LogMessage) - CECAdapter: >> source activated: Playback 1 (4)
2019-05-31 08:53:30.578253 I [1307/1698] thread_unknown cecadapter.cpp:271 (LogMessage) - CECAdapter: CEC client registered: libCEC version = 4.0.4, client version = 4.0.4, firmware version = 8, firmware build date: Fri Jul 21 09:08:24 2017 +0000, logical address(es) = Playback 1 (4) , physical address: 1.0.0.0, compiled on Linux-4.9.0-8-amd64 ... , features: P8_USB, DRM, P8_detect, randr, Exynos, AOCEC
2019-05-31 08:53:31.085445 I [1307/1307] CoreContext cecadapter.cpp:211 (Open) - CECAdapter: Opened CEC device.

2019-05-31 08:53:32.257571 N [1307/1307] CoreContext mythcommandlineparser.cpp:2641 (ApplySettingsOverride) - Setting 'libCECEnabled' being forced to '0'

2019-05-31 08:53:32.776186 I [1307/1698] thread_unknown cecadapter.cpp:271 (LogMessage) - CECAdapter: << Playback 1 (4) -> broadcast (F): active source (1000)
2019-05-31 08:53:32.887268 I [1307/1698] thread_unknown cecadapter.cpp:271 (LogMessage) - CECAdapter: << powering on 'TV' (0)
2019-05-31 08:53:32.942048 I [1307/1698] thread_unknown cecadapter.cpp:271 (LogMessage) - CECAdapter: << Playback 1 (4) -> broadcast (F): active source (1000)
2019-05-31 08:53:33.977101 I [1307/1698] thread_unknown cecadapter.cpp:271 (LogMessage) - CECAdapter: << Playback 1 (4) -> broadcast (F): active source (1000)
User avatar
bill6502
Developer
Posts: 2323
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Disable libcec in Mythwelcome

Post by bill6502 »

Thanks for testing. I suspect the fix needs to be applied similar to mythfrontend's version.
That is, ApplySettingsOverride gets called twice. Please add another call to before the Context
gets initialized:

Code: Select all

diff --git a/mythtv/programs/mythwelcome/main.cpp b/mythtv/programs/mythwelcome/main.cpp
index 5f5edcf9cd..6c1384cb8f 100644
--- a/mythtv/programs/mythwelcome/main.cpp
+++ b/mythtv/programs/mythwelcome/main.cpp
@@ -88,6 +88,8 @@ int main(int argc, char **argv)
 #endif
 
     gContext = new MythContext(MYTH_BINARY_VERSION, true);
+
+    cmdline.ApplySettingsOverride();
     if (!gContext->Init())
     {
         LOG(VB_GENERAL, LOG_ERR,
Builds and runs OK for me. You should then see two Setting 'libCECEnabled' being forced to '0'
lines.
trx-913
Newcomer
Posts: 8
Joined: Sun Mar 10, 2019 4:33 pm
United States of America

Re: Disable libcec in Mythwelcome

Post by trx-913 »

Adding a second ApplySettingsOverride() works.
Thank you very much.
User avatar
bill6502
Developer
Posts: 2323
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Disable libcec in Mythwelcome

Post by bill6502 »

Pushed to v30 this date.
Post Reply