Logic Machine Forum
Commands to devices over LAN - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: General (https://forum.logicmachine.net/forumdisplay.php?fid=2)
+--- Thread: Commands to devices over LAN (/showthread.php?tid=864)



Commands to devices over LAN - AlexLV - 22.06.2017

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=launch_media_url&media_url=nfs://192.168.0.100:/VideoStorage:/SomeFolder/file.mkv


RE: Commands to devices over LAN - Erwin van der Zwart - 22.06.2017

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


RE: Commands to devices over LAN - AlexLV - 23.06.2017

Erwin,

Thank you for help.


RE: Commands to devices over LAN - AlexLV - 24.06.2017

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


RE: Commands to devices over LAN - Erwin van der Zwart - 24.06.2017

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


RE: Commands to devices over LAN - admin - 25.06.2017

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.


RE: Commands to devices over LAN - Erwin van der Zwart - 25.06.2017

Hi

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

BR,

Erwin


RE: Commands to devices over LAN - AlexLV - 25.06.2017

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.


RE: Commands to devices over LAN - Erwin van der Zwart - 25.06.2017

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


RE: Commands to devices over LAN - AlexLV - 26.06.2017

Erwin,

super, thank you for helping