Bug - Terrestrial USB tuner identified as non-terrestrial

Moderators: Gully, peteru

Grumpy_Geoff
Uber Wizard
Posts: 6490
Joined: Thu Mar 05, 2009 22:54
Location: Perth

Re: Bug - Terrestrial USB tuner identified as non-terrestrial

Post by Grumpy_Geoff » Thu Apr 26, 2018 23:18

IanSav wrote:
Thu Apr 26, 2018 23:04
Hi,

Before people start becoming litigious perhaps my suggestion to look at the code contribution to OpenViX, https://github.com/OpenViX/enigma2/pull/254, may address this issue for the Beyonwiz as well.

Regards,
Ian.

I've no idea, but from my brief look at that it is selecting from a dual tuner, not from a single tuner that may sometimes present multi-modes depending on celestial mechanics.

Also it has a comment re. selecting DVB-S2 which won't help us.

IanSav
Uber Wizard
Posts: 16846
Joined: Tue May 29, 2007 15:00
Location: Melbourne, Australia

Re: Bug - Terrestrial USB tuner identified as non-terrestrial

Post by IanSav » Thu Apr 26, 2018 23:22

Hi Grumpy_Geoff,

I believe the code is attempting to select the correct operating mode from a device that supports multiple modes. (What those modes actually are do not matter.)

Regards,
Ian.

Paul_oz53
Wizard
Posts: 2789
Joined: Sat Jun 13, 2009 02:34
Location: Melbourne

Re: Bug - Terrestrial USB tuner identified as non-terrestrial

Post by Paul_oz53 » Fri Apr 27, 2018 01:30

AFAIK, the only reliable way to ensure one doesn't lose out in 'tuner lotto' is to put the T2/T3 to standby instead of allowing it to go to shutdown, and to monitor the tuner mode upon UI restart or attended system reboot.
This is probably why I don't see it - I only ever use standby with the T3. This was because on shutdowns the T3 was losing the HDD. Apparently a bug in the front panel firmware.
__________________________________
Paul
Beyonwiz T4, 2 x U4: FW - 19.3 20211010
Samsung QA85Q80BAWXXY 4K TV
Samsung QA65Q80TAWXXY 4K TV
Samsung HW Q800BXY soundbar
OverlayHD 1.70, IceTV, Foxtel IQ4
2 x Win7 PCs, 2 x Win10 PCs
Denon AVR -X2400H

dRdoS7
Wizard
Posts: 1101
Joined: Tue Sep 22, 2015 11:47

Re: Bug - Terrestrial USB tuner identified as non-terrestrial

Post by dRdoS7 » Fri Apr 27, 2018 09:40

Paul_oz53 wrote:
Fri Apr 27, 2018 01:30
AFAIK, the only reliable way to ensure one doesn't lose out in 'tuner lotto' is to put the T2/T3 to standby instead of allowing it to go to shutdown, and to monitor the tuner mode upon UI restart or attended system reboot.
This is probably why I don't see it - I only ever use standby with the T3. This was because on shutdowns the T3 was losing the HDD. Apparently a bug in the front panel firmware.

Always use Standby for our T2s. Shutdown/Reboot when there's a FW update, new/updated patches, or a lockup. All fairly rare on my wife's T2, which is why I don't get "the stupid box won't record all my programs" called out from the other room. :lol:

dRdoS7

prl
Wizard God
Posts: 32705
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: Bug - Terrestrial USB tuner identified as non-terrestrial

Post by prl » Fri Apr 27, 2018 18:13

Grumpy_Geoff wrote:
Thu Apr 26, 2018 23:18
IanSav wrote:
Thu Apr 26, 2018 23:04
Hi,

Before people start becoming litigious perhaps my suggestion to look at the code contribution to OpenViX, https://github.com/OpenViX/enigma2/pull/254, may address this issue for the Beyonwiz as well.

Regards,
Ian.

I've no idea, but from my brief look at that it is selecting from a dual tuner, not from a single tuner that may sometimes present multi-modes depending on celestial mechanics.

Also it has a comment re. selecting DVB-S2 which won't help us.

And not only that, but the kernel is presenting a list of capabilities where none are actual capabilities of the tuner. E.g. from Grumpy_Geoff's earlier post:

Code: Select all

NIM Socket 2:
        Type: DVB-T
        Name: RTL2838UHIDIR
        Mode 6: DVB-T2
        Mode 2: DVB-C
        Frontend_Device: 2
        I2C_Device: 843863122
The device is a DVB-T tuner, not DVB-T2 or DVB-C.
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

