Author Topic: TCP Plugin and Tivos  (Read 8153 times)

0 Members and 1 Guest are viewing this topic.

garryjw

  • $upporter
  • Contributor
  • *****
  • Posts: 59
  • Karma: 5
    • View Profile
TCP Plugin and Tivos
« on: March 20, 2014, 05:21:47 PM »
Not sure if I should tag this on the end of this topic or start a new one.

I'm trying to put together a set of commands to control networked Tivos (Virgin Media Tivo here in the UK, Tivo Premiere etc in US)

I'm using the TCP plugin and I've got it working almost all of the time but, and this is the strange bit, only when running the code from the editor. When I try to use Voice it always fails.

Command:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="1609" name="tivo power toggle" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="On my Virgin Media TV it requires the power button to be pressed twice to turn off. &#xD;&#xA;Whilst not required to press twice to turn on it does no harm and allows me to have a single event to toggle off/on">
  <action>
    <cmdType>Tcp.Client.Connect</cmdType>
    <cmdString>tivotcp&amp;&amp;192.168.18.22&amp;&amp;31339&amp;&amp;\x0d</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Tcp.Client.Write</cmdType>
    <cmdString>tivotcp&amp;&amp;IRCODE STANDBY\x0d&amp;&amp;1000</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Tcp.Client.Write</cmdType>
    <cmdString>tivotcp&amp;&amp;IRCODE STANDBY\x0d&amp;&amp;1000</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TCP.Client.Disconnect</cmdType>
    <cmdString>tivotcp</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>tivo power</phrase>
  <event>tivo_toggle</event>
</command>
Annotated log
Code: [Select]
Garry - This was a voice command
20/03/2014 20:12:04 658 doCommand:tivo power toggle
20/03/2014 20:12:04 658 action repeat set to: 1
20/03/2014 20:12:04 658 Action:  Tcp.Client.Connect - tivotcp&&192.168.18.22&&31339&&\x0d
20/03/2014 20:12:04 658 [action] Tcp.Client.Connect:tivotcp&&192.168.18.22&&31339&&\x0d

20/03/2014 20:12:04 658 [plugin] Tcp: New thread created for client: tivotcp
20/03/2014 20:12:08 215 [vcevent] TCP.StartListen.tivotcp

20/03/2014 20:12:08 215 action repeat set to: 1
20/03/2014 20:12:08 215 Action:  Tcp.Client.Write - tivotcp&&IRCODE STANDBY\x0d&&1000
20/03/2014 20:12:08 215 [action] Tcp.Client.Write:tivotcp&&IRCODE STANDBY\x0d&&1000

20/03/2014 20:12:08 215 [plugin] Tcp: TCP.ClientError: System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at vcPlugin.tcpClient.listenToServerLoop()
20/03/2014 20:12:08 215 [vcevent] TCP.ClientError.tivotcp

20/03/2014 20:12:08 215 action repeat set to: 1
20/03/2014 20:12:08 215 Action:  Tcp.Client.Write - tivotcp&&IRCODE STANDBY\x0d&&1000
20/03/2014 20:12:08 215 [action] Tcp.Client.Write:tivotcp&&IRCODE STANDBY\x0d&&1000

20/03/2014 20:12:08 215 Event Error: Thread was being aborted.
20/03/2014 20:12:08 215 [vcevent] TCP.EndListenLoop.tivotcp

20/03/2014 20:12:08 215 [vcevent] TCP.StartListen.tivotcp

20/03/2014 20:12:08 215 [vcevent] TCP.Reconnecting.tivotcp

20/03/2014 20:12:08 215 [plugin] Tcp: TCP.ClientError: System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at vcPlugin.tcpClient.listenToServerLoop()
20/03/2014 20:12:10 288 [vcevent] TCP.ClientError.tivotcp

20/03/2014 20:12:10 288 action repeat set to: 1
20/03/2014 20:12:10 288 Action:  TCP.Client.Disconnect - tivotcp
20/03/2014 20:12:10 288 [action] TCP.Client.Disconnect:tivotcp

