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 suppose you have LM5 with shared RS232/RS485 port. You must use duplex = 'full' for RS232.
Also, are you sure that the protocol does not have some delimiter like a new line? Try this:
(17.04.2020, 08:25)admin Wrote: I suppose you have LM5 with shared RS232/RS485 port. You must use duplex = 'full' for RS232.
Also, are you sure that the protocol does not have some delimiter like a new line? Try this:
Code:
hexvalue = '00,00,00,20,01,00,1A,3B\r\n'
I've tried using that change but I've no answer. Lock at attached file
Then I cannot help unfortunately. What you can do is connect LM to your PC via RS232, send the sequence from PC and log what you get in LM. Just make sure that duplex is set to full.
(17.04.2020, 08:49)admin Wrote: Then I cannot help unfortunately. What you can do is connect LM to your PC via RS232, send the sequence from PC and log what you get in LM. Just make sure that duplex is set to full.
This is an idea, so I can see what the lm gives to the device.... Thanks
17.04.2020, 11:51 (This post was last modified: 18.04.2020, 18:46 by CristianAgata.)
hi Admin,
thanks to your suggest i've find an answer....... But i don't know how fix the problem. I need to send the data in numeric mode not in string. In the image attached you can see the two different telegram. The first green is the numeric telegram followed by the yellow answer. The second telegram (string mode that it is the same that my LM Re:actor generate) infact it doesn't work.