Search

Recent Posts

Tags


« | Main | »

Arduino – using SerialIP networking with Linux (Fedora)

By Dale Reagan | June 22, 2011

Using SerialIP with Arduino should be relatively simple – just don’t forget any of the required set-up steps.

Why bother? Why not just add an ethernet/wireless component?

My current Hardware/Operating System & tool setup:

Sample steps to configure and use SLIP (SerialIP) with Arduino Uno (your steps may vary based on your OS/OS version/Arduino version, etc…)

  1. Install & test slattach on your Linux system
  2. download the library, compile and upload the SerialIP test program to your Arduino; note that the current code contains a ‘hard-coded’ IP address which you should change to meet your needs
  3. identify/locate the TTY port for YOUR Arduino
  4. open a terminal session AND attach a serialIP process to the TTY port used by Arduino (slattach)
  5. open another terminal session and complete the network IP configuration
    • activate the ‘slip port’  (slX)
    • create a network path/route
    • review the route
  6. try a ping test
  7. optional – create some simple host table entries

In Terminal Session/Window #1 – Start a serialIP session in ‘debug mode’ – you want to identify the SerialIP-Interface (sl0 below):

slattach -d -m -L -s 115200 -p slip ttyACM0 -o /tmp/slattach.log #<ENTER>
slattach: tty_open: looking for lock
slattach: tty_open: trying to open /dev/ttyACM0
slattach: tty_open: /dev/ttyACM0 (fd=3) slip started on ttyACM0 interface sl0

For more information on slattach options, try ‘man slattach‘ on your system.

In Terminal Session/Window #2 – Activate the Slip Interface:

ifconfig sl0 up # <ENTER>
ifconfig # <ENTER> should report ALL NETWORK Interfaces - is 's1X' present?

In Terminal Session/Window #2 – Add a network path from the Slip interface to a local network device:

ifconfig sl0 192.168.5.1 dstaddr 192.168.5.2  ## Or

ifconfig sl0 ardrouter dstaddr arduino ## requires /etc/hosts table entries

In Terminal Session/Window #2 – Review your routing tables:

# ifconfig sl0 192.168.5.1 dstaddr 192.168.5.2
# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
arduino         *               255.255.255.255 UH    0      0        0 sl0
192.168.5.0     *               255.255.255.0   U     0      0        0 eth1

Entries in /etc/hosts file:

### arduino Uno slip
192.168.5.2     arduino
192.168.5.1     ardrouter

In Terminal Session/Window #2 – A ping test (yes, much slower than ‘normal’ 10/100 Ethernet, but workable):

PING arduino (192.168.5.2) 56(84) bytes of data.
64 bytes from arduino (192.168.5.2): icmp_seq=1 ttl=64 time=16.8 ms
64 bytes from arduino (192.168.5.2): icmp_seq=2 ttl=64 time=20.0 ms
64 bytes from arduino (192.168.5.2): icmp_seq=3 ttl=64 time=18.1 ms

--- arduino ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2021ms
rtt min/avg/max/mdev = 16.828/18.326/20.004/1.307 ms

So, big deal!  Besides, “Look Ma! No NIC!”  Now what?  Hmm, perhaps:

Any bad news about this solution?

Other SLIP (serial line IP) type solutions:

A Bash Script ‘Wrapper’

Sample Bash Script snippet

###
function go_slip {
printf "\n\t Setting_Up_Arduino_Slip\n"
printf "\t###########################\n"
###
### use Debug mode; place in background with '&'
### use 'man slattach' for local system docs
###
set -x
slattach -d -m -L -s 115200 -p slip ttyACM0 -o /tmp/slattach.log &
###
set -
SLEEP=15
echo "Sleep: ${SLEEP} ..."
##########
## wait 15 seconds before configuring the slip 'interface'
## actual time required may vary - what matters is that
## the 'ping test' works - you are connected when it works
## you have a 'problem' when it does not...
##########
sleep ${SLEEP}
## reset interfaces - turn them off/on
ifconfig sl0 down
ifconfig eth1 down
ifconfig eth1 up
ifconfig sl0 up
## set the IP address for the SLIP interface (Arduino)
ifconfig sl0 192.168.5.20
ifconfig eth1 sl0
## establish a path/route to/from host 'Arduino'
ifconfig sl0 192.168.5.1 dstaddr 192.168.5.20
## display info on the two interfaces
ifconfig eth1 sl0
## display the 'network routing table'
route
## try a 'ping-test'
STAT=$(ping -c 3 arduino)
if [[ "${STAT}" -ne 0 ]] ; then echo "No ping result..." ; fi
set -x
ping -c 3 arduino
set -
}
###
#### MAIN ####
## add host entry for 'arduino' to /etc/hosts or DNS
## assumes that 'slattach' will connect to 'sl0';
## assumes use of 'sudo' or user is ROOT/UID=0
## assumes ttyACM0 for Arduino connection
## assumes eth1 is dedicated for this network purpose (i.e. eth0 is 'normal' network
go_slip

### /etc/hosts file – arduino Uno slip

## IP used for Arduino SerialIP
192.168.5.2 arduino arduino.local_net

## IP for dedicated NIC in  host PC

192.168.5.1 ardrouter ardrouter.local_net


Topics: 1-Wire, Computer Technology, Problem Solving, System and Network Security, Unix-Linux-Os | Comments Off on Arduino – using SerialIP networking with Linux (Fedora)

Comments are closed.


________________________________________________
YOUR GeoIP Data | Ip: 73.21.121.1
Continent: NA | Country Code: US | Country Name: United States
Region: | State/Region Name: | City:
(US only) Area Code: 0 | Postal code/Zip:
Latitude: 38.000000 | Longitude: -97.000000
Note - if using a mobile device your physical location may NOT be accurate...
________________________________________________

Georgia-USA.Com - Web Hosting for Business
____________________________________