set a variable

249 views
Skip to first unread message

Greg Ricks

unread,
Mar 26, 2015, 12:01:02 AM3/26/15
to android-s...@googlegroups.com
I'm having a horrible time trying to figure out how to set the expect data to a variable. I saw a few previous posts that I copied and pasted but didn't work. Is there a post/tutorial you can point me at? Thanks.

David

unread,
Mar 26, 2015, 12:50:14 AM3/26/15
to android-s...@googlegroups.com
Start by executing Send/Expect directly and looking at the help.  There is a section called Tasker Integration and in that section is a subsection about Expect which covers setting a Tasker variable via a named capture group.  Let me know if it this covers it sufficiently for you. 

Greg Ricks

unread,
Mar 27, 2015, 7:38:07 PM3/27/15
to android-s...@googlegroups.com
I've gone through a bunch of different variations and haven't gotten the expect to map to a variable yet.  Below is the send expect setup.  

Send: ?V\r
Expect: VOL(?<myvar>)

Tasker Fails on this step of the task.  Next step is to flash %myvar

When I just do send for things like Volume Up VU\r it works just fine, the fail seems to be on the expect.

When I enter the send in PUTTY the response is VOL101 (the number changes based on what the volume of the AV is).  Note, I set the timeout of the task to 36 seconds, I saw that was a troubleshooting step.  Please advise what I'm missing here.  Thanks.

David

unread,
Mar 27, 2015, 8:49:19 PM3/27/15
to android-s...@googlegroups.com
On Friday, March 27, 2015 at 4:38:07 PM UTC-7, Greg Ricks wrote:
I've gone through a bunch of different variations and haven't gotten the expect to map to a variable yet.  Below is the send expect setup.  

Send: ?V\r
Expect: VOL(?<myvar>)

Tasker Fails on this step of the task.  Next step is to flash %myvar


It is a problem with the regular expression.  It is saying look for VOL and then put nothing in the named capture group myvar.

Try something like:

Expect: VOL(?<myvar>[0-9]+) 

Here are couple of references for using regular expressions:


Charles Hsu

unread,
Jan 9, 2016, 11:50:55 PM1/9/16
to Android Send/Expect
did you ever get this working?  I'm probably doing the same thing you are... 
I'm trying to get the volume sent to a variable and it doesn't seem to be working.  What's your expect command if you got it working?  thx. 

David

unread,
Jan 10, 2016, 10:37:59 AM1/10/16
to Android Send/Expect
Post a SendExpect debug log

Message has been deleted

OB1

unread,
Aug 12, 2016, 4:35:14 PM8/12/16
to Android Send/Expect
Hi,

I have the same problem... It doesn't seem to be the regular expression... The variable %test seems to have been set to the correct value (131), yet my next command on tasker is flash %test which doesn't return anything. I thought that maybe it had to be something with the variable in CAPS (%TEST), but that doesn't work either as it's not accepted by send/expect...

Here is the log:

[
  {
    "timestamp": 0,
    "recordType": "Start",
    "recordData": "Tasker"
  },
  {
    "timestamp": 0,
    "recordType": "Version",
    "recordData": "2000051"
  },
  {
    "timestamp": 0,
    "recordType": "Send/Expect Data",
    "recordData": "Timeout seconds: 10\nSend (original): ?V\\r\nSend (variables replaced): ?V\\r\nExpect: VOL(?<test>[0-9]+)\n"
  },
  {
    "timestamp": 0,
    "recordType": "Connection Started",
    "recordData": "192.168.0.159:8102"
  },
  {
    "timestamp": 80,
    "recordType": "Connection Completed",
    "recordData": "192.168.0.159:8102"
  },
  {
    "timestamp": 80,
    "recordType": "Send",
    "recordData": "?V\\r"
  },
  {
    "timestamp": 80,
    "recordType": "Data Sent",
    "recordData": null
  },
  {
    "timestamp": 81,
    "recordType": "Expect",
    "recordData": "VOL([0-9]+)"
  },
  {
    "timestamp": 81,
    "recordType": "Received Buffer Contains",
    "recordData": ""
  },
  {
    "timestamp": 95,
    "recordType": "Received Bytes",
    "recordData": "8"
  },
  {
    "timestamp": 95,
    "recordType": "Received Buffer Contains",
    "recordData": "VOL131\r\n"
  },
  {
    "timestamp": 96,
    "recordType": "Expect Matched",
    "recordData": "VOL131"
  },
  {
    "timestamp": 96,
    "recordType": "Capture Group",
    "recordData": "testmatched 131"
  },
  {
    "timestamp": 96,
    "recordType": "Disconnect",
    "recordData": null
  },
  {
    "timestamp": 96,
    "recordType": "Set Tasker Variable",
    "recordData": "%test = 131"
  },
  {
    "timestamp": 96,
    "recordType": "Succeeded",
    "recordData": null
  }
]


David

unread,
Aug 12, 2016, 10:13:57 PM8/12/16
to Android Send/Expect


On Friday, August 12, 2016 at 1:35:14 PM UTC-7, OB1 wrote:
Hi,

I have the same problem... It doesn't seem to be the regular expression... The variable %test seems to have been set to the correct value (131), yet my next command on tasker is flash %test which doesn't return anything. I thought that maybe it had to be something with the variable in CAPS (%TEST), but that doesn't work either as it's not accepted by send/expect...

Here is the log:


  {


    "timestamp": 96,
    "recordType": "Set Tasker Variable",
    "recordData": "%test = 131"
  },
  {
    "timestamp": 96,
    "recordType": "Succeeded",
    "recordData": null
  }
]



Hello.

These two log entries indicate that SendExpect passed the variable back to Tasker  (see  signalFinish() in TaskerPlugin.java).

This feels like an issue with your Tasker task.  Can you enable debugging there and see if the variable is showing up?

OB1

unread,
Aug 16, 2016, 5:55:32 PM8/16/16
to Android Send/Expect
Hi David,

As you can see in the screenshot, my task is super basic, just send/expect and flash the variable... but the variable isn't passed...  the Tasker log is very verbose.

Your help would be greatly appreciated...
Screenshot_20160816-232840 (1).png

David

unread,
Aug 16, 2016, 7:08:24 PM8/16/16
to Android Send/Expect
Salut OB1.

Is your SendExpect task synchronous?   See SendExpect Tasker Tutorial

If not, starting SendExpect, and then immediately moving on to the flash, and the variable won't be set yet.

David

OB1

unread,
Aug 16, 2016, 7:39:19 PM8/16/16
to Android Send/Expect
Hello David,

Thanks, you were right... 

For those of you who experience the same problem, as David points out, you have to set a TIMEOUT on tasker and Send/Expect, otherwise the variable will not passed to tasker...

David

unread,
Aug 16, 2016, 8:12:45 PM8/16/16
to Android Send/Expect
On Tuesday, August 16, 2016 at 4:39:19 PM UTC-7, OB1 wrote:

For those of you who experience the same problem, as David points out, you have to set a TIMEOUT on tasker and Send/Expect, otherwise the variable will not passed to tasker...

Also, the Tasker timeout needs to be a larger value than the timeout within your SendExpect configuration (if you have one there). 

OB1

unread,
Aug 17, 2016, 6:58:31 AM8/17/16
to Android Send/Expect
Salut David,

I wrote you an email yesterday, but I'm not sure that you are receiving them...
Reply all
Reply to author
Forward
0 new messages