This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Commands to devices over LAN
#1
Hello,

I have mediaplayer with remote control over LAN. How can I send command from my script? As example this type:

http://192.168.0.100/cgi-bin/do?cmd=laun...r/file.mkv
Reply
#2
Hi,

Try this:
Code:
require('socket.http')
socket.http.TIMEOUT = 15
socket.http.request('http://192.168.0.100/cgi-bin/do?cmd=launch_media_url&media_url=nfs://192.168.0.100:/VideoStorage:/SomeFolder/file.mkv')
BR,

Erwin
Reply
#3
Erwin,

Thank you for help.
Reply
#4
Erwin,

Can you explain me a little to me? What parameter socket.http.TIMEOUT does? Also, I made resident script. When I start it nothing going on.. When I stop it - all works - http command sends to device over network.. How to make command to be send without delay, or may be I need something else to add or somehow control this resident script? Sorry, may be simple, but I still not found solution
Reply
#5
Hi,

I't makes the socket wait for max 15 seconds for a response, it's not a delay, just a parameter to wait a bit longer when the response is not fast enough. When the response is received within something like 100 ms the timeout will never be used. You can leave it out, but then it will use the default socket timeout and that one is i believe something like 3 seconds.

In your case the timeout is probably not even needed as you don't use the response, you just send a command to the other device.

There must be another reason why your script is hanging ..

Can you show me what you have build?

BR,

Erwin
Reply
#6
Default timeout is 60 seconds. If you have a resident script then the command is sent in an infinite loop. You probably need an event script to send it only once.
Reply
#7
Hi

Sorry i missed that you wrote you run it from resident (:

BR,

Erwin
Reply
#8
Ervin,

Does it mean I use one group, as example 2/2/2, if I send to it 1 or something else depends of used type in event script - my command will be sent? And also I found that my commands I can send directly from visualization using http type for it.
Reply
#9
Hi,

Yes, if you want to send multiple commands from a single event based script you can create a byte object and attach this script to it:
Code:
require('socket.http')
socket.http.TIMEOUT = 15
value = event.getvalue()
if value == 0 then
  socket.http.request('http://192.168.0.100/cgi-bin/do?cmd=launch_media_url&media_url=nfs://192.168.0.100:/VideoStorage:/SomeFolder/file.mkv')
elseif value == 1 then
  socket.http.request('http://192.168.0.100/cgi-bin/do?cmd=launch_media_url&media_url=nfs://192.168.0.100:/VideoStorage:/SomeFolder/file1.mkv')
elseif value == 2 then
  socket.http.request('http://192.168.0.100/cgi-bin/do?cmd=launch_media_url&media_url=nfs://192.168.0.100:/VideoStorage:/SomeFolder/file2.mkv')
elseif value == 3 then
  socket.http.request('http://192.168.0.100/cgi-bin/do?cmd=launch_media_url&media_url=nfs://192.168.0.100:/VideoStorage:/SomeFolder/file3.mkv')
elseif value == 4 then
  socket.http.request('http://192.168.0.100/cgi-bin/do?cmd=launch_media_url&media_url=nfs://192.168.0.100:/VideoStorage:/SomeFolder/file4.mkv')
end
In your visu you create 5 buttons that send fixed values 0 to 4 all on the same byte object.

BR,

Erwin
Reply
#10
Erwin,

super, thank you for helping
Reply


Forum Jump: