SageTV Community

SageTV Community (http://forums.sagetv.com/forums/index.php)
-   SageTV Github Development (http://forums.sagetv.com/forums/forumdisplay.php?f=53)
-   -   DVB-S2 Scanning and tuning (http://forums.sagetv.com/forums/showthread.php?t=63131)

echoes 04-12-2016 02:40 PM

DVB-S2 Scanning and tuning
 
I've made some changes in this pull request to enable DVB-S scanning and DVB-S2 tuning on 64-bit Linux.

I would be grateful for any review, comments or help from anyone who is familiar with the DVBCapture library. I can only test this on the hardware I have (A Hauppauge NOVA-HD-S2 card, on which I have it working), but it would be better if it could be tested on more hardware.

It's my aim to get the open-source SageTV working on 64-bit Linux to the same functionality as I had on 32-bit Windows XP with my DVB cards. So far it's the DVB-S(2) tuning and config which has been problematic.

Many thanks,

echoes

wubdich 04-12-2016 03:23 PM

Quote:

Originally Posted by echoes (Post 587425)
[..]It's my aim to get the open-source SageTV working on 64-bit Linux to the same functionality as I had on 32-bit Windows XP with my DVB cards.[..]

I will switch to Linux as soon as Satellite Channel Routing / Single Cable Distribution (SCR/CSS CENELEC EN50494) is available. I talked to DigitalDevices, then company building my DVB-S2 card, because on Windows SCR support is done by device driver. Unfortunately they told me on linux application software has to take care by itself.

echoes 04-12-2016 04:49 PM

Quote:

Originally Posted by wubdich (Post 587429)
I will switch to Linux as soon as Satellite Channel Routing / Single Cable Distribution (SCR/CSS CENELEC EN50494) is available. I talked to DigitalDevices, then company building my DVB-S2 card, because on Windows SCR support is done by device driver. Unfortunately they told me on linux application software has to take care by itself.

At first glance that might be feasible (for someone else to implement :) )provided that DiSeqC is used to select the transponder. I did come across this:
Code:

int  SageGetSatelliteTble( void* Capture, SAT_NAME *sat_name, int max_sat )
{
    //it's for DiSeqC, to be implemented soon.
        return 0;
}


echoes 04-12-2016 04:55 PM

LNB config file
 
I noticed that the following file is written holding my LNB configuration:
Code:

Digital-Conexant-CX24116-CX24118-0000-06-05-2-0.lnb
But the DVBCapture library code is looking for adapter0.cfg

As a workaround I used a soft link. Anyone know what is the 'correct' file name?

echoes

Narflex 04-13-2016 12:21 PM

Quote:

Originally Posted by echoes (Post 587439)
I noticed that the following file is written holding my LNB configuration:
Code:

Digital-Conexant-CX24116-CX24118-0000-06-05-2-0.lnb
But the DVBCapture library code is looking for adapter0.cfg

As a workaround I used a soft link. Anyone know what is the 'correct' file name?

echoes

This sounds very familiar. At one point we were using the linux video device name (adapter0) for storing configuration information like this. Then we modified things to use the actual device name (Digital-Conexant...) so they were more stable when devices were added/removed. Apparently that never got modified for the DVB code though.

However, that .lnb file looks like it was written by the Windows software because nothing in the Linux code will write out a .lnb file (but it's there in the Windows code). On Linux, it only reads the .cfg file instead. And I'm not sure if both of them store the same kind of information or not.

echoes 04-13-2016 05:57 PM

I found that the STV XML file determines the lnb filename, and configures a regexp replace on troublesome characters (replacing them with '-').

The .lnb file name was definitely produced by SageTV on Linux.

The .frq files use the 'adapterX-DVB-[C|T|S].frq pattern.

There is some code to copy the lnb file to the 'adapterX-X.lnb (bear with me) pattern whenever an encoder is opened in sage.DVBCaptureDevice.startEncoding)

Now the native c code is trying to open adapterX.cfg, so I've made a couple of changes (that you might see in a pull request soon):
1) Use the same regex replacement to find the .lnb file that the Java code wrote.
2) If found, copy the .lnb file to 'adapterX.cfg' and not 'adapterX-X.lnb'

I'm unsure if the file formats of the .lnb and .cfg are exactly the same, but on my system this now works - the contents of the .cfg file are successfully used to determine the Intermediate Frequencies for the native DVB-S tune. So that's OK!

Are the native .cfg files used for any other purposes other than supplying LNB info?

Thanks for your help!

Since code is worth a thousand words...
Before:
Code:

  public void startEncoding(CaptureDeviceInput cdi, String encodeFile, String channel) throws EncodingException
  {
    if (Sage.DBG) System.out.println("startEncoding for DVB capture device file=" + encodeFile + " chan=" + channel);

    // Rename the .lnb file properly if its been set
    java.io.File lnbFile = new java.io.File(captureDeviceName + "-" + captureDeviceNum + ".lnb");
    if (lnbFile.isFile())
    {
      java.io.File targetFile = new java.io.File(new java.io.File(linuxVideoDevice).getName() + "-" + captureDeviceNum + ".lnb");
      if (Sage.DBG) System.out.println("Copying LNB file to device specific name from " + lnbFile + " to " + targetFile);
      try
      {
        IOUtils.copyFile(lnbFile, targetFile);
      }
      catch (java.io.IOException ioe)
      {
        if (Sage.DBG) System.out.println("ERROR Failed copying LNB file for video device of:" + ioe);
      }
    }
    ...

After:
Code:

  public void startEncoding(CaptureDeviceInput cdi, String encodeFile, String channel) throws EncodingException
  {
    if (Sage.DBG) System.out.println("startEncoding for DVB capture device file=" + encodeFile + " chan=" + channel);

    // Rename the .lnb file properly if its been set
    String lnbFilename = (captureDeviceName + "-" + captureDeviceNum).replaceAll("[^A-Za-z0-9_-]", "-") + ".lnb";
    File lnbFile = new java.io.File(lnbFilename);
    if (lnbFile.isFile())
    {
      //java.io.File targetFile = new java.io.File(new java.io.File(linuxVideoDevice).getName() + "-" + captureDeviceNum + ".lnb");
      File targetFile = new File(new File(linuxVideoDevice).getName() + ".cfg");
      if (Sage.DBG) System.out.println("Copying LNB file to device specific name from " + lnbFile + " to " + targetFile);
      try
      {
        IOUtils.copyFile(lnbFile, targetFile);
      }
      catch (java.io.IOException ioe)
      {
        if (Sage.DBG) System.out.println("ERROR Failed copying LNB file for video device of:" + ioe);
      }
    }


Narflex 04-14-2016 01:18 PM

Lol...yeah, I forgot to look at the Java and STV code...I forgot we did stuff to modify those files in there too. :)

I really don't know what we had in the .cfg or the .lnb files...that was written by Qian, not myself. I'll send him an email and ask him if he remembers.

echoes 04-14-2016 02:01 PM

That's appreciated!

Yeah, that file name took some finding with some increasingly desperate grepping...

Narflex 04-18-2016 11:34 AM

This was the answer I got, hopefully this helps:

a .cfg file is a configuration file that is given to a satellite LNB device to scan DVB-s channel by iterating directions and channel frequencies.

a .lnb file has LNB data that are used to control LNB device to pick up a direction to lock up a frequency.

echoes 04-18-2016 12:32 PM

That's good to know. Looks like it just needed consistent naming in the java, stv and native code. I'll submit a pull request soon.
Many thanks.

echoes 05-18-2016 07:08 AM

Update: I've tested this with another DVB-S2 tuner card: DVBSky S952 V3 with no problems.

I've had some trouble with a DVB-S channel scan on Linux64. I will be trying to get this working in the near future. I'm wondering if anyone else has been able to channel scan DVB-S(2) using Sage 9.x on Linux-64 successfully?

A couple of scanning questions:
1) Does the channel scanner use the NIT table to generate tuning information?
2) Are these modulation value mappings correct and consistent:
30 = DVB-S2, QPSK
31 = DVB-S2, QPSK
32 = DVB-S2, 8PSK