Grumpy_Geoff
Uber Wizard
Posts: 6490
Joined: Thu Mar 05, 2009 22:54
Location: Perth

Re: Bug - Terrestrial USB tuner identified as non-terrestrial

Post by Grumpy_Geoff » Tue May 08, 2018 12:27

I have the below snippet as part of my enigma2_pre_start.sh script to detect if the USB tuner is in the wrong mode -

Code: Select all

  ## restart UI if non-Terrestrial
  awk '/NIM Socket 2:/ {USBtuner = 1}; \
       USBtuner && /Mode [0-9]: DVB-/ { if($0 !~ /DVB-T/) {print "*** non-Terrestrial USB tuner type, restarting UI"; exit 99}; exit}' /proc/bus/nim_sockets; \
  RC=$?; echo -e "awk RC: $RC"; \
  if [ $RC -eq 99 -a -f /home/root/Allow_UI_Restart ] ; then echo "*** about to restart"; wget -q -O - http://192.168.1.63/web/powerstate?newstate=3; fi; \

When I execute that wget command from the command line it executes and restarts the UI okay as intended (I get a "wget: error getting response" and I'm guessing that's because the UI is restarting and the web server is no longer active).

Yesterday the T2 started with the USB tuner in satelite mode -

Code: Select all

NIM Socket 2:
	Type: DVB-T
	Name: RTL2832U
	Mode 4: DVB-S2
	Frontend_Device: 2
	I2C_Device: 843863122
When that wget command was executed from within my enigma2_pre_start.sh script the log contained -

Code: Select all

*** non-Terrestrial USB tuner type, restarting UI
awk RC: 99
*** about to restart
<?xml version="1.0" encoding="UTF-8"?>
<e2powerstate>
	<e2instandby>
false	</e2instandby>
</e2powerstate>
That xml response string is exactly the same if I enter the query without the action (or whatever you call it) on the command line -

Code: Select all

root@beyonwizt2:~# wget -q -O - http://192.168.1.63/web/powerstate
<?xml version="1.0" encoding="UTF-8"?>
<e2powerstate>
        <e2instandby>
false   </e2instandby>
</e2powerstate>
root@beyonwizt2:~#
So it appears to me that ?newstate=3 wasn't passed to wget. Do I need to escape the "?" in that wget call in the script?
Is there some other way I should be specifying this?

Cheers,
Geoff

prl
Wizard God
Posts: 32705
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: Bug - Terrestrial USB tuner identified as non-terrestrial

Post by prl » Tue May 08, 2018 16:07

Since the "?" character is a filename expansion metacharacter (match any single character), it would probably be a good idea to escape it. If there's no filename expansion match, the unaltered string is passed to the program by the shell, so it is likely to work, even if not as safe as it could be.

Also, why not use the generic IP address that means "the computer I'm running on": 127.0.0.1 or localhost? So something like this safer and more generic:

wget -q -O - 'http://localhost/web/powerstate?newstate=3'

My main problem with it is that I can't see how it could ever work at UI startup, because the OpenWebif server only runs when enigma2 is running, and at the time that, as its name suggests, enigma2_pre_start.sh runs, enigma2 isn't yet running.

E.g:

Code: Select all

root@beyonwizu4:/media/hdd/logs# init 4  # shut down enigma2
root@beyonwizu4:/media/hdd/logs# wget -q -O - 'http://localhost/web/powerstate?newstate=3'
wget: can't connect to remote host (127.0.0.1): Connection refused
root@beyonwizu4:/media/hdd/logs# 
Also, stylistically, and for readability, you might want something like:

Code: Select all

#!/bin/sh

exec >> /tmp/pre_start.txt 2>&1

## restart UI if non-Terrestrial
awk '/NIM Socket 2:/ {USBtuner = 1}
    USBtuner && /Mode [0-9]: DVB-/ {
        if($0 !~ /DVB-T/) {
	    print "*** non-Terrestrial USB tuner type, restarting UI"
	    exit 99
        }
    }' /proc/bus/nim_sockets

RC=$?
echo -e "awk RC: $RC"

if [ $RC -eq 99 -a -f /home/root/Allow_UI_Restart ] ; then
    echo "*** about to restart"
    wget -q -O - 'http://localhost/web/powerstate?newstate=3'
fi
Both in the shell script and in the awk script,

Code: Select all

something; \
otherthing
in most cases will do the same thing as:

Code: Select all

something
otherthing
De gustibus non est disputandum, of course :)
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

Grumpy_Geoff
Uber Wizard
Posts: 6490
Joined: Thu Mar 05, 2009 22:54
Location: Perth

Re: Bug - Terrestrial USB tuner identified as non-terrestrial

Post by Grumpy_Geoff » Tue May 08, 2018 17:17

Thanks Peter.
I'll try with quoting the URL restart parameter to wget - I think that's the missing link :)

The pre-start script gets called, and my stuff is then executed in a sub-shell in the background so as to not hold up the UI starting up. I got that bit from you, as I did some awk that I still have in the script :)
By the time the wget commands get to run, enigma2 has started, and the webserver has also started. The full script as currently executing is shown below. As you can see, it's been cobbled together over time!

Code: Select all

root@beyonwizt2:~# cat /usr/bin/enigma2_pre_start.sh
#!/bin/sh
( (echo -e "\n\n=> $(date -Iseconds)"; cat /proc/bus/nim_sockets) >> /media/hdd/logs/nim_sockets_bootup_0secs.txt; \
  (sleep 5; echo -e "\n\n=> $(date -Iseconds)"; cat /proc/bus/nim_sockets) >> /media/hdd/logs/nim_sockets_bootup_5secs.txt; \
  sleep 95; \
  echo -e "\n==> $(date -Iseconds)"; \
  ##grep -i vtuner /var/log/messages; \
  (echo -e "\n==> $(date -Iseconds)"; cat /proc/bus/nim_sockets) >> /media/hdd/logs/nim_sockets.txt; \
  awk '/NIM Socket 2:/ {printIt=1}; printIt' /proc/bus/nim_sockets; \
  wget -q -O - http://192.168.1.63/web/deviceinfo | \
    awk '{ \
           if(printNext) { print $0; printNext = 0 } \
         } \
         /<e2name>Tuner C<\/e2name>/ { print $0; printNext = 1 }'; \
  DbgPath=$(grep debug_path /etc/enigma2/settings); \
  if [ -n "$DbgPath" ] ; then DbgPath=$(echo $DbgPath | sed -e 's/config.crash.debug_path=//'); else DbgPath=/home/root/logs/; fi; \
  latestFile=$(ls -t ${DbgPath}Enigma2-201* | head -n 1);  \
  echo "==> $latestFile"; \
  grep '\[NimManager\]' $latestFile;
  ## restart UI if non-Terrestrial
  awk '/NIM Socket 2:/ {USBtuner = 1}; \
       USBtuner && /Mode [0-9]: DVB-/ { if($0 !~ /DVB-T/) {print "*** non-Terrestrial USB tuner type, restarting UI"; exit 99}; exit}' /proc/bus/nim_sockets; \
  RC=$?; echo -e "awk RC: $RC"; \
  if [ $RC -eq 99 -a -f /home/root/Allow_UI_Restart ] ; then echo "*** about to restart"; wget -q -O - http://192.168.1.63/web/powerstate?newstate=3; fi; \
) >> /media/hdd/logs/vtuner6.log 2>> /media/hdd/logs/vtuner_errs.log &
Apart from quoting the (wget) UI restart, and changing the IP address to localhost, what other changes would you suggest? Your comments are most welcome.


Cheers
Geoff

prl
Wizard God
Posts: 32705
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: Bug - Terrestrial USB tuner identified as non-terrestrial

Post by prl » Tue May 08, 2018 18:28

Grumpy_Geoff wrote:
Tue May 08, 2018 17:17
... I'll try with quoting the URL restart parameter to wget - I think that's the missing link :)

That seems unlikely to me. You could check by putting an echo http://localhost/web/powerstate?newstate=3 in the script to see whether there's any funny filename expansion going on.
Grumpy_Geoff wrote:
Tue May 08, 2018 17:17
...
Apart from quoting the (wget) UI restart, and changing the IP address to localhost, what other changes would you suggest? Your comments are most welcome.

Use more newlines. You don't actually need most of those " ; \<newline>" items. Just use a newline.

You don't need line continuation on most compound commands, provided it's clear that the command hasn't ended.

For example, all these things allow you to break up compound commands and make them more readable (the indenting isn't required, it's just for readability):

Code: Select all

(
   echo this
   echo that
)

echo this |
    cat

echo this &&
    echo that # and the same for ||
 
For compound statements, you can either use the style:

Code: Select all

 if <pipeline>
 then
     echo this
 else
     echo that
fi
or as I prefer:

Code: Select all

 if <pipeline>; then
     echo this
else
    echo that
fi
So, after that, something like this (untested!):

Code: Select all

#!/bin/sh

exec >> /media/hdd/logs/vtuner6.log 2>> /media/hdd/logs/vtuner_errs.log 
# Or exec >> /media/hdd/logs/vtuner6.log 2>&1 to put it in a single file

