17.04.2020, 08:22
good morning,
I have a problem on serial transmission, I simulated with a PC and transmitting in ascii format this patch HEX it works, the slave answer with ok. So the patch is correct. If I transmit using this code on the LM I have no answer from the slave. Any suggest?
thanks to everybody will help me.
Best regards
--port check
if not port then
require('serial')
log('porta non aperta')
comm_on, err = serial.open('/dev/RS232', { baudrate = 57600, parity = 'even', duplex = 'half', databits = 8 , stopbits = 1 })
if comm_on then
log('Porta aperta')
else
log('errore apertura porta in: ', err)
end
end
-- loop while condition is met
while (1) do
if comm_on then
hexvalue = ('00,00,00,20,01,00,1A,3B')
log('value: ',hexvalue)
comm_on:write(hexvalue)
data, err = comm_on:read(2,1)
log('Valore letto = ', data)
log('errore letto = ', err)
end
end
I have a problem on serial transmission, I simulated with a PC and transmitting in ascii format this patch HEX it works, the slave answer with ok. So the patch is correct. If I transmit using this code on the LM I have no answer from the slave. Any suggest?
thanks to everybody will help me.
Best regards
--port check
if not port then
require('serial')
log('porta non aperta')
comm_on, err = serial.open('/dev/RS232', { baudrate = 57600, parity = 'even', duplex = 'half', databits = 8 , stopbits = 1 })
if comm_on then
log('Porta aperta')
else
log('errore apertura porta in: ', err)
end
end
-- loop while condition is met
while (1) do
if comm_on then
hexvalue = ('00,00,00,20,01,00,1A,3B')
log('value: ',hexvalue)
comm_on:write(hexvalue)
data, err = comm_on:read(2,1)
log('Valore letto = ', data)
log('errore letto = ', err)
end
end