Logic Machine Forum
Control BenQ projector with RS232 - 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: Control BenQ projector with RS232 (/showthread.php?tid=2648)



Control BenQ projector with RS232 - victor.back - 20.05.2020

Hi 

I have some trouble to send control commands ON/OFF to a BenQ MS517H usin gfollowing event based script. 

Code:
require('serial')

device = '/dev/ttyUSB0'

port = serial.open(device, { baudrate = 9600, parity = 'none', stopbits = 1  })

-- get value of KNX object
value = event.getvalue()

if (value == true) then
  -- send power on command with returns to make them stick
  char = "<CR>*pow=on#<CR>" 
  port:write(char)
else
  -- send power off command
  char = "<CR>*pow=off#<CR>" 
  port:write(char)
end


-- close port
port:close()



RE: Control BenQ projector with RS232 - admin - 20.05.2020

<CR> is \r (carriage return):
Code:
char = "\r*pow=on#\r"



RE: Control BenQ projector with RS232 - benanderson_475 - 20.05.2020

(20.05.2020, 10:30)victor.back Wrote: Hi 

I have some trouble to send control commands ON/OFF to a BenQ MS517H usin gfollowing event based script. 

Code:
require('serial')

device = '/dev/ttyUSB0'

port = serial.open(device, { baudrate = 9600, parity = 'none', stopbits = 1  })

-- get value of KNX object
value = event.getvalue()

if (value == true) then
  -- send power on command with returns to make them stick
  char = "<CR>*pow=on#<CR>" 
  port:write(char)
else
  -- send power off command
  char = "<CR>*pow=off#<CR>" 
  port:write(char)
end


-- close port
port:close()
I had an issue with benq once before, I think the solution was to replace <CR> with hex terminator 0D
Try,
char = string.char(“0x0D”)..”*pow=off”..string.char(“0x0D”)

Can you test the command by sending it from a terminal from pc


RE: Control BenQ projector with RS232 - victor.back - 25.05.2020

(20.05.2020, 10:33)admin Wrote: <CR> is \r (carriage return):
Code:
char = "\r*pow=on#\r"
Thanks, changed that but no success.

(20.05.2020, 10:43)benanderson_475 Wrote:
(20.05.2020, 10:30)victor.back Wrote: Hi 

I have some trouble to send control commands ON/OFF to a BenQ MS517H usin gfollowing event based script. 

Code:
require('serial')

device = '/dev/ttyUSB0'

port = serial.open(device, { baudrate = 9600, parity = 'none', stopbits = 1  })

-- get value of KNX object
value = event.getvalue()

if (value == true) then
  -- send power on command with returns to make them stick
  char = "<CR>*pow=on#<CR>" 
  port:write(char)
else
  -- send power off command
  char = "<CR>*pow=off#<CR>" 
  port:write(char)
end


-- close port
port:close()
I had an issue with benq once before, I think the solution was to replace <CR> with hex terminator 0D
Try,
char = string.char(“0x0D”)..”*pow=off”..string.char(“0x0D”)

Can you test the command by sending it from a terminal from pc
I tried with Tera term but didnt get it to work. 
Managed to send power on command from a Zennio SKX Open with the HEX code 0D2A706F773D6F6E230D.


Sorry but I didnt understand how to change the script with your solution. Im an beginner in LUA.


RE: Control BenQ projector with RS232 - admin - 25.05.2020

0D2A706F773D6F6E230D is the same as "\r*pow=on#\r"
Maybe the serial port settings are wrong or the cable is the problem? Are you using straight or cross-over cable?


RE: Control BenQ projector with RS232 - victor.back - 03.06.2020

The problem chould be the cable. I´ve used an old cable that I have used for programming before, but don´t know if its straight or cross-over.
What type shcould i have?


RE: Control BenQ projector with RS232 - admin - 03.06.2020

Usually you need cross so RX on one side is connected to TX on the other side.