I can see some use of '30' being used for either 8PSK or QPSK, depending on where I look. e.g. line 485 of DVBPSIParser.c (UnpackNIT) assigns '30' for 8PSK/DVB-S2.

Narflex 05-18-2016 11:37 AM

Sorry, don't know those answers....I'm sure you've already used grep to try to figure out more, that's what I'd be doing. :) If you really get stuck, let me know and I'll ping the dev that wrote that code to see if he recalls how it works...but I try not to bother him too much.

echoes 05-18-2016 01:09 PM

No worries! I'll have a play with it and see what I can figure out.

Rich.

echoes 05-23-2016 03:09 AM

Been playing around with the DVB-S scan and discovered the following issues:
1) Could not get a scan to start unless the mmc/dvbs_region property was set (in my case to "Astra (28.2)"). I couldn't find anywhere where this property was set in code or STV. I think this property should be more properly picked up from the .lnb / .cfg file though.
2) The scan does use the NIT information to determine the subsequent tuning frequencies.
3) On first look, the DVB-S/S2 and modulation bits in the NIT descriptors are not being interpreted correctly. More investigation needed here.

Just an update for now.

Rich

Narflex 05-23-2016 11:45 AM

It looks like we have code in the STV for setting the region for DVBT and DVBC...but apparently not for DVBS. I'm not sure why it was done that way....

