![]() |
|
TCP connection - Printable Version +- LogicMachine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10) +--- Thread: TCP connection (/showthread.php?tid=304) |
TCP connection - buuuudzik - 18.05.2016 Hello, I must connect with a device which is a gateway for CAN-based system via TCP which sends and receive frames with RAW data. Do you know how can I create such mechanism? Frame size is from 29 to 37 bytes and this is start-bit: "0F" and this is stop-bit: "04". I've tried based on available other integration manuals and all did is that I can send to the bus command and it works: Code: require('socket')
ip = '192.168.0.15'
port = 10001
cmd = string.char(0x0F, 0x00, 0x10, 0x00, 0x00, 0x80, 0x01, 0x00, 0x01, 0x04, 0x00, 0x01, 0x00, 0x00, 0x5A, 0x04)
sock = socket.tcp()
sock:settimeout(3)
res, err = sock:connect(ip, port)
if res then
res, err = sock:send(cmd)
if res then
print('send OK')
else
print('send failed: ' .. tostring(err))
end
else
print('connect failed: ' .. tostring(err))
end
sock:close()But this is easier than receiving data and checking from which point the frame starts
|