Author Topic: Getting IP address from Device in GSD  (Read 2599 times)

PeteK

  • Guru
  • ****
  • Posts: 408
    • View Profile
Getting IP address from Device in GSD
« on: March 10, 2009, 07:00:31 am »
Hi everyone--

I'm trying to modify the template for the Roku Netflix player.  Right now it's set to be controlled via an IR interface.  However, I've gotten a quasi-official ICD from Roku to control it via telnet.  The template is of type AV/Cable Box (which seemed to be the closest match when I created it).  Per TSCHAK's advice, I added a PORT (#171) device data field.  However, when I add code to the Command fields, I get an error about not finding a port.  I believe this is due to the case that there is a Com Port on PC data field defined for the device (I'm not sure exactly how, as it's not in the template.  i think it's inherited from the device type).  This field is set to empty and I think GSD defaults to using this field and it's trying to create a serial connection.   TSCHAK suggested using a Ruby  TCPSocket to communicate.  That socket requires the IP address of the target in its constructor.

Now, to make a long plead short, I haven't been able to find the documentation for how to extract a device's IP address from it's devicedata fields inside GSD so I can feed it to the constructor.  Does anyone know how to do it?

Thanks for the help.
-PeteK

darrenmason

  • Addicted
  • *
  • Posts: 529
    • View Profile
Re: Getting IP address from Device in GSD
« Reply #1 on: March 11, 2009, 02:56:22 am »
Not really answering your question but....

The GSD code will create a serial connection if the COM Port is not empty and not Zero
Otherwise, it will create a network connection using the IP address from the device and the port specified in the device data.

So as long as your COM port is not set you should be OK - You seem to already realise this and this bit is probably fine..
However, You do not want to add PORT(#171) you need to use TCP_PORT(#69).

I think that this might fix your problem even though it is not the answer to the question you asked :)

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5505
  • DOES work for LinuxMCE.
    • View Profile
Re: Getting IP address from Device in GSD
« Reply #2 on: March 11, 2009, 03:08:37 am »
Sorry, yes, he's right. It's TCP Port. ;-)

*blush*

-Thom

PeteK

  • Guru
  • ****
  • Posts: 408
    • View Profile
Re: Getting IP address from Device in GSD
« Reply #3 on: March 16, 2009, 05:18:48 am »
Guys--

Thanks for the help!  Darrenmason, you were right.  Changing the Port Device Data field to TCP Port fixed the connection issue.  I've got the commands working, but I've run into another issue.  After booting the device (having it recognized by LMCE), it responds just fine to commands from GSD.  However, after a router reload, it fails to respond to commands until a power cycle.  I'm wondering if this is due to the way that the connection is closed during a router reload.  However, I'm not by any means certain.  I know that i can telnet to it from the command line, quit via 'quit' and re-connect to it time after time (until a router reboot).  Can anyone offer any more advice?

Thanks a lot!
-Peter

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5505
  • DOES work for LinuxMCE.
    • View Profile
Re: Getting IP address from Device in GSD
« Reply #4 on: March 16, 2009, 05:33:54 am »
Try putting in a conn_.send("quit"); in process release?

-Thom

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: Getting IP address from Device in GSD
« Reply #5 on: March 16, 2009, 08:22:28 pm »
Check the log, it may be that the socket connection is still open.. or cannot connect, because the other end (not gsd) isn't designed for multiple connections.. (ie, 1 socket connection at a time, and it must be closed prior to reopening)

Try adding a conn_.close() in the apropriate GSD routine.

I've used IP via GSD for a lot of things, including my first stab at Insteon...

Good Luck, HTH

Dan
« Last Edit: March 16, 2009, 08:24:10 pm by ddamron »
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

PeteK

  • Guru
  • ****
  • Posts: 408
    • View Profile
Re: Getting IP address from Device in GSD
« Reply #6 on: March 16, 2009, 09:31:20 pm »
Try putting in a conn_.send("quit"); in process release?

-Thom

Thom---

Thanks for the advice.  Unfortunately I tried that yesterday with no luck  :(

PeteK

  • Guru
  • ****
  • Posts: 408
    • View Profile
Re: Getting IP address from Device in GSD
« Reply #7 on: March 16, 2009, 09:34:41 pm »
Check the log, it may be that the socket connection is still open.. or cannot connect, because the other end (not gsd) isn't designed for multiple connections.. (ie, 1 socket connection at a time, and it must be closed prior to reopening)

Try adding a conn_.close() in the apropriate GSD routine.

I've used IP via GSD for a lot of things, including my first stab at Insteon...

Good Luck, HTH

Dan

OK, Dan.  I'll give it a shot.  I've started revisiting my Insteon code in hopes of getting it cleaned up and improve the functionality.  Did you see that there's a USB PLM now?

jondecker76

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 763
    • View Profile
Re: Getting IP address from Device in GSD
« Reply #8 on: March 23, 2009, 03:44:13 am »
Pete

Could you post the information you have regarding controlling the box via telnet?  I'd be interested in doing a c++ device for this, and integrating your instant queue with the normal datagrids

PeteK

  • Guru
  • ****
  • Posts: 408
    • View Profile
Re: Getting IP address from Device in GSD
« Reply #9 on: March 23, 2009, 06:15:39 am »
http://forums.rokulabs.com/viewtopic.php?p=119593

I've run into an issue with GSD in working to integrate the Roku box.  The box only accepts 1 telnet connection at a time, and GSD seems to be opening two connections.  Attempts to communicate with the box using the second connection therefore don't work, requiring a power cycle of the Roku unit.  I'm currently investigating.

-Peter

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: Getting IP address from Device in GSD
« Reply #10 on: April 02, 2009, 04:34:55 am »
Check the log, it may be that the socket connection is still open.. or cannot connect, because the other end (not gsd) isn't designed for multiple connections.. (ie, 1 socket connection at a time, and it must be closed prior to reopening)

Try adding a conn_.close() in the apropriate GSD routine.

I've used IP via GSD for a lot of things, including my first stab at Insteon...

Good Luck, HTH

Dan

OK, Dan.  I'll give it a shot.  I've started revisiting my Insteon code in hopes of getting it cleaned up and improve the functionality.  Did you see that there's a USB PLM now?

Yeah, there's quite a bit of new Insteon hardware.. Motion/Occupancy sensors, low voltage I/O, door/window sensors, etc.

Also, there's another new controller with IP.  I've not looked at the specifics yet..

I haven't found the USB PLM as of yet, but then again, I haven't really looked too hard.

It should be pretty straight forward, any idea if it's a USB/serial device or HID?

Regards,

Dan

The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.