20/03/2014 20:12:10 288 [vcevent] TCP.EndListenLoop.tivotcp
Garry -- now try same thing from editor
20/03/2014 20:12:20 518 [vcevent] VC.OpenEditor

20/03/2014 20:12:20 518 options: loading options
20/03/2014 20:12:20 518 options: verifying speech engine culture language
20/03/2014 20:12:33 293 doCommand:tivo power toggle
20/03/2014 20:12:33 293 action repeat set to: 1
20/03/2014 20:12:33 293 Action:  Tcp.Client.Connect - tivotcp&&192.168.18.22&&31339&&\x0d
20/03/2014 20:12:33 293 [action] Tcp.Client.Connect:tivotcp&&192.168.18.22&&31339&&\x0d

20/03/2014 20:12:33 293 [plugin] Tcp: New thread created for client: tivotcp
20/03/2014 20:12:33 293 [vcevent] TCP.StartListen.tivotcp

20/03/2014 20:12:33 293 action repeat set to: 1
20/03/2014 20:12:33 293 Action:  Tcp.Client.Write - tivotcp&&IRCODE STANDBY\x0d&&1000
20/03/2014 20:12:33 293 [action] Tcp.Client.Write:tivotcp&&IRCODE STANDBY\x0d&&1000

20/03/2014 20:12:33 293 action repeat set to: 1
20/03/2014 20:12:33 293 Action:  Tcp.Client.Write - tivotcp&&IRCODE STANDBY\x0d&&1000
20/03/2014 20:12:33 293 [action] Tcp.Client.Write:tivotcp&&IRCODE STANDBY\x0d&&1000

20/03/2014 20:12:35 325 action repeat set to: 1
20/03/2014 20:12:35 325 Action:  TCP.Client.Disconnect - tivotcp
20/03/2014 20:12:35 325 [action] TCP.Client.Disconnect:tivotcp

20/03/2014 20:12:35 325 [vcevent] TCP.EndListenLoop.tivotcp

20/03/2014 20:12:41 652 doCommand:tivo power toggle
20/03/2014 20:12:41 652 action repeat set to: 1
20/03/2014 20:12:41 652 Action:  Tcp.Client.Connect - tivotcp&&192.168.18.22&&31339&&\x0d
20/03/2014 20:12:41 652 [action] Tcp.Client.Connect:tivotcp&&192.168.18.22&&31339&&\x0d

20/03/2014 20:12:41 652 [plugin] Tcp: New thread created for client: tivotcp
20/03/2014 20:12:41 652 [vcevent] TCP.StartListen.tivotcp

20/03/2014 20:12:41 652 action repeat set to: 1
20/03/2014 20:12:41 652 Action:  Tcp.Client.Write - tivotcp&&IRCODE STANDBY\x0d&&1000
20/03/2014 20:12:41 652 [action] Tcp.Client.Write:tivotcp&&IRCODE STANDBY\x0d&&1000

20/03/2014 20:12:41 652 action repeat set to: 1
20/03/2014 20:12:41 652 Action:  Tcp.Client.Write - tivotcp&&IRCODE STANDBY\x0d&&1000
20/03/2014 20:12:41 652 [action] Tcp.Client.Write:tivotcp&&IRCODE STANDBY\x0d&&1000

20/03/2014 20:12:43 686 action repeat set to: 1
20/03/2014 20:12:43 686 Action:  TCP.Client.Disconnect - tivotcp
20/03/2014 20:12:43 686 [action] TCP.Client.Disconnect:tivotcp

20/03/2014 20:12:43 686 [vcevent] TCP.EndListenLoop.tivotcp
Garry - editor closed now trying with voice command again
20/03/2014 20:12:50 409 doCommand:tivo power toggle
20/03/2014 20:12:50 409 action repeat set to: 1
20/03/2014 20:12:50 409 Action:  Tcp.Client.Connect - tivotcp&&192.168.18.22&&31339&&\x0d
20/03/2014 20:12:50 409 [action] Tcp.Client.Connect:tivotcp&&192.168.18.22&&31339&&\x0d

20/03/2014 20:12:50 409 [plugin] Tcp: New thread created for client: tivotcp
20/03/2014 20:12:50 409 [vcevent] TCP.StartListen.tivotcp

20/03/2014 20:12:50 409 action repeat set to: 1
20/03/2014 20:12:50 409 Action:  Tcp.Client.Write - tivotcp&&IRCODE STANDBY\x0d&&1000
20/03/2014 20:12:50 409 [action] Tcp.Client.Write:tivotcp&&IRCODE STANDBY\x0d&&1000

20/03/2014 20:12:50 409 [plugin] Tcp: TCP.ClientError: System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at vcPlugin.tcpClient.listenToServerLoop()
20/03/2014 20:12:52 138 [vcevent] TCP.ClientError.tivotcp

20/03/2014 20:12:52 138 action repeat set to: 1
20/03/2014 20:12:52 138 Action:  Tcp.Client.Write - tivotcp&&IRCODE STANDBY\x0d&&1000
20/03/2014 20:12:52 138 [action] Tcp.Client.Write:tivotcp&&IRCODE STANDBY\x0d&&1000

20/03/2014 20:12:52 138 Event Error: Thread was being aborted.
20/03/2014 20:12:52 138 [vcevent] TCP.EndListenLoop.tivotcp

20/03/2014 20:12:52 138 [vcevent] TCP.StartListen.tivotcp

20/03/2014 20:12:52 138 [vcevent] TCP.Reconnecting.tivotcp

20/03/2014 20:12:52 138 [plugin] Tcp: TCP.ClientError: System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at vcPlugin.tcpClient.listenToServerLoop()
20/03/2014 20:12:52 138 [vcevent] TCP.ClientError.tivotcp

20/03/2014 20:12:52 138 action repeat set to: 1
20/03/2014 20:12:52 138 Action:  TCP.Client.Disconnect - tivotcp
20/03/2014 20:12:52 138 [action] TCP.Client.Disconnect:tivotcp

20/03/2014 20:12:52 138 [vcevent] TCP.EndListenLoop.tivotcp

20/03/2014 20:12:57 698 shutting down form, saving window state
20/03/2014 20:12:57 698 Minimizing to notification area
20/03/2014 20:13:00 628 focused: Idle
20/03/2014 20:13:00 628 [vcevent] unFocused.VoxCommando

20/03/2014 20:13:00 628 [vcevent] focused.Idle

20/03/2014 20:13:03 613 focused: explorer
20/03/2014 20:13:03 613 [vcevent] unFocused.Idle

20/03/2014 20:13:03 613 [vcevent] focused.explorer

« Last Edit: March 21, 2014, 05:49:09 PM by jitterjames »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
TCP Plugin and Tivo
« Reply #1 on: March 20, 2014, 05:57:00 PM »
Did you try using \x0D\x0A

I can't think why it would make a difference to run it from the editor or in a voice command.  Unless it is actually something like it works only the first time, and not the second time.

You could also try using TCP.Single.Write

Usually we use client if we want to hold the connection open for a longer period of time, rather than opening and closing right away, although technically it should still work...

Also, I'm wondering why you use a delay of a full second.  That seems long to me.  It might be better not to put a delay in the TCP action but to add a VC.Pause between the two actions.

It's hard to troubleshoot this type of thing without have a device.  I usually try lots of different things to eliminate possibilities and find patterns.

garryjw

  • $upporter
  • Contributor
  • *****
  • Posts: 59
  • Karma: 5
    • View Profile
TCP Plugin and Tivo
« Reply #2 on: March 20, 2014, 08:36:07 PM »
Hi

I don't think its a case of only works once - I called it twice from the editor in the log file and although I didn't show it I went back to the editor after the last failed voice attempt and ran the command again and it worked.

The 1 second delay was trial and error attempt at fixing the issue and you are right doesn't make total sense - it works in the editor even with a 50 ms delay.

I did try SingleWrite first but then it always failed on the second call.

 I'll give \x0D\x0A a go but the documentation says only \x0D

All very odd indeed and very difficult to track down.  All I can say is it has not worked voice controlled and 99% of the time it works in the editor (and no that doesn't make sense to me either) I might try a python script next (did I see mention somewhere that I could code something in c#)

Thanks again for your help.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
TCP Plugin and Tivo
« Reply #3 on: March 20, 2014, 09:13:46 PM »
It's ironpython running in a .net environment so yeah, you can make calls to c# libraries if you are careful but you should also be able to do stuff in pure python, which might be easier.

If I remember correctly this example is settings up a TCP server, not a client, but it may still prove helpful to you.  I would prefer if you were able to get it to work in "pure VC" but if not I'm sure you can find a way to make it work in python.

http://voxcommando.com/forum/index.php?topic=1236.msg10615#msg10615

JasonFox

  • $upporter
  • Jr. Member
  • *****
  • Posts: 27
  • Karma: 4
    • View Profile
TCP Plugin and Tivo
« Reply #4 on: March 21, 2014, 02:32:38 AM »
See my post here:

http://voxcommando.com/forum/index.php?topic=1459.0

Don't know if it will be helpful to your situation since I don't use the standby command specifically but hopefully it will.  :)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
TCP Plugin and Tivo
« Reply #5 on: March 21, 2014, 09:05:12 AM »
Thanks Jason. So basically the TiVo prefers if you connect and stay connected, which is really how the TCP.client actions were intended to be used. If you get a chance could you please test the standby commands?

BTW using writeln should be equivalent to using write and manually terminating your message with \x0D

garryjw

  • $upporter
  • Contributor
  • *****
  • Posts: 59
  • Karma: 5
    • View Profile
