UDP SOCKET - 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: UDP SOCKET (/showthread.php?tid=2236) |
UDP SOCKET - Angeles - 12.09.2019 Hello: We have several devices on the network that send packages continuously: energy meters. We need to read these packages and we have tried using the following scritp: if not server then require('socket') server = socket.udp() server:setsockname('*', 8891) server:settimeout(1) end data = server:receive() if data then loghex(data) end If we log setsockename address already in use. Is this method correct to receive that kind of data from network. Thanks. RE: UDP SOCKET - admin - 12.09.2019 This means that another script is already bound to this UDP port. You can find script PID like this: Code: res = io.readfile('netstat -puln | grep 8891') RE: UDP SOCKET - Angeles - 27.09.2019 (12.09.2019, 11:14)admin Wrote: This means that another script is already bound to this UDP port. You can find script PID like this: Hi again: The system that I try to read is a energy meter concentrator. We manage to communicate with the device through the usr-vcom application and we receive data. The system was already installed when our clients hire us but anybody know how read the data and there is not any program. We have test with protocol modbus, mbus and there is no response. The communication throught USR-TCP232-T2 - (TTL - ETHERNET). When a create a socket.tcp the connection is correct but receive is nil. What could be the problem.? Thanks for your help Best Regards. RE: UDP SOCKET - admin - 30.09.2019 ModBus won't work like this as ModBus TCP is a different protocol. If you are calling socket:receive() without any arguments it will try to read a whole line ending with \n character. For binary protocols this won't work correctly. You can read data by one byte at a time: byte, err = socket:receive(1) |