Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

How to send Command to Global Cache iTech IPToIR

If you have a question or need help, this is the place to be.
Kazuya
Posts: 15
Joined: Sat Dec 14, 2013 8:07 pm

Re: How to send Command to Global Cache iTech IPToIR

Post by Kazuya »

I read it and I tried different things, and nothing more... :cry:

It's very odd because the command works with iTest, look :

Image


It's exactly the same command "sendir" for the GC100, but my python script doesn't work with the IP2IR, only on the GC100.
I think something is wrong on the red part here or something missing :

import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

HOST = '192.168.1.20'
PORT = 4998
sock.connect((HOST, PORT))
sock.sendall("sendir,1:1,1,38000,2,...,20,1686,338,84,20,3622"+"/r/n")
sock.close()


but what should be different between GC100 and IP2IR ???

I don't understand... :cry:
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: How to send Command to Global Cache iTech IPToIR

Post by krambriw »

For me is impossible to test since I do not have a device like that. I can only try to give general advice in this case:

First, try to use only \r at the end of the string (in the document you linked to, it says all commands must terminate with carriage return (maybe the \n, meaning new line, confuses the device..)

Code: Select all

\r = CR (Carriage Return) // Used as a new line character in Unix

\n = LF (Line Feed) // Used as a new line character in Mac OS

\r\n = CR + LF // Used as a new line character in Windows
Secondly, try a simpler command first just to see if you can communicate at all with the device. Just try to check the device version:

Code: Select all

import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
HOST = '192.168.1.20'
PORT = 4998
sock.connect((HOST, PORT))

p = sock.sendall("getversion"+"/r")
print p
 
sock.close()
Kazuya
Posts: 15
Joined: Sat Dec 14, 2013 8:07 pm

Re: How to send Command to Global Cache iTech IPToIR

Post by Kazuya »

Thanks for helping me !

I just tried /r only and it still does nothing.
There is a LED on the iTach which blinks when a command goes to the output and it never blinks with eventghost.

I tried your script too, with only getversion and Eventghost gives the answer "None"...
Looks like it can't communicate with the device...

For info, iRule on my android tablet communicates with it, without any problem.
For gateway, I just enter the IP adress of the iTach device and it's ok...

The IP is the good one, the port too.

Is there any difficulty usually to get eventghost communicates with Wi-Fi devices ?
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: How to send Command to Global Cache iTech IPToIR

Post by krambriw »

I have changed the test script a bit, trying to read the response from the device, you can try and see if you receive anything at all...

Code: Select all

import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
HOST = '192.168.1.20'
PORT = 4998
sock.connect((HOST, PORT))
sock.settimeout(2)
sock.sendall("getversion"+"/r")

while True:
    try:
        msg = sock.recv(4096)
    except socket.timeout, e:
        err = e.args[0]
        # this next if/else is a bit redundant, but illustrates how the
        # timeout exception is setup
        if err == 'timed out':
            sleep(1)
            print 'recv timed out, retry later'
            continue
        else:
            print e
            sys.exit(1)
    except socket.error, e:
        # Something else happened, handle error, exit, etc.
        print e
        sys.exit(1)
    else:
        if len(msg) == 0:
            print 'orderly shutdown on server end'
            sys.exit(0)
        else:
            # got a message do something :)

print msg
sock.close()

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: How to send Command to Global Cache iTech IPToIR

Post by krambriw »

Is there any difficulty usually to get eventghost communicates with Wi-Fi devices
No, is no difference if it is connected to your network

Best regards, Walter
Kazuya
Posts: 15
Joined: Sat Dec 14, 2013 8:07 pm

Re: How to send Command to Global Cache iTech IPToIR

Post by Kazuya »

krambriw wrote:I have changed the test script a bit, trying to read the response from the device, you can try and see if you receive anything at all...
Ok !
First, eventghost says it expects an incrementation line 34 (for "print msg"), I did it, then, there is a response this time :

Python Script
710-1001-05

Traceback (most recent call last):
Python script "86", line 17, in <module>
sleep(1)
NameError: name 'sleep' is not defined
"710-1001-05" is indeed the firmware of my device ! :D
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: How to send Command to Global Cache iTech IPToIR

Post by krambriw »

ok, means you can communicate with the device...

to fix the sleep error, add the following line at top of the script

Code: Select all

from time import sleep
Kazuya
Posts: 15
Joined: Sat Dec 14, 2013 8:07 pm

Re: How to send Command to Global Cache iTech IPToIR

Post by Kazuya »

Yes, it communicates.

This script :

Code: Select all

import socket
from time import sleep
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
HOST = '192.168.1.20'
PORT = 4998
sock.connect((HOST, PORT))
sock.settimeout(2)
sock.sendall("getversion"+"/r")

while True:
    try:
        msg = sock.recv(4096)
    except socket.timeout, e:
        err = e.args[0]
        # this next if/else is a bit redundant, but illustrates how the
        # timeout exception is setup
        if err == 'timed out':
            sleep(1)
            print 'recv timed out, retry later'
            continue
        else:
            print e
            sys.exit(1)
    except socket.error, e:
        # Something else happened, handle error, exit, etc.
        print e
        sys.exit(1)
    else:
        if len(msg) == 0:
            print 'orderly shutdown on server end'
            sys.exit(0)
        else:
            # got a message do something :)

            print msg
sock.close()
Gives me this :
Python Script
710-1001-05

recv timed out, retry later
ERR_0:0,016

recv timed out, retry later
recv timed out, retry later
recv timed out, retry later
recv timed out, retry later
with no ending... I have to kill eventghost to stop it ! :shock:
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: How to send Command to Global Cache iTech IPToIR

Post by krambriw »

Ok, lets try this now

First, instead of the word 'continue' you could insert 'sys.exit(1)', then it will close after the timeout (I hope)

Then we can try a new command instead, get_NET

Best regards

Code: Select all

import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
HOST = '192.168.1.20'
PORT = 4998
sock.connect((HOST, PORT))
sock.settimeout(2)
sock.sendall("get_NET,0:1"+"/r")

while True:
    try:
        msg = sock.recv(4096)
    except socket.timeout, e:
        err = e.args[0]
        # this next if/else is a bit redundant, but illustrates how the
        # timeout exception is setup
        if err == 'timed out':
            sleep(1)
            print 'recv timed out, retry later'
            sys.exit(1)
            #continue
        else:
            print e
            sys.exit(1)
    except socket.error, e:
        # Something else happened, handle error, exit, etc.
        print e
        sys.exit(1)
    else:
        if len(msg) == 0:
            print 'orderly shutdown on server end'
            sys.exit(0)
        else:
            # got a message do something :)

print msg
sock.close()
Kazuya
Posts: 15
Joined: Sat Dec 14, 2013 8:07 pm

Re: How to send Command to Global Cache iTech IPToIR

Post by Kazuya »

Ok, I think you forgot from time import sleep, I added it at the beginning.

Now, Eventghost gives me this as answer :
Python Script
ERR_0:0,003

recv timed out, retry later
Traceback (most recent call last):
Python script "54", line 20, in <module>
sys.exit(1)
NameError: name 'sys' is not defined
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: How to send Command to Global Cache iTech IPToIR

Post by krambriw »

Sorry, need to add

Code: Select all

import sys
at the top

Anyway, looks like the device is not responding to that command...
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: How to send Command to Global Cache iTech IPToIR

Post by krambriw »

...and should maybe be

Code: Select all

sock.sendall("get_NET,1:1"+"/r")
Kazuya
Posts: 15
Joined: Sat Dec 14, 2013 8:07 pm

Re: How to send Command to Global Cache iTech IPToIR

Post by Kazuya »

Still an error sent by the device :
Python Script
ERR_1:0,003

recv timed out, retry later
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: How to send Command to Global Cache iTech IPToIR

Post by krambriw »

I am not sure if we get the error code

ERR_03 Invalid connector address (does not exist).
or
ERR_01 Invalid command. Command not found.


I do not know so much more what to try, maybe some other commands,,,

You have the 'getdevices' and 'getstate' , maybe worth testing
Kazuya
Posts: 15
Joined: Sat Dec 14, 2013 8:07 pm

Re: How to send Command to Global Cache iTech IPToIR

Post by Kazuya »

I think it's good now !!!! :P :P :P :P :P

There was a mistake with the backslash of /r/n, it's not "/" we have to use but "\" !
I figured it out by reading the document Bruinlax give me first.

Now, the script is :

Code: Select all

import socket
from time import sleep
import sys
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
HOST = '192.168.1.20'
PORT = 4998
sock.connect((HOST, PORT))
sock.settimeout(2)
sock.sendall("get_NET,1:1"+"\r")

while True:
    try:
        msg = sock.recv(4096)
    except socket.timeout, e:
        err = e.args[0]
        # this next if/else is a bit redundant, but illustrates how the
        # timeout exception is setup
        if err == 'timed out':
            sleep(1)
            print 'recv timed out, retry later'
            sys.exit(1)
            #continue
        else:
            print e
            sys.exit(1)
    except socket.error, e:
        # Something else happened, handle error, exit, etc.
        print e
        sys.exit(1)
    else:
        if len(msg) == 0:
            print 'orderly shutdown on server end'
            sys.exit(0)
        else:
            # got a message do something :)

            print msg
sock.close()

With your command, I still get an ERR_0:0,001 :
self.errCodeMap = {
"001" : "Invalid command. Command not found.",
BUT !
With my previous IR command which is good for GC100, I get :
Python Script
completeir,1:1,1

recv timed out, retry later
And the LED blinks !
My command is working ! :D
I don't understand all your script but it's good now, except that "recv timed out, retry later"...

Thanks a lot ! :D
Last edited by Kazuya on Wed Jan 29, 2014 6:04 pm, edited 1 time in total.
Post Reply