echoes 05-23-2016 12:58 PM

I'm guessing that the region may have multiple values in case of a diseqc setup. In which case the region, along with the rest of the LNB config would be in sections of the the lnb/cfg file for that adapter. It always worked for me on Windows with v7. Perhaps the Windows native code does things a bit differently. More things to check...

R

echoes 05-23-2016 04:23 PM

Some progress :)
Have got the DVBPSIParser to correctly read the modulation type and modulation system bits, as defined in the DVB BlueBook A038 Oct 2015 (a thoroughly riveting bedtime read) and map them to the integer values which Sage uses for tuning:
DVB-S:
1 (16QAM), 20 (QPSK), 22 (8PSK)
DVB-S2:
31 (QPSK), 32 (8PSK)

The tuneDVBSFrequency function then maps these values to the required API constants.

I've got this to do a full channel scan, and all the expected DVB-S and DVB-S2 entries in the NIT were scanned and tested - so now I have a complete, SageV9-produced DVBS frq file for the first time. I assume a DVB-S only card will just refuse to tune a DVB-S2 tuning entry - but that would seem natural.

Next I'll investigate the DVB-S region setting and see how that should be read. But that's for another day. :coffee:

R

Narflex 05-24-2016 11:16 AM

Great work!

starfire 08-31-2017 12:20 PM

Just found this thread, thanks for the work on this - I've been trying to get my TBS 8921 working, see https://forums.sagetv.com/forums/showthread.php?t=64961

After setting mmc/dvbs_region to "Astra (28.2)" I could get sage to actually start a scan but it immediately crashes :(

./startsagecore: line 55: 114 Aborted java -Djava.awt.headless=$HEADLESS $JAVAMEM -XX:+UseAdaptiveSizePolicy -XX:MaxGCPauseMillis=25 -XX:GCTimeRatio=24 $(if [[ $EUID -eq 0 ]]; then echo '-XX:ThreadPriorityPolicy=1'; fi) $JAVAOPTS -cp Sage.jar:JARs/lucene-core-3.6.0.jar:/:$(echo JARs/*.jar | sed 's/ */:/g') sage.Sage 0 0 x "sagetv Sage.properties" 0>&-

Cannot see any dump file or useful data in native.log or sagetv_0.txt to help me debug it any further.

echoes 08-31-2017 01:09 PM

Hi starfire,

This sounds familiar. I remember encountering something like this, and I did manage to fix it, but with the day job taking over, I didn't get round to committing the code. From memory, the scan terminated immediately, but didn't terminate the process, but details are hazy. I'll see if my fix will merge into the code as soon as I get a chance.

Echoes


All times are GMT -6. The time now is 11:30 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.