Control video projector via PJLINK protocol
Example: Control video projector via PJLINK protocol from LogicMachine
Task
How to turn ON and OFF video projector using PJLINK protocol? Use LogicMachine with the following event-based script.
Event-based script
Add this script for the grp address which will control ON/OFF from visualization. In this example video projector’s IP is 192.168.1.5, port 4352.
- 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