Install the following packages on your OpenWRT device:
Connect your Arduino on the USB port and check the kernel messages.
It should mention a new
ttyACM0 device; that's our Arduino.
Now fire up
socat to listen on a TCP port and connect it to
/dev/ttyACM0 like this:
# socat tcp-l:1234,reuseaddr,fork file:/dev/ttyACM0,nonblock,raw,echo=0,waitlock=/var/run/tty,b9600
Change your baudrate (here
9600) and port (here
Now you should be able to telnet to the device on another machine like this:
$ telnet 192.168.1.1 1234
In order to create it a always-running background service we should hook in to OpenWRT's services, but this will do as well:
#!/bin/ash DEV=/dev/ttyACM0 PORT=50000 BAUD=9600 while true; do if [ -e $DEV ] then socat tcp-l:$PORT,reuseaddr,fork file:$DEV,nonblock,raw,echo=0,waitlock=/var/run/tty,b$BAUD else sleep 2 fi done
Put it somewhere and make it executable (
chmod +x filename).
Add it to boot time by editing
# make sure it's above 'exit 0'! /path/to/the-script_above.sh & exit 0