(
    (echo -e "\n\n=> $(date -Iseconds)"; cat /proc/bus/nim_sockets) >> /media/hdd/logs/nim_sockets_bootup_0secs.txt
    (sleep 5; echo -e "\n\n=> $(date -Iseconds)"; cat /proc/bus/nim_sockets) >> /media/hdd/logs/nim_sockets_bootup_5secs.txt

    sleep 95

    echo -e "\n==> $(date -Iseconds)"

    ##grep -i vtuner /var/log/messages

    (echo -e "\n==> $(date -Iseconds)"; cat /proc/bus/nim_sockets) >> /media/hdd/logs/nim_sockets.txt

    awk '/NIM Socket 2:/ {printIt=1}; printIt' /proc/bus/nim_sockets

    wget -q -O - http://192.168.1.63/web/deviceinfo |
          awk '{
                if(printNext) { print $0; printNext = 0 }
          }
          /<e2name>Tuner C<\/e2name>/ {
              print $0
              printNext = 1
          }'

    DbgPath=$(grep debug_path /etc/enigma2/settings)
    if [ -n "$DbgPath" ] ; then
        DbgPath=$(echo $DbgPath | sed -e 's/config.crash.debug_path=//')
    else
        DbgPath=/home/root/logs/
    fi

    latestFile=$(ls -t ${DbgPath}Enigma2-201* | head -n 1)
    echo "==> $latestFile"
    grep '\[NimManager\]' $latestFile;

    ## restart UI if non-Terrestrial
    awk '/NIM Socket 2:/ {USBtuner = 1}
         USBtuner && /Mode [0-9]: DVB-/ {
             if($0 !~ /DVB-T/) {
                 print "*** non-Terrestrial USB tuner type, restarting UI"; exit 99
             }
             exit
         }' /proc/bus/nim_sockets

    RC=$?; echo -e "awk RC: $RC"
    if [ $RC -eq 99 -a -f /home/root/Allow_UI_Restart ]; then
        echo "*** about to restart"
        wget -q -O - 'http://localhost/web/powerstate?newstate=3'
    fi
) &
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

Grumpy_Geoff
Uber Wizard
Posts: 6490
Joined: Thu Mar 05, 2009 22:54
Location: Perth

Re: Bug - Terrestrial USB tuner identified as non-terrestrial

Post by Grumpy_Geoff » Wed May 09, 2018 00:07

Thanks. I'm running with your ideas and formatting.
The tuner has come up as non-terrestrial four times in the last four weeks - so on that (bad) average, we'll only need to wait about a week to see if the quoting to the wget UI restart works.


Cheers,
Geoff

prl
Wizard God
Posts: 32705
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: Bug - Terrestrial USB tuner identified as non-terrestrial

Post by prl » Wed May 09, 2018 11:01

Glad to have been able to help, at least with readability. I'm still doubtful that the problem is in not quoting the wget URL.
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

Grumpy_Geoff
Uber Wizard
Posts: 6490
Joined: Thu Mar 05, 2009 22:54
Location: Perth

Re: Bug - Terrestrial USB tuner identified as non-terrestrial

Post by Grumpy_Geoff » Wed May 09, 2018 12:25

She works!
I added this bit to the end of the script to force/test a UI restart -

Code: Select all

    if [ $RC -eq 0 -a -f /home/root/Allow_UI_Restart ]; then
        echo "*** forcing a restart"
        wget -q -O - 'http://localhost/web/message?text=Pretending%20a%20bad%20USB%20tuner%20mode.%20%20Restarting%20GUI&type=3'
        echo "issuing command:"
        echo wget -q -O - http://localhost/web/powerstate?newstate=3
        wget -q -O - 'http://localhost/web/powerstate?newstate=3'
        echo "*** command issued"
    fi
The message appeared on the screen, and the UI restarted. The output contained -

Code: Select all

*** forcing a restart
<?xml version="1.0" encoding="UTF-8"?>
<e2simplexmlresult>
	<e2state>True</e2state>
	<e2statetext>Message sent successfully!</e2statetext>	
</e2simplexmlresult>
issuing command:
wget -q -O - http://localhost/web/powerstate?newstate=3
*** command issued
I let it restart twice before renaming the 'allow' file.

prl
Wizard God
Posts: 32705
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: Bug - Terrestrial USB tuner identified as non-terrestrial

Post by prl » Wed May 09, 2018 12:48

I can't see why, but as long as it works ...
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

Post Reply

Return to “Bug Reporting and Feature Requests”