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.

TCP connection
#1
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 startsSad
Reply


Forum Jump: