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.

RS232 trasmission
#1
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
Reply
#2
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'
Reply
#3
(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
Reply
#4
You forgot to attach a file. You need to provide a protocol description.
Reply
#5
(17.04.2020, 08:40)admin Wrote: You forgot to attach a file. You need to provide a protocol description.
Unfortunately, the protocol cannot be published because it is covered by the manufacturer's right of confidentiality
Reply
#6
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.
Reply
#7
(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
Reply
#8
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.

Attached Files Thumbnail(s)
   
Reply
#9
You can send binary data like this:
Code:
hexvalue = string.char(0x00, 0x00, 0x00, 0x20, 0x01, 0x00, 0x1A, 0x3B)
Reply
#10
ok, now i can't understand because in the registration window I can see any think.

Attached Files Thumbnail(s)
   
Reply
#11
You are still using half duplex, set it to full or it won't work. Use loghex instead of log for binary data.
Reply
#12
(17.04.2020, 13:44)admin Wrote: You are still using half duplex, set it to full or it won't work. Use loghex instead of log for binary data.
Sorry I've changed it before and I forgot to turn back in full..... My mistake
Reply
#13
(17.04.2020, 13:44)admin Wrote: You are still using half duplex, set it to full or it won't work. Use loghex instead of log for binary data.
ok now it works.......
Reply


Forum Jump: