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

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?

The GSD code will create a serial connection if the COM Port is not empty and not ZeroOtherwise, 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

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?

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 »

Logged

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?

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?

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.

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?