OpenWrt/acemonstertoys-serial

From Wiki
< OpenWrt
Revision as of 10:16, 1 October 2012 by Marcluer (talk | contribs) (Die Seite wurde neu angelegt: „== Interfacing with Arduino == Prereqs opkg install the following coreutils-stty - 8.8-1 (lets you talk to serial ports) kmod-usb-serial - 2.6.39.4…“)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Interfacing with Arduino

Prereqs 
opkg install  the following
  coreutils-stty - 8.8-1 (lets you talk to serial ports)
  kmod-usb-serial - 2.6.39.4-1 (base driver for USB serial ports)
and your serial port driver, probably
  kmod-usb-serial-cp210x (CP201x based USB/serial adapters)
  kmod-usb-serial-pl2303 (PL2303 based USB/serial adapters
  kmod-usb-serial-ftdi - (FTDI based USB/serial adapters, used in older Arduinos)
  kmod-usb-acm (USB/serial adapters implementing the standardized USB CDC protocol, such as the Teensy or Arduino Uno)

Can't hurt to install them all


Script to read from arduino


#!/bin/sh
#/usr/bin/readuino.sh
# simple script to tail newline terminated messages from the arduino
# adjust the head number depending on your arduino messages

if  ! [ -f /tmp/isrunning ]; then
  if  [ -c /dev/ttyUSB0 ]; then
 
      echo $$ > /tmp/isrunning                   
      /usr/bin/stty -F /dev/ttyUSB0 raw speed 9600    
      while [ 1 ]; do                        
              if [ -c /dev/ttyUSB0 ]; then
                      head -n 3 /dev/ttyUSB0 >/tmp/volts
                      sleep 1         
              else
                      # USB dissapeared. 
                      echo "Arduino no longer attached" >/tmp/volts
                      rm /tmp/isrunning
                      exit            
              fi
      done
  else
      echo "Arduino not yet  attached" >/tmp/volts
  fi
fi