TCP Plugin and Tivo
« Reply #6 on: March 21, 2014, 04:53:37 PM »
Thanks. I'm going to give this a go - I did originally have it setup to open the channel and stay open. I wonder if it is the terminator in the open which is the issue (can't really see why)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
TCP Plugin and Tivo
« Reply #7 on: March 21, 2014, 05:45:53 PM »
The terminator in the "Tcp.Client.Connect" action (I assume that's what you mean by "open") is used to detect termination of messages coming back from the server (in this case the Tivo).  You could try with or without but I don't think it should make a big difference to sending.  You never know!

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: TCP Plugin and Tivos
« Reply #8 on: March 21, 2014, 05:55:39 PM »
I'm using the TCP plugin and I've got it working almost all of the time but, and this is the strange bit, only when running the code from the editor. When I try to use Voice it always fails.


Please clarify one thing for me.  Do all your voice activated TCP>>Tivo commands (like "volup", "channelDown" etc.) fail, or is it only a problem with the Double Standby command?

garryjw

  • $upporter
  • Contributor
  • *****
  • Posts: 59
  • Karma: 5
    • View Profile
Re: TCP Plugin and Tivos
« Reply #9 on: March 21, 2014, 06:05:37 PM »
Hi James - None seem to work

A bit more evidence. I've just tried Jason's scripts. As soon as I say OK Tivo I get continuous TIVO events being fired and the only way to stop them is to shut down VC completely (even a full restart doesn't get rid of them) If I run it in the command editor I don't see this.

I assume Jason isn't seeing this. I've tried with both V1 and V2 builds of VC.

I'm going to try a new install next.

Cheers
Garry


jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: TCP Plugin and Tivos
« Reply #10 on: March 21, 2014, 06:23:25 PM »
I don't know what is different about Jason's setup but it sound like you need the terminator in your connect action.

If you are not both using the same version of the TCP plugin I guess it would help me to know which versions each of you have.

I would be happy to share your computer screen (VNC or Teamviewer) at some point to try to make sense of this, but it would have to be earlier in the day.

garryjw

  • $upporter
  • Contributor
  • *****
  • Posts: 59
  • Karma: 5
    • View Profile
Re: TCP Plugin and Tivos
« Reply #11 on: March 21, 2014, 07:03:06 PM »
Thanks James really appreciate the offer. I feel I'm taking a lot of your time for something which may be specific to my network set up.

Some further evidence. I tried a clean build, having rebooted both Tivo and the PC - same problem. I did the same but added \0xD as the terminator  and I no longer get the multiple events but it now fails on the write with an established connection was aborted by the software on your machine. This is regardless of whether it is on the editor or not.

Out of interest does the fact it is generating continuous events without the terminator mean its constantly receiving data (do you generate an event per character in this case) - that would seem odd.

My plugin is 0.1.8.0

garryjw

  • $upporter
  • Contributor
  • *****
  • Posts: 59
  • Karma: 5
    • View Profile
Re: TCP Plugin and Tivos
« Reply #12 on: March 21, 2014, 07:47:49 PM »
OK decided to try the python approach as a test.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<commandGroup open="True" name="tivo py" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="1628" name="tivo power toggle" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="On my Virgin Media TV it requires the power button to be pressed twice to turn off. &#xD;&#xA;Whilst not required to press twice to trun on it does no harm and allows me to have a single event to toggle off/on">
    <action>
      <cmdType>PY.ExecString</cmdType>
      <cmdString>sendtotivo('IRCODE STANDBY')</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>tivo power</phrase>
    <event>tivo_toggle</event>
  </command>
  <command id="296" name="tivo" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>PY.ExecString</cmdType>
      <cmdString>sendtotivo('{1}')</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>tivo</phrase>
    <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\tivoremote.xml</payloadFromXML>
  </command>
  <command id="799" name="Set Tivo Response Variable" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Results.SetVar</cmdType>
      <cmdString>TivoResponse&amp;&amp;{1}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>TIVO</event>
  </command>
  <command id="387" name="onload" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <cmdString>loaded</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>PY.ExecFile</cmdType>
      <cmdString>Plugins\PY\tivo.py</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>onload</event>
  </command>
</commandGroup>

Where Plugins\PY\tivo.py is
Code: [Select]
#!  /usr/bin/python
#   Title: tivo.py
#   Author: Garry Whittaker
#   Date: 21MAR2014
#   Info: To send remote control commands to the tivo over LAN
#   TODO:

import socket
import base64


#



def sendtotivo(msg):
    dst = '192.168.18.22' # IP to tivo
   
    new = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    new.connect((dst, 31339))
   
    pkt = msg+chr(0x0D)
    new.send(pkt)
    new.close()


This works 100% reliably for all commands !

JasonFox

  • $upporter
  • Jr. Member
  • *****
  • Posts: 27
  • Karma: 4
    • View Profile
Re: TCP Plugin and Tivos
« Reply #13 on: March 22, 2014, 01:56:35 AM »
Thanks for sharing your python version I definitely want to give it a try.

I only experienced the problem you described above (constant events from tivo to VC) once and it coincided with a failure to disconnect, not sure how/why either happened.

I won't have time in front of VC and Tivo until tomorrow night but I'll share how you're python script works on my set up as soon as I get the chance.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: TCP Plugin and Tivos
« Reply #14 on: March 22, 2014, 12:46:25 PM »
OK decided to try the python approach as a test.

Nice. Looks amazingly simple.

I'm curious about the base64 module you're importing for your code. Can you explain where it's being used? I have been racking my brain trying to figure this out.

Thanks!
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)

garryjw

  • $upporter
  • Contributor
  • *****
  • Posts: 59
  • Karma: 5
    • View Profile
Re: TCP Plugin and Tivos
« Reply #15 on: March 22, 2014, 01:27:50 PM »
Good spot. I was playing around with the advanced tivo control that needs base64 encoding but i stripped it out to keep it simple but missed the include.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: TCP Plugin and Tivos
« Reply #16 on: March 22, 2014, 01:36:30 PM »
Good to know, thanks. I thought I was missing something there.  :bonk
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)

garryjw

  • $upporter
  • Contributor
  • *****
  • Posts: 59
  • Karma: 5
    • View Profile
