1

I am working on sending NMEA 2000 messages to the network via the YD ethernet gateway. Basically, I want to implement the CAN Log Viewer's tool to send CAN messages in my program and make them appear in the CAN Log Viewer. I use Python and I managed to connect to the gateway by a TCP client socket and read messages, but when I try to send messages to the gateway(in the same format as displayed in the CAN Log Viewer's send messages tool) they don't appear nor do they appear in my program which reads the messages. This is what I've tried:

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('192.168.4.1', 1457))
msg = b'0DF20EB3 00 00 00 00 01 00 01 00' # also tried bytes.fromhex('0DF20EB3 00 00 00 00 01 00 01 00')
sock.send(msg)

I could use some help with the following questions:

  1. Is it possible to send NMEA messages to the gateway by a Pythonic TCP socket?
  2. Are the IP address and port of the CAN the same as the gateway's? Or do I need to send those messages to another address?
  3. What is the format of the message that needs to be sent in order for it to be parsed correctly? Does it need to be in binary/hexadecimal/text?
  4. What number should I use for the source address? The message I want to send is 127502 - Switch Bank Control. I'll appreciate any kind of help! Thanks in advance
yuvalnac1
  • 21
  • 2

1 Answers1

1

For whomever it may concern, I've solved this issue. The message needs to be send as raw data with carriage return and line feed symbols at the end. For example with the message I was sending: msg = '0DF20EB3 00 00 00 00 01 00 01 00\r\n' sock.send(msg.encode())

yuvalnac1
  • 21
  • 2