Monkey Mode test function

Started by warrmr, 23. Nov 2008, 01:24

previous topic - next topic
Go Down

warrmr

I have managed to fine some kind of test mode in the Vision boxes that they call it Monkey mode. There are a few fetures outlined in the monkey.xml and I think that if we can get this mode enabled then that will enable us to record and pause TV but not record on shedule until we get the EPG running.

I have found the key combinations in the Source codes but cannot find the section of the code that waits for these combinations and calls on the functions associated with them.

The two code snippets are form the Monkey.xml file and the other is from the TV2.Test.monkey namespace from within the TV2 Client


Code: [Select]

public class Monkey
    {
        private static int _captureCount = 0;
        private static OnMsgArrived _captureDelegate = new OnMsgArrived(Monkey.CaptureHandler);
        private static DateTime _lastKeyTime = DateTime.MinValue;
        private static int _maxSleep = 0x3e8;
        private static int _minSleep = 200;
        private static MonkeyMode _mode = MonkeyMode.Default;
        private static bool _MonkeyActive;
        private static int _monkeyRandomSeed = 0;
        private static DateTime _monkeyStart = DateTime.MinValue;
        private static bool _once = false;
        private static StreamWriter _sw = null;
        private static Microsoft.TV2.TestScripter.TestScriptEngine _testScriptEngine;
        private static string[] keys = keys_default;
        private static string[] keys_default = new string[] {
            "channelup", "channeldown", "channelup", "channeldown", "channelup", "channeldown", "channelup", "channeldown", "channelup", "channeldown", "channelup", "channeldown", "up", "down", "left", "right",
            "up", "down", "left", "right", "up", "down", "left", "right", "up", "down", "left", "right", "raw,ch,0", "raw,ch,1", "raw,ch,2", "raw,ch,3",
            "raw,ch,4", "raw,ch,5", "raw,ch,6", "raw,ch,7", "raw,ch,8", "raw,ch,9", "raw,ch,backspace", "select", "select", "menu", "recordedtv", "guide", "guide", "skipback", "skipfwd", "back",
            "info", "UI.WatchTV", "UI.WatchTV", "UI.WatchTV", "ffwd", "rwd", "play", "pause", "ffwd", "rwd", "play", "pause", "ffwd", "rwd", "play", "pause",
            "rec", "pause", "mute"
         };
        private static string[] keys_dvr = new string[] {
            "channelup", "channeldown", "channelup", "channeldown", "channelup", "channeldown", "channelup", "channeldown", "channelup", "channeldown", "channelup", "channeldown", "select", "select", "menu", "recordedtv",
            "raw,ch,0", "raw,ch,1", "raw,ch,2", "raw,ch,3", "raw,ch,4", "raw,ch,5", "raw,ch,6", "raw,ch,7", "raw,ch,8", "raw,ch,9", "raw,ch,backspace", "guide", "guide", "skipback", "skipfwd", "back",
            "info", "UI.WatchTV", "UI.WatchTV", "UI.WatchTV", "ffwd", "rwd", "play", "pause", "ffwd", "rwd", "play", "pause", "ffwd", "rwd", "play", "pause",
            "rec", "pause"
         };
        private static string[] keys_navigation = new string[] {
            "up", "down", "left", "right", "up", "down", "left", "right", "up", "down", "left", "right", "up", "down", "left", "right",
            "select", "select", "menu", "recordedtv", "guide", "guide", "skipback", "skipfwd", "back", "info", "UI.WatchTV"
         };
        private static string[] keys_recordings = new string[] { "channelup", "channeldown", "channeldown", "select", "rec", "UI.WatchTV" };
        private static string[] keys_search = new string[] {
            "raw,ch,a", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,b", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,c", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,d", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace",
            "raw,ch,e", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,f", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,g", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,h", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace",
            "raw,ch,i", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,j", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,k", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,l", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace",
            "raw,ch,m", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,n", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,o", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,p", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace",
            "raw,ch,q", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,r", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,s", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,t", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace",
            "raw,ch,u", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,v", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,w", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,x", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace",
            "raw,ch,y", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,z", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,1", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,2", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace",
            "raw,ch,3", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,4", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,5", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,6", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace",
            "raw,ch,7", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,8", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,9", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,0", "raw,ch,backspace", "raw,ch,backspace", "raw,ch,backspace",
            "right", "left", "down", "up", "channelup", "channeldown"
         };
        private static string[] keys_sequence = new string[] {
            "guide", "menu", "guide", "down", "select", "down", "guide", "menu", "right", "select", "raw,ch,2", "raw,ch,2", "raw,ch,2", "raw,ch,2", "down", "down",
            "down", "select", "guide", "menu", "right", "right", "right", "down", "down", "select", "raw,ch,1", "raw,ch,1", "raw,ch,1", "raw,ch,1", "raw,ch,1", "raw,ch,1",
            "raw,ch,1", "raw,ch,1"
         };
        private static string[] keys_stayonpage = new string[] { "up", "down", "left", "right", "channelup", "channeldown" };
        private static string[] keys_timhack = new string[] { "menu", "guide" };
        private static string[] keys_trickmodes = new string[] {
            "channelup", "channeldown", "channelup", "channeldown", "channelup", "channeldown", "channelup", "channeldown", "channelup", "channeldown", "channelup", "channeldown", "UI.WatchTV", "skipback", "skipfwd", "raw,ch,0",
            "raw,ch,1", "raw,ch,2", "raw,ch,3", "raw,ch,4", "raw,ch,5", "raw,ch,6", "raw,ch,7", "raw,ch,8", "raw,ch,9", "raw,ch,backspace", "ffwd", "rwd", "play", "pause", "ffwd", "rwd",
            "play", "pause", "ffwd", "rwd", "play", "pause", "pause"
         };
        private static string[] keys_trickmodes2 = new string[] {
            "rwd", "ffwd", "noop", "noop", "noop", "noop", "noop", "noop", "noop", "noop", "noop", "noop", "noop", "noop", "noop", "noop",
            "noop", "noop", "noop", "noop", "noop", "noop", "noop", "noop", "noop", "noop"
         };
        private static string[] keys_tune = new string[] {
            "channelup", "channeldown", "channelup", "channeldown", "channelup", "channeldown", "channelup", "channeldown", "channelup", "channeldown", "channelup", "channeldown", "raw,ch,0", "raw,ch,1", "raw,ch,2", "raw,ch,3",
            "raw,ch,4", "raw,ch,5", "raw,ch,6", "raw,ch,7", "raw,ch,8", "raw,ch,9", "raw,ch,backspace", "up", "down", "left", "right", "up", "down", "left", "right", "raw,ch,0",
            "raw,ch,1", "raw,ch,2", "raw,ch,3", "raw,ch,4", "raw,ch,5", "raw,ch,6", "raw,ch,7", "raw,ch,8", "raw,ch,9", "raw,ch,backspace", "up", "down", "left", "right", "up", "down",
            "left", "right", "UI.WatchTV"
         };
   


Code: [Select]

<HorizontalFlowPanel>
<Text width="140" left="0" height="31" layout="center" margin="rect(10,10,0,0)">Monkey Mode:</Text>
<Spinner class="Spinner" left="10" margin="rect(10,10,0,0)" id="_modeSpinner">
<Text width="150" layout="center" class="Text.Spinner">Default</Text>
<Text width="150" layout="center" class="Text.Spinner">Recordings</Text>
<Text width="150" layout="center" class="Text.Spinner">Sequential</Text>
<Text width="150" layout="center" class="Text.Spinner">DVR</Text>
<Text width="150" layout="center" class="Text.Spinner">Trick Modes</Text>
<Text width="150" layout="center" class="Text.Spinner">Trick Modes2</Text>
          <Text width="150" layout="center" class="Text.Spinner">Tune</Text>
          <Text width="150" layout="center" class="Text.Spinner">TuneChupChdn</Text>
<Text width="150" layout="center" class="Text.Spinner">Navigation</Text>
<Text width="150" layout="center" class="Text.Spinner">Memory</Text>
<Text width="150" layout="center" class="Text.Spinner">Capture</Text>
<Text width="150" layout="center" class="Text.Spinner">Replay</Text>
<Text width="150" layout="center" class="Text.Spinner">Stay on Page</Text>
<Text width="150" layout="center" class="Text.Spinner">TimHack</Text>
<Text width="150" layout="center" class="Text.Spinner">Search</Text>
<Text width="150" layout="center" class="Text.Spinner">WMSLongPlay</Text>
<Text width="150" layout="center" class="Text.Spinner">WMSTrickMode</Text>
<Text width="150" layout="center" class="Text.Spinner">RDP</Text>
</Spinner>
</HorizontalFlowPanel>



redband

The monkey stuff is for automated testing.  Lets a tester simulate button presses etc to and  then script them.  The scripts can be stored on HDisk2 and loaded via the menu then executed...  the ones left behind on the box do stuff like navigate to onDemand menu and purchase a show over and over until told to stop...
So, yes, it can carry out the keystrokes to record, and pause faster and more frequently than a human could with a remote...  It will also throw up a banner on the top of the screen which tells you which button is being pressed.

is0-mick

#2
23. Nov 2008, 13:28 Last Edit: 23. Nov 2008, 13:40 by is0-mick
Saw the MonkeyMode a while ago, when playing with the demo menu, and it does seem to be for automated key presses as redband said.

The xray classes seem more interesting, and suggest some kind of CLI interface.

If you look in the XRAY.CS section of the code

there is a line which sets the an IP to 127.0.0.1
        private static IPAddress addr = IPAddress.Parse("127.0.0.1");
        private static int port = 0x15d4;


further in the code is the following.

public static bool Connect(IPAddress addr, int port)

....

                    if (Address.ToString() == "127.0.0.1")
                    {
                        return false;
                    }
                    if (TV2Engine.XrayConnect(addr.GetAddressBytes(), port) != 0)
                    {
                        return false;
                    }
                    reader = new BinaryReader(Stream);
                    SendAllProperties();
                    flag = true;


So if you set the IP to something different..

I haven't tried this, but there are lots of other references to suggest that it gives a CLI interface. No idea how its implemented tho.

also in GuideXrayCommands are things like this..

        public static void GuideCommander(ushort id, string[] args)
        {
            if (args.Length > 1)
            {
            switch (args[1])
            {
                    case "?":
                        DisplayCommands();
                        return;

                    case "getguide":
                        GetGuide(args);
                        return;

                    case "getbrowse":
                        GetBrowse(args);
                        return;

                    case "getprogram":
                        GetProgram(args);
                        return;

                    case "getsi":
                        GetSI(args);
                        return;

                    case "sendevent":
                        SendEvent(args);
                        return;

                    case "loaddata":
                        LoadData(args);
                        return;

                    case "unloaddata":
                        UnloadData(args);
                        return;

                    case "unloadguide":
                        UnloadGuide(args);
                        return;

                    case "unloadguidesicm":
                        UnloadGuideSICM(args);
                        return;

                    case "updateversion":
                        UpdateVersion(args);
                        return;

                    case "stats":
                        Stats(args);
                        return;

                    case "setorigintime":
                        SetOriginTime(args);
                        return;

                    case "eit":
                        EITTester(args);
                        return;

                    case "reloadmetadata":
                        ReloadMetadata(args);
                        return;

                    case "channelmap":
                        DumpChannelMap(args);
                        return;
                }
            }

Mick

warrmr

#3
23. Nov 2008, 22:23 Last Edit: 23. Nov 2008, 22:26 by warrmr
That command line stuf looks interesting although im not sure how useful it would be. I did a google for port 5588 to see if there were any known services running on it, The only results i got is for a remote access trojan.  I was hopeing that there would be some kind of documneted service running on that port like Remote desktop as there is alot of mentions in the code to RDP but i havent checked those out yet.

I also googled Microsoft IPTV CLI to see if there is any referance to command lines built into the MS IPTV platform this is based on no luck there either.

Has anyone found out where the "Recordings" menu is as i noticed on lots of forums it says that if its disconnected from BTV that menu dissapears. Neo thinks that when it connects to the vision server it downloads the new menu. Is there any way to get this menu enabled or can someone point me in the right direction.


Mick Whats this demo mode you mentioned how did you enable that.

redband

I think the Xray Class is actually a client, possibly to a CLI somewhere else.
The BT box does download new menu content when it logs on properly.
The GetAllDeviceValues response contains XML in the following key:
  <DeviceValue Key="ClientMenus" Value="<?xml version="1.0" encoding="utf-8"?>

The Recordings menu is simply hidden while the DVREnabled flag returns false.  It can be forced to appear but the recordings rely upon the clientrights which are assigned by the server and tell the box what it has recorded, what is available and probably which key/how to decode it...

warrmr

Thanx I have now managed to enable the recordings menu. And as expected it does nothing without the server connection so i am now looking into that.


is0-mick

IsAllowed  (i think its in the DVR manager class)
I think is the one that is used displays the recording menu.

Also the pause / rewind functions are around that area too.
I did manage to display the pause / play bar on the picture, but didn't manage to get it to play / record / rewind etc.

I think its to do with the record buffer not being active. NoWS (no webservice flag and something to do with the pin and _pins (these are flags and not actual PIN numbers)).
Cant remember exactly 100% as havent got the code here at the mo..

Mick

warrmr

Changing
Code: [Select]

if (this._recordedTVMenuItem != null)
            {
                this._recordedTVMenuItem.Visible = DvrManager.IsDvrEnabled(false);
            }


to this

Code: [Select]

DvrManager.IsDvrEnabled(true);


in the StartPage Class enabled the recordings menu.

and i see what you guys mean about it being hevily intergrated into the Webservice. Just hope we can bypass that easy enough.

is0-mick

#8
24. Nov 2008, 20:18 Last Edit: 24. Nov 2008, 20:24 by is0-mick
I thought the paramater in the IsDvrEnabled is for displaying the banner?

Did you not mean
this._recordedTVMenuItem.Visible = true;

Otherwise I can't see how it would have worked?


If you go to the definition you will see
Code: [Select]

        public static bool IsDvrEnabled(bool showDisabledUI)
        {
            return IsDvrEnabled(true, showDisabledUI);
        }


this then calls this method

Code: [Select]

        public static bool IsDvrEnabled(bool ignoreWS, bool showDisabledUI)
        {
            return Instance().IsEnabled(ignoreWS, showDisabledUI);
        }


Which then calls the IsEnabled, which does the real work....

I changed my code as follows..

Code: [Select]

        public bool IsEnabled(bool ignoreWS, bool showDisabledUI)
        {
            return true;


This means that any other routines calling this would think it is enabled, the way you have done it, you are just enabling the UI.

Mick

verg0

Pinging an ip of 127.0.0.1 is nothing more than a standard way for the box to test that the network hardware is working correctly.

Hope this helps

VERG0

is0-mick

True.. Not sure what it has to do with this post tho? (except that they were just using 127.0.0.1 as dummy IP if the xray class is not being used).

127.0.0.1 is just the loopback address.

Ie if you some kind of server locally, the box can also access this by using the LoopBackIP:PortAddress.

For example: Lets say we had a fake BT Vision server running on the box at port 4000. We could set the bootstrap to point at 127.0.0.1:4000 which could then be used to make the box run itself.

Mick

Go Up