Re: TCP Plugin and Tivos
« Reply #17 on: March 22, 2014, 01:38:57 PM »
I've been testing and comparing with Jason's script and it looks like I will need to update PayloadXML with some slightly different commands for some of the more esoteric TiVo commands but other than that working well. Ill post the revised payload file when I get it done.

garryjw

  • $upporter
  • Contributor
  • *****
  • Posts: 59
  • Karma: 5
    • View Profile
Re: TCP Plugin and Tivos
« Reply #18 on: March 23, 2014, 07:03:11 AM »
Revised payload file attached. It doesn't include any channel changing as I think that will be specific to each user and Jason's approach is probably better for that.

JasonFox

  • $upporter
  • Jr. Member
  • *****
  • Posts: 27
  • Karma: 4
    • View Profile
Re: TCP Plugin and Tivos
« Reply #19 on: March 30, 2014, 07:48:18 PM »
Finally got a chance to play with this a little today and have run into a few questions/snags. Apologies in advance if any of them have obvious answers.   ;)

First I'm confused about what the 'onload' command does. My thought was that it loaded the python program so that the 'Py.ExecString' commands work. Does it need to run once so those commands can be called (showing my programming ignorance here)? But it appears to be triggered by the event 'onload' which I never see happen. Was it supposed to be trigged by VC.Loaded?

Second have you had any trouble using commands back to back? I tried a few commands (IRCODE LIVETV, TELEPORT NOWPLAYING) and had to wait quite a bit between commands for it work. Using IRCODE LIVETV to switch quickly between tuners would not work. If I understand the python (based on nearly zero programming knowledge) it opens and closes the connection for each command right? I like that better than what mine does but maybe it's the reason for being unable to issue back to back commands? Otherwise I'm wondering if this true for you as well or specific to my Tivo (Roamio).




garryjw

  • $upporter
  • Contributor
  • *****
  • Posts: 59
  • Karma: 5
    • View Profile
Re: TCP Plugin and Tivos
« Reply #20 on: March 30, 2014, 08:11:05 PM »
Hi Jason

Onload does need to run once. Sorry I have a centralised start-up script that is triggered by VC.Loaded which triggers the onload event. You could indeed change this to VC.Loaded.

I've not had any problems with back to back commands. You are correct that I open and close the connection for each command and it is possible this is causing what you are seeing. My Virgin Media TiVo is pretty responsive to commands sent over the network and this doesn't seem to cause me any issues. (I think the closest equivalent to my box you have there is the TiVo Premier) 

Cheers
Garry

JasonFox

  • $upporter
  • Jr. Member
  • *****
  • Posts: 27
  • Karma: 4
    • View Profile
Re: TCP Plugin and Tivos
« Reply #21 on: March 30, 2014, 08:22:52 PM »
I think I need to experiment a bit more. I'm having very mixed results. Send command 5 times in 10 seconds only the first works, send command twice 15 seconds apart and neither works. Doing the same with my old command set works perfectly. It must be something on my end. I'll keep digging.  :)

garryjw

  • $upporter
  • Contributor
  • *****
  • Posts: 59
  • Karma: 5
    • View Profile
Re: TCP Plugin and Tivos
« Reply #22 on: March 31, 2014, 07:50:05 PM »
Hi Jason

Been doing some digging and I think this may be something specific with the  LiveTV command. It looks like there is a response sent by the server after this command is sent of LIVETV_READY and from what I can see no other TV control commands can be sent until that message has been sent and processed. Obviously my code is not looking for any response.


vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
Re: TCP Plugin and Tivos
« Reply #23 on: April 22, 2014, 12:05:39 AM »
Hi guys, my housemate has a networked Tivo. I tried to grab all the XMLs and just get a Guide command to work.
Would love to get this to work, but so far unsuccessful.
I dropped the files in the the applicable folder on the latest version of v2 of VC.
Was there specific setup on the Tivo required? Being TCP related I dont think any other hardware is required correct? When I just try to get a phone app to work, seems like I have to enable Network Remote Control and have a Media Access Key, is that applicable here?
I tried to grab all the xmls, not sure if they are v1 or v2 of VC and updated the py script w/ the tivo IP.
I can hit the http://tivoIP page successfully.
Its not my tivo but I'm sure my housemate would let me do whatever I needed to configure it if required.
Its a Tivo Series4

