RS232 trasmission - 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: RS232 trasmission (/showthread.php?tid=2599) |
RS232 trasmission - CristianAgata - 17.04.2020 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 RE: RS232 trasmission - admin - 17.04.2020 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' RE: RS232 trasmission - CristianAgata - 17.04.2020 (17.04.2020, 08:25)admin Wrote: I suppose you have LM5 with shared RS232/RS485 port. You must use duplex = 'full' for RS232.I've tried using that change but I've no answer. Lock at attached file RE: RS232 trasmission - admin - 17.04.2020 You forgot to attach a file. You need to provide a protocol description. RE: RS232 trasmission - CristianAgata - 17.04.2020 (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 RE: RS232 trasmission - admin - 17.04.2020 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. RE: RS232 trasmission - CristianAgata - 17.04.2020 (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 RE: RS232 trasmission - CristianAgata - 17.04.2020 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. RE: RS232 trasmission - admin - 17.04.2020 You can send binary data like this: Code: hexvalue = string.char(0x00, 0x00, 0x00, 0x20, 0x01, 0x00, 0x1A, 0x3B) RE: RS232 trasmission - CristianAgata - 17.04.2020 ok, now i can't understand because in the registration window I can see any think. RE: RS232 trasmission - admin - 17.04.2020 You are still using half duplex, set it to full or it won't work. Use loghex instead of log for binary data. RE: RS232 trasmission - CristianAgata - 17.04.2020 (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 RE: RS232 trasmission - CristianAgata - 17.04.2020 (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....... |