PJLink TCP protocol

Control video projector via PJLink TCP protocol from LogicMachine #

Task #

How to turn a video projector ON and OFF using PJLink TCP protocol?

Event script #

Map the following script to a 1 bit object. Change the projector's IP address (192.168.1.5) and port (4352) as needed.

require('socket')

value = event.getvalue()

ip = '192.168.1.5'
port = 4352

if value == 1 then
  cmd = '%1POWR 1\r\n'
else
  cmd = '%1POWR 0\r\n'
end

sock = socket.tcp()
sock:settimeout(1)

res, err = sock:connect(ip, port)

if res then
  res, err = sock:send(cmd)

  if res then
    alert('Send OK')
  else
    alert('Send failed: %s', tostring(err))
  end
else
  alert('Connect failed: %s', tostring(err))
end