1

I am trying to send LinBus protocol serial commands over the ethernet port of my Raspberry pi to a linear actuator connected on the other end via ethernet.

Currently, I am using pyserial script to connect to /dev/ttyAMA0 on the pi and using socat to intercept traffic on that port and send it to the ethernet interface.

So far my test python script is:

import serial
serialport = serial.Serial("/dev/ttyAMA0", 5500, timeout=0.5)
data="\x03"
serialport.write(data.encode())
reply=serialport.readlines(1)
print(reply)

I am using the following socat command:

sudo socat pty, link=/dev/ttyAMA0, raw tcp:10.1.1.30:5501

the ethernet interface has been configured to have the static ip as described in the socat command.

When I run the socat command I receive:

socat[852] E read(7, 0x143ad50, 8192): Connection refused

The Raspberry pi has been configured for UART and the /dev/ttyAMA0 port is shown when using ls /dev

Essentially, I am trying to send a special linbus frame containing serial byte commands such as "0x8000" from a Python script through the ethernet port to a linear actuator which is listening on the other end.

Am I approaching this the wrong way? If so, what do I need to do?

Thank you for your help!

Jon Head
  • 19
  • 1
  • 1
    You should just create a direct network connection to your destination, no need to redirect something with socat. You might consider socat if you have a program that insists on another interface and you can't modify it. – RalfFriedl Apr 25 '19 at 13:53

1 Answers1

0

/dev/ttyAMA0 is connected to Bluetooth

See How do I make serial work on the Raspberry Pi3 , Pi3B+, PiZeroW

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • I have changed the serial interface to /dev/serial0 but socat refuses to connect to that interface. – Jon Head Apr 26 '19 at 01:53