Author Topic: USB UIRT with multiple values in payload  (Read 4430 times)

0 Members and 1 Guest are viewing this topic.

DHHJ

  • $upporter
  • Contributor
  • *****
  • Posts: 62
  • Karma: 1
    • View Profile
USB UIRT with multiple values in payload
« on: March 22, 2014, 07:00:42 PM »
I'm trying to send a UIRT signal to my set top box based on a TV channel identifier (in this example, the phrase 'CBC' is mapped to the value '1205' in my payload xml file.

I don't believe UsbUIRT.Send supports multiple payload values so I think I need to use RegEx to loop through the 1,2,0 and 5, for my example, and send individual UsbUIRT.Send actions?

I tried to duplicate the logic from nimester's reply to http://voxcommando.com/forum/index.php?topic=1220.0 but am not sure about the logic/syntax of these lines
Code: [Select]
  <action>
    <cmdType>Tcp.Client.WriteLn</cmdType>
    <cmdString>iTach&amp;&amp;{M:GcTivo.TIVO - {Match.{i}}}&amp;&amp;200</cmdString>
    <cmdRepeat>{#M}</cmdRepeat>
  </action>

Here is my starting effort- can someone help please?!

Code: [Select]
<command id="756" name="CBC Test" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
            <action>
                <cmdType>TTS.Speak</cmdType>
                <cmdString>Switching to channel: {PF.1}</cmdString>
                <cmdRepeat>1</cmdRepeat>
            </action>
            <action>
                <cmdType>Results.RegEx</cmdType>
                <cmdString>(/d)&amp;&amp;&amp;&amp;{1}</cmdString>
                <cmdRepeat>1</cmdRepeat>
            </action>
            <action>
                <cmdType>UsbUIRT.Send</cmdType>
                <cmdString>{M:uu_Fibe.1 - {Match.{i}}}&amp;&amp;1</cmdString>
                <cmdRepeat>{#M}</cmdRepeat>
            </action>
            <phrase>Goto channel</phrase>
            <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\fibecommands.xml</payloadFromXML>
        </command>

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: USB UIRT with multiple values in payload
« Reply #1 on: March 22, 2014, 09:02:13 PM »
Hi DHHJ,

You haven't explained what kind of result you're seeing or not seeing. Is it sending the wrong signals, or not all 4 digits are being sent? What result are you getting currently?

In principle, what you've done looks like it should work from a point of view of the regex, though we would need to know more about your Fibe map to be certain.

Based on what you've posted, your uu_Fibe should have keys mapped to IR code values as follows:

1 - 0 > IR code for your remote button 0;
1 - 1 > IR code for your button 1;
1 - 2 > IR code for your button 2;
1 - 3 > IR code for the button 3;
etc. to 9

Is that correct?
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: USB UIRT with multiple values in payload
« Reply #2 on: March 22, 2014, 09:19:18 PM »

I tried to duplicate the logic from nimester's reply to http://voxcommando.com/forum/index.php?topic=1220.0 but am not sure about the logic/syntax of these lines
Code: [Select]
 <action>
    <cmdType>Tcp.Client.WriteLn</cmdType>
    <cmdString>iTach&amp;&amp;{M:GcTivo.TIVO - {Match.{i}}}&amp;&amp;200</cmdString>
    <cmdRepeat>{#M}</cmdRepeat>
  </action>

Taking your CBC example of 1205:

The regular expression (\d) is capturing 1 digit at a time. So each digit is a match.

1 -> {Match.1}
2 -> {Match.2}
0 -> {Match.3}
5 -> {Match.4}

So, if we look at the map variable (I'll stick with the Tivo example that you quoted, although it's a bit confusing because that's not your map. ;)):

Jason's map variable takes the form {M:GcTivo.TIVO - buttonNumber} for each button press.

So what we want is to send four button presses for four different buttons, using the map variables:
{M:GcTivo.TIVO - 1}
{M:GcTivo.TIVO - 2}
{M:GcTivo.TIVO - 0}
{M:GcTivo.TIVO - 5}

Instead of four separate actions, we can repeat the same action four times, but obviously we need to change the variable each time.

{#M} is the number of regex matches found. If CBC's channel number has four digits "1205" then there will be 4 matches. So the action will repeat 4 times.

{i} is the "increment" variable. See http://voxcommando.com/mediawiki/index.php?title=Variables#.7Bi.7D

So the first time the action is executed, {Match.{i}} becomes {Match.1};
The second time the action is repeated, {Match.{i}} becomes {Match.2}; etc.

---

... Not sure if that helps, but obviously we're happy to help if any more clarifications are needed.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

DHHJ

  • $upporter
  • Contributor
  • *****
  • Posts: 62
  • Karma: 1
    • View Profile
Re: USB UIRT with multiple values in payload
« Reply #3 on: March 23, 2014, 07:57:25 PM »
Thanks, that helps- I didn't take the time  :bonk to read the wiki on Variables!

I'm close but not quite there. My xml payload file is quite simple, phrases are channel names (CBC, CTV, NBC, Fox, etc) and their values are 4 digit channel numbers (1205, 1201, 1220, 123, etc.). I understand the RegEx and looping using {#M} but I'm not getting any results being fed into my UsbUIRT.Send action.

Code: [Select]
<command id="756" name="CBC Test" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
            <action>
                <cmdType>TTS.Speak</cmdType>
                <cmdString>Switching to channel: {PF.1}</cmdString>
                <cmdRepeat>1</cmdRepeat>
            </action>
            <action>
                <cmdType>Results.RegEx</cmdType>
                <cmdString>(/d)&amp;&amp;&amp;&amp;{1}</cmdString>
                <cmdRepeat>1</cmdRepeat>
            </action>
            <action>
                <cmdType>UsbUIRT.Send</cmdType>
                <cmdString>{M:uu_Fibe.{Match.{i}}}&amp;&amp;2</cmdString>
                <cmdRepeat>{#M}</cmdRepeat>
            </action>
            <phrase>Goto channel</phrase>
            <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\fibecommands.xml</payloadFromXML>
        </command>

My mapping table is named uu_Fibe and has fromKey values of 1,2,3,...,0 with toValue consisting of IR codes. Attached is my log. Thanks.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: USB UIRT with multiple values in payload
« Reply #4 on: March 23, 2014, 08:39:02 PM »
your regex pattern has the wrong kind of slash.

it should be \d

you have written /d

http://www.mikesdotnetting.com/Article/46/CSharp-Regular-Expressions-Cheat-Sheet

I don't know if that is the only problem but you can start by fixing that.  Sorry we did not notice it before.

DHHJ

  • $upporter
  • Contributor
  • *****
  • Posts: 62
  • Karma: 1
    • View Profile
Re: USB UIRT with multiple values in payload
« Reply #5 on: March 24, 2014, 04:16:24 PM »
Thanks James- that did it! Should have seen it........

Which leads me to a request (probably should put this in Feature Requests!)

I know you're busy with V2 but have you considered putting in a simple debug capability into the LCB to assist in macro development? It would be great if we could single step though a macro and take a look at variables, {Match.2}, {PF.1}, {#M}, {LastResult}, etc. on the fly. May cut down on the number of macro support questions in the forum as well  ;)

Thanks for your help.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: USB UIRT with multiple values in payload
« Reply #6 on: March 24, 2014, 04:50:04 PM »
Hi DHHJ,

Part of this is simply about becoming more familiar with VC's interface.

If you had looked at your history window after testing your voice command, you would have had a good indication of what the problem was.



You can try this yourself. Go back to your original regular expression. Issue your voice command with the history window open. See the line highlighted in orange? Mouse over it. It tells you that it didn't find any matches and it shows what string it is trying to evaluate (1205).

Right away, you should know that it is trying to evaluate the correct string, but it can't find matches so there must be something wrong with the regular expression you're using.

It would be difficult indeed for a debugging tool to figure out every possible human error for each action that VC offers. It's true that comprehensive development platforms offer such tools, but the resources required make it an independent development project in its own right, not a small side "bonus feature".

James has tried to provide a lot of tools in VC to help us to problem solve.

Apart from learning how to make the most of messages that appear in the history window, I usually recommend that people make more use of the parameter helper as well: http://voxcommando.com/mediawiki/index.php?title=Parameter_Helper

And look for guidance provided in the action selection tree. (e.g. the Results.Regex action description includes a link to the C# cheat sheet that James linked to above): http://voxcommando.com/mediawiki/index.php?title=Action_Selection_Tree

In the end, it still takes time, for those of us who aren't programmers, to learn how to problem solve in the kinds of step-by-step systematic ways that computer applications require.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: USB UIRT with multiple values in payload
« Reply #7 on: March 24, 2014, 04:54:48 PM »
People really don't use the history window enough.  As a debugging tool, it is a very good place to start.  I have no intention of adding another debugger in the LCB since it would be redundant and a wasted effort for when you are executing commands with the LCB closed.

DHHJ

  • $upporter
  • Contributor
  • *****
  • Posts: 62
  • Karma: 1
    • View Profile
Re: USB UIRT with multiple values in payload
« Reply #8 on: March 25, 2014, 11:14:00 AM »
Thanks folks for the ideas. I was looking for some assistance on how best to debug- I didn't see the mouse over. I will also try to play with OSD and SetVar to see if I can get some intermediate results as the macro flows, to aid in error checking.

I do know Regex quite well (you wouldn't think though with my slash typo!) and have a fair degree of software development in my background. I guess I miss my NetBeans/Visual Studio...............

Thanks again. Great software.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: USB UIRT with multiple values in payload
« Reply #9 on: March 25, 2014, 11:20:46 AM »
Mouse over an item in the history window will show the {LastResult} at that point if the action returns a result.  Otherwise it will show info that is not stored as a result, or an error message.  Note that the main VC window must have focus for popups to work (standard Windows phenomena!) but sometimes if you are working in the LCB you might forget to focus the main window.

I find it useful when I have a very long last result (like from scraping a website) to use
System.SetClipboardText    {LastResult}

and then pasting the text into notepad++

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: USB UIRT with multiple values in payload
« Reply #10 on: March 25, 2014, 11:23:12 AM »
Or you could write your lastresult to a text file using the File actions...