Logic Machine Forum
Gefen Integration - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Gefen Integration (/showthread.php?tid=284)



Gefen Integration - josep - 21.04.2016

Hello again,


I need to setup a Gefen 4x2 UHD Matrix on a installation and I like to know if someone installed it before, I read it is possible to control the Matrix via IP... I add a user manual and I try to make a scrip to control it. BR.


RE: Gefen Integration - Erwin van der Zwart - 21.04.2016

Hi,

Try this to set IP config over RS232 (if needed):

Code:
-- To set up IP control, the network settings for the 4K Ultra HD 4x2 Matrix for HDMI must be configured via RS-232.

-- RS232 Script to set IP control

-- Load Modules
require('serial')

-- Open connection
port = serial.open('/dev/RS232', {
 baudrate = 115200,
 databits = 8,
 stopbits = 1,
 parity = 'none',
 duplex = 'full'
})

-- Function to read until carier return is received or timeout
function readline(port, timeout)
 local char, buf
 buf = {}
 while true do
   char = port:read(1, timeout or 0.2)
   -- error (timeout) or newline, stop
   if char == nil or char == '\n' then
     break
   -- ignore cr char
   elseif char ~= '\r' then
     table.insert(buf, char)
   end
 end
 return table.concat(buf)
end

-- Function to write to port and return a reply
function writetoport(port, timeout, command)
    -- Write data to port as HEX
 port:write(command)
    -- Call function to read data
 line = readline(port, timeout)
 if #line > 0 then
     return line
 else
   return "No reply received"
 end
end

-- Send command to port and wait for reply or timeout
reply = writetoport(port, 1, '#sipadd 192.168.2.190')-- Timeout is set to 1 second (default = 0.2)
log(reply)

-- Send command to port and wait for reply or timeout
reply = writetoport(port, 1, '#snetmask 255.255.0.0')-- Timeout is set to 1 second (default = 0.2)
log(reply)

-- Send command to port and wait for reply or timeout
reply = writetoport(port, 1, '#sgateway 192.168.1.5')-- Timeout is set to 1 second (default = 0.2)
log(reply)

-- Send command to port and wait for reply or timeout
reply = writetoport(port, 1, '#set_telnet_port 23')-- Timeout is set to 1 second (default = 0.2)
log(reply)

-- Send command to port and wait for reply or timeout
reply = writetoport(port, 1, '#set_http_port 80')-- Timeout is set to 1 second (default = 0.2)
log(reply)

-- Send command to port and wait for reply or timeout
reply = writetoport(port, 1, '#set_udp_remote_ip 192.168.1.227')-- Timeout is set to 1 second (default = 0.2)
log(reply)

-- Send command to port and wait for reply or timeout
reply = writetoport(port, 1, '#set_udp_port 56')-- Timeout is set to 1 second (default = 0.2)
log(reply)

-- Send command to port and wait for reply or timeout
reply = writetoport(port, 1, '#set_udp_remote_port 50008')-- Timeout is set to 1 second (default = 0.2)
log(reply)

-- REBOOT MATRIX NOW

And after reboot try this to control:
Code:
-- Control over UDP

-- Function Udp Send
function udpsend(message,ip,port)
 require('socket')
 local client = socket.udp()
 if client then
   client:sendto(message,ip,port)
   client:close()
 end
end

result, err = udpsend('#power 0','192.168.1.227', 50008) -- Command to power on
log(result)

result, err = udpsend('#power 1','192.168.1.227', 50008) -- Command to power off
log(result)

Not tested so i hope it works for you (;

BR,

Erwin van der Zwart