This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

RS-232 Projector control
#1
Hello,
I am trying to control a projector via RS232 protocol. I own LogicMachine 5 Lite.
So far it has created a virtual object for simple on/off control, I have attached an event-script to it:


Code:
require('serial')

device = '/dev/RS232'

port = serial.open(device, { baudrate = 9600, parity = 'none', databits = 8, stopbits = 1, duplex = full })
port:flush()

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

if (value == true) then
  -- send power on command with returns to make them stick
  char = "\r*pow=on#\r"
  log("wyslka on")
  res, err = port:write(char)
  log('blad:', err)
else
  -- send power off command
  char = "\r*pow=off#\r"
  log("wyslka off")
  res, err = port:write(char)
  log('blad: ', err)
end

-- close port
port:close()

Is the above script sufficient? I understand that by defining the communication in the script I don't need to set anything else in the tab with "Modbus"?
In the logs it seems to me that the script returns a "nil" error when writing, what does this mean?

I have the LM5 Lite + Ext (i.MX6) firmware uploaded.
The cable issues can be dismissed, I have swapped TX with RX more than once.

I would be grateful for any help.

Log response in attachment.

Attached Files Thumbnail(s)
   
Reply
#2
Are you sure it is RS232 and not TTL? Drop some documentation.
------------------------------
Ctrl+F5
Reply
#3
(15.03.2023, 14:36)Daniel Wrote: Are you sure it is RS232 and not TTL? Drop some documentation.

Yes, I am pretty sure it is RS232.
In attachment there are documentation which I got from producer.

Attached Files
.pdf   LX-NZ3_External_Command_List.pdf (Size: 225.4 KB / Downloads: 2)
.pdf   LX-NZ3_RS-232C_Commmand _List_V1.02.pdf (Size: 392.67 KB / Downloads: 2)
Reply
#4
nil means no error. You don't need to change anything in Modbus, it is not related to using serial ports in scripts. Check that projector has the same baud rate as the script. Check if you get any reply before closing the port:
Code:
res, err = port:read(-1, 2)
log(res, err)
-- close port
port:close()
Do this with reversed RX/TX as well. Make sure that GND is connected between the projector and LM.
Reply


Forum Jump: