TBS: CI/CAM support and other improvements (4 Viewers)

mm1352000

Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    Anyway, here is a new build. I couldn't find any usage of this function in relation to ci menus so it is a wild guess what I did...
    Sounds like fun! :D
    I'm off to bed now (or very soon), but flick me a PM if you want to arrange to work on this together. I see some more budding developer skills... :D
     

    FreakyJ

    Retired Team Member
  • Premium Supporter
  • July 25, 2010
    4,024
    1,420
    Home Country
    Germany Germany
    I'm off to bed now (or very soon), but flick me a PM if you want to arrange to work on this together. I see some more budding developer skills...
    thanks for the kind words :)
    But I see no way to test it.. I will try my luck and if I get stuck I will shout loud for your help :)

    @doctor64
    I couldn't resist and installed my provided build locally. I can see äöü (my native language is German) now the question does it also work with your language?!
    I have no Cam from the Ukraine :D

    Edit:
    3-08-10 18:20:28,485] [Log ] [Turbosight MMI handler] [DEBUG] - Turbosight: menu
    [2013-08-10 18:20:28,486] [Log ] [Turbosight MMI handler] [DEBUG] - title = –AlphaCrypt 3.23 (c) Mascom GmbH
    [2013-08-10 18:20:28,486] [Log ] [Turbosight MMI handler] [DEBUG] - sub-title = Module Hauptmenu
    [2013-08-10 18:20:28,486] [Log ] [Turbosight MMI handler] [DEBUG] - footer = Bitte wählen Sie mit OK
    [2013-08-10 18:20:28,486] [Log ] [Turbosight MMI handler] [DEBUG] - # entries = 6
    [2013-08-10 18:20:28,486] [Log ] [Turbosight MMI handler] [DEBUG] - entry 1 = Information
    [2013-08-10 18:20:28,487] [Log ] [Turbosight MMI handler] [DEBUG] - entry 2 = Smartkarte
    [2013-08-10 18:20:28,487] [Log ] [Turbosight MMI handler] [DEBUG] - entry 3 = Nachrichten
    [2013-08-10 18:20:28,487] [Log ] [Turbosight MMI handler] [DEBUG] - entry 4 = Jugendschutz
    [2013-08-10 18:20:28,487] [Log ] [Turbosight MMI handler] [DEBUG] - entry 5 = Einstellungen
    [2013-08-10 18:20:28,487] [Log ] [Turbosight MMI handler] [DEBUG] - entry 6 = Zurück
    [2013-08-10 18:20:28,503] [Log ] [Turbosight MMI handler] [DEBUG] - Turbosight: resuming polling...

    Edit:
    But for me it is also working with the initial patch :/

    3-08-10 18:24:26,400] [Log ] [Turbosight MMI handler] [DEBUG] - Turbosight: menu
    [2013-08-10 18:24:26,400] [Log ] [Turbosight MMI handler] [DEBUG] - title = –AlphaCrypt 3.23 (c) Mascom GmbH
    [2013-08-10 18:24:26,401] [Log ] [Turbosight MMI handler] [DEBUG] - sub-title = Module Hauptmenu
    [2013-08-10 18:24:26,401] [Log ] [Turbosight MMI handler] [DEBUG] - footer = Bitte wählen Sie mit OK
    [2013-08-10 18:24:26,401] [Log ] [Turbosight MMI handler] [DEBUG] - # entries = 6
    [2013-08-10 18:24:26,403] [Log ] [Turbosight MMI handler] [DEBUG] - entry 1 = Information
    [2013-08-10 18:24:26,404] [Log ] [Turbosight MMI handler] [DEBUG] - entry 2 = Smartkarte
    [2013-08-10 18:24:26,405] [Log ] [Turbosight MMI handler] [DEBUG] - entry 3 = Nachrichten
    [2013-08-10 18:24:26,405] [Log ] [Turbosight MMI handler] [DEBUG] - entry 4 = Jugendschutz
    [2013-08-10 18:24:26,405] [Log ] [Turbosight MMI handler] [DEBUG] - entry 5 = Einstellungen
    [2013-08-10 18:24:26,405] [Log ] [Turbosight MMI handler] [DEBUG] - entry 6 = Zurück
    [2013-08-10 18:24:26,459] [Log ] [Turbosight MMI handler] [DEBUG] - Turbosight: resuming polling..

    Edit3:
    Which is you system language? If it is english my last patch probably won't work :/ If it is Ukraine it will hopefully work^^
     
    Last edited:

    FreakyJ

    Retired Team Member
  • Premium Supporter
  • July 25, 2010
    4,024
    1,420
    Home Country
    Germany Germany
    another update: I added a log line:

    [2013-08-10 18:32:40,127] [Log ] [Turbosight MMI handler] [INFO ] - Encoding used: 28595
     

    Attachments

    • Release.rar
      198.7 KB

    doctor64

    Portal Member
    December 6, 2009
    40
    9
    50
    Home Country
    Ukraine Ukraine
    Thanks mm for the hint, here is the try^^


    maybe you should take a look at the src your self xDD
    Unfortunately, i'm plain C/C++ developer for embedded platform/Linux, and have almost none knowledge about .Net and Windows development. Of course, i'm try to do something, but right now i able to switch CAM to english, using manual decode method described above ;)

    If somebody with Volia (Kiev) CAM interested - just select 2 (Settings) 1 (Language) 1 (English) from first CAM menu.

    Sorry, still no progress.
    [Turbosight MMI handler] [DEBUG] - Turbosight: menu
    [Turbosight MMI handler] [DEBUG] - title = ☺??O?
    [Turbosight MMI handler] [DEBUG] - sub-title = ☺AO?OaoeYi U?O? ??UiaiU?
    [Turbosight MMI handler] [DEBUG] - footer = ☺??aOaYoai ?? - OONa?aO, Exit - OOUaO
    [Turbosight MMI handler] [DEBUG] - # entries = 3
    [Turbosight MMI handler] [DEBUG] - entry 1 = ☺АYOUoUaiU?
    [Turbosight MMI handler] [DEBUG] - entry 2 = ☺??UiaiU?
    [Turbosight MMI handler] [DEBUG] - entry 3 = ☺??UiaiU? (U?aOYO?i)


    screen3.png

    Attached TVService.log with different menus
     

    doctor64

    Portal Member
    December 6, 2009
    40
    9
    50
    Home Country
    Ukraine Ukraine
    sorry, i'm did'nt see your latest comment. Anyway, thank you for you work!
    Here is log from latest build, still garbage in places of Cyrillic.
    TVService.log

    About system locale: system is Win 7, English language selected as system interface, but system locale (Control Panel - Clock, Language, and Region - Regional and Language Options - Administrative tab - Language for non-Unicode programs (System Locale) ) set to Russian (Russia).
    So i have english language in menu, programs, etc, but able to input and view Cyrillic characters. And MediaPortal itself can output Cyrillic without problems. for example: - (first channels in channel list a cyrillic (Ukrainian)
    screen4.png
     

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    Hmmm, I wonder if this is partially a display issue.
    @doctor64
    Are you testing from MP or TV Server configuration? MP is more likely to show text properly.
    If I've understood the situation correctly, the log files currently can't show the text properly as they are not UTF-8.
     

    FreakyJ

    Retired Team Member
  • Premium Supporter
  • July 25, 2010
    4,024
    1,420
    Home Country
    Germany Germany
    Okay I made some progress:
    In the old code there we took every byte once after another and cast it as char (unicode). I changed it now that we collect the bytes in a new byte array until we get to the delimiter which is 0. Now I can take the byte array and convert it to a string using a specific encoding.

    The question is now how can I determine which is the src encoding of the cam?!
    eg. I now have something like this:
    ntries.Add(System.Text.Encoding.Default.GetString(entryArray, 0, entryArray.Length));
    Default uses the system encoding, the problem: if the cam uses something different than the system we get garbage.
    Also if I assume that we get UTF-8 and the Cam sends ASCII we get again garbage :/ At least I didn't got a reasonable result as I used UTF-8. I even don't know which encoding my cam is sending...

    my current code:
    Code:
    List<string> entries = new List<string>();
    				byte[] entryArray = null;
    				string entry = string.Empty;
    				int entryCount = 0;
     
    				for (int i = 1; i < length; i++)
    				{
    					if (content[i] == 0)
    					{
    					  //TvLibrary.Log.Log.Debug("OK3");
    					  //IntPtr unmanagedPointer = Marshal.AllocHGlobal(entryArray.Length);
    					  //Marshal.Copy(entryArray, 0, unmanagedPointer, entryArray.Length);
    					  //entry += DvbTextConverter.Convert(unmanagedPointer, "");
    					  entry += System.Text.Encoding.ASCII.GetString(entryArray, 0, entryArray.Length);
    					  //TvLibrary.Log.Log.Debug("OK4");
    					  entries.Add(entry);
    						entryCount++;
    						entry = string.Empty;
    						entryArray = null;
    					}
    					else
    					{
    						//if ((content[i] >= 32 && content[i] <= 126) || (content[i] >= 192 && content[i] <= 255))
    						//{
    					  if (entryArray != null)
    					  {
    						//TvLibrary.Log.Log.Debug("OK1");
    						byte[] newArray = new byte[entryArray.Length + 1];
    						//TvLibrary.Log.Log.Debug("OK1.1");
    						entryArray.CopyTo(newArray, 0);
    						//TvLibrary.Log.Log.Debug("OK1.2");
    						newArray[newArray.Length - 1] = content[i];
    						//TvLibrary.Log.Log.Debug("OK1.3");
    						entryArray = newArray;
    					  }
    					  else
    					  {
    						entryArray = new byte[1];
    						entryArray[0] = content[i];
    					  }
    					  TvLibrary.Log.Log.Debug("OK2");
    						//}
    						//else
    						//{
    						//	entry += ' ';
    						//}
    					}
    				}
    				entries.Add(System.Text.Encoding.Default.GetString(entryArray, 0, entryArray.Length));

    any inputs?!
     
    Last edited:

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    The question is now how can I determine which is the src encoding of the cam?!
    If you take a look at the DvbTextConverter class that I pointed to I think you'll see the answer.
    An easier solution might be to do something like this (code not compiled or checked):

    Code:
    				List<string> entries = new List<string>();
     
    				List<byte> entryBytes = new List<byte>();
     
    				int entryCount = 0;
     
     
     
    				for (int i = 1; i < length; i++)
     
    				{
     
    					if (content[i] == 0)
     
    					{
    					  IntPtr p = Marshal.AllocCoTaskMem(entryBytes.Count + 1);
    					  Marshal.Copy(entryBytes.ToArray(), 0, p, entryBytes.Count);
    					  Marshal.WriteByte(p, entryBytes.Count, 0);
    					  DVB_MMI.DumpBinary(p, 0, entryBytes.Count);  // for debug showing the byte values
    					  entries.Add(DvbTextConverter.Convert(p, null));
    					  entryCount++;
    					  entryBytes.Clear();
    					  Marshal.FreeCoTaskMem(p);
    					}
    					else
     
    					{
    					  entryBytes.Add(content[i]);
     
    					}
     
    				}

    Note:
    1. You'll need to also add handling for the last entry.
    2. I would never commit this to TVE 3.5. Instead I'd refactor DvbTextConverter to provide a method that accepts a byte[].



    Default uses the system encoding, the problem: if the cam uses something different than the system we get garbage.

    Also if I assume that we get UTF-8 and the Cam sends ASCII we get again garbage :/ At least I didn't got a reasonable result as I used UTF-8. I even don't know which encoding my cam is sending...
    The first byte of each entry tells you the encoding. DvbTextCoverter handles all of that, which is why I suggested to use it. ;)
     

    FreakyJ

    Retired Team Member
  • Premium Supporter
  • July 25, 2010
    4,024
    1,420
    Home Country
    Germany Germany
    The first byte of each entry tells you the encoding. DvbTextCoverter handles all of that, which is why I suggested to use it.

    I had a look on the class, but my thinking was that only the first byte of the whole response has the encoding. Didn't know that every Menu entry has the encoding at the beginning... So I thought I'm adding the bytes to an array and the first letter is treated as encoding, what would be obviously wrong oO


    An easier solution might be to do something like this (code not compiled or checked):
    That is basically exact what I already tried, the only difference between your solution and my is:
    IntPtr p = Marshal.AllocCoTaskMem(entryArray.Length + 1);
    this was my code:
    //IntPtr unmanagedPointer = Marshal.AllocHGlobal(entryArray.Length);
    //Marshal.Copy(entryArray, 0, unmanagedPointer, entryArray.Length);
    //entry += DvbTextConverter.Convert(unmanagedPointer, "");

    I had to replace all your .count with .length, because a byte array doesn't support count.
    the current code:
    Code:
    IntPtr p = Marshal.AllocCoTaskMem(entryArray.Length + 1);
    						Marshal.Copy(entryArray, 0, p, entryArray.Length);
    						Marshal.WriteByte(p, entryArray.Length, 0);
    						DVB_MMI.DumpBinary(p, 0, entryArray.Length);  // for debug showing the byte values
    						entries.Add(DvbTextConverter.Convert(p, null));
    						entryCount++;
    						entry = string.Empty;
    						entryArray = null;
    						Marshal.FreeCoTaskMem(p);
    I also added this for the last entry, binaries attached :)

    Result:
    [2013-08-11 12:51:12,643] [Log ] [Turbosight MMI handler] [DEBUG] - title = –AlphaCrypt 3.23 (c) Mascom GmbH
    [2013-08-11 12:51:12,643] [Log ] [Turbosight MMI handler] [DEBUG] - sub-title = Module Hauptmenu
    [2013-08-11 12:51:12,643] [Log ] [Turbosight MMI handler] [DEBUG] - footer = Bitte wählen Sie mit OK
    [2013-08-11 12:51:12,643] [Log ] [Turbosight MMI handler] [DEBUG] - # entries = 6
    [2013-08-11 12:51:12,645] [Log ] [Turbosight MMI handler] [DEBUG] - entry 1 = Information
    [2013-08-11 12:51:12,646] [Log ] [Turbosight MMI handler] [DEBUG] - entry 2 = Smartkarte
    [2013-08-11 12:51:12,647] [Log ] [Turbosight MMI handler] [DEBUG] - entry 3 = Nachrichten
    [2013-08-11 12:51:12,647] [Log ] [Turbosight MMI handler] [DEBUG] - entry 4 = Jugendschutz
    [2013-08-11 12:51:12,647] [Log ] [Turbosight MMI handler] [DEBUG] - entry 5 = Einstellungen
    [2013-08-11 12:51:12,647] [Log ] [Turbosight MMI handler] [DEBUG] - entry 6 = Zurück
    but for me also the old version worked, so @doctor64 please test the attached binaries :)
     

    Attachments

    • Release.rar
      198.5 KB
    Last edited:

    Users who are viewing this thread

    Top Bottom