UPDATE:
Ok I had to change the event to VC.loaded and add the {path.vc} to the py script however some commands aren't working or having the same experience where some unresponsiveness occurs?
Also discovered the telnet commands and those seem more consistently effective. This would be really neat if could get more hardened!!
The above is related to the PY ones from gary.
I'm not having luck with http://voxcommando.com/forum/index.php?topic=1459.0
« Last Edit: April 22, 2014, 01:06:52 AM by vulcanjedi »

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
Re: TCP Plugin and Tivos
« Reply #24 on: April 22, 2014, 09:56:41 AM »
Managed to get Jason's TCP centric ones to work just before bed. Brief testing was more consistent and more commands worked consecutively. Is there a pressing argument of python vs tcp based approach.?

My experience pretty much echos those of jasonfox/garryjw.
I see the commands and the threads mention the tcp connection.  Can you simply have the client connection load on onload and then perhaps terminate on closure, or is leaving the connection open a big issue? (i know it seems to flood the activity log pane, which is a bit annoying but also not always?)
Or have each command create the connection, execute action, terminate connection? I found the listen, and idle , disconnect command/events a bit odd is the late hours maybe missing the rationale.
I liked the more pithy config w/ most of the commands in the PY variant being in the payload xml shrinking the LCB command tree :P But it was very inconsistent and never got most commands working.
The TCP ones all worked the several I managed to try before getting to be too late and having to sleep. Command response was very good and consecutive commands no problem.

But this is pretty awesome stuff, thanks for sharing and helping all.
« Last Edit: April 22, 2014, 10:51:28 AM by vulcanjedi »

garryjw

  • $upporter
  • Contributor
  • *****
  • Posts: 59
  • Karma: 5
    • View Profile
Re: TCP Plugin and Tivos
« Reply #25 on: April 22, 2014, 11:01:58 AM »
Hi

I went with Python as I just couldn't get the tcp approach to work consistently with my Virgin TiVo here in the UK. To be honest I never really got to the bottom of why. Other than the Live TV command the python approach works absolutely rock solidly for me. According to the TiVo spec LiveTV needs you to wait for a response after sending it before trying any other commands. In my setup I'm not using the LiveTV button so I haven't looked at extending the python script - at the moment the Python Script doesn't wait. I think Jason's approach may be better for that if TCP is working for you.

Cheers
Garry

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
Re: TCP Plugin and Tivos
« Reply #26 on: April 22, 2014, 11:34:46 AM »
Hi

I went with Python as I just couldn't get the tcp approach to work consistently with my Virgin TiVo here in the UK. To be honest I never really got to the bottom of why. Other than the Live TV command the python approach works absolutely rock solidly for me. According to the TiVo spec LiveTV needs you to wait for a response after sending it before trying any other commands. In my setup I'm not using the LiveTV button so I haven't looked at extending the python script - at the moment the Python Script doesn't wait. I think Jason's approach may be better for that if TCP is working for you.

Cheers
Garry
Ah thats clearer thanks Gary. At first glance the tcp approach seems to as of last night. Based on your comments I apparently don't think I'm getting the responses or in a timely manner, as just sporadically would the py commands work and only a few of them, under TELEPORT, not sure any IRCODEs ever worked for me. But I was trying to use the Live TV command a few times so that may have impacted my experience based on your statement.
Sorry for all the questions it was a bit hard to go through all the xmls/posts in the few threads. I think I did manage to get both ways 'proof of concepted'. I'll continue to vet and see how it goes, thanks again.
« Last Edit: April 22, 2014, 01:15:51 PM by vulcanjedi »

garryjw

  • $upporter
  • Contributor
  • *****
  • Posts: 59
  • Karma: 5
    • View Profile
Re: TCP Plugin and Tivos
« Reply #27 on: April 22, 2014, 12:35:38 PM »
Maybe we should log which devices which approach works with.