Archive for October, 2017

We have one of these devices that we wanted to get working in linux, specifically RHEL6.

Here’s what we did.

First, you need to install the libftdi libraries. There are rpm packages for those on the EPEL site, if we couldn’t get them directly from RedHat. (I can’t remember where we got those from, but it was pretty easy to find.)

The problem we had was that we wanted the device to be automatically created at login or when it was plugged in. And we didn’t want to have to be root to use it. So here is what we set up.

* Create /etc/sysconfig/modules/ftdi_sio.modules
We are creating this so that the ftdi_sio module is automatically loaded at boot

#!/bin/sh
exec /sbin/modprobe ftdi_sio >/dev/null 2>&1

* Create /etc/modprobe.d/ftdi_sio.conf
This is for the options that we would use with the modprobe command

options ftdi_sio vendor=0x0c52 product=0xe402

Note that we got the vendor and product ids by running lsusb when the device was plugged in.

* Create /etc/rc.d/init.d/setup_Seamax
This is a script to run at startup. It adds the ids of the device to a file. However, that file is not created unless the module is loaded, which is why we did the previous two steps. Also note that this script could be better written, I just copied an old script I had around and edited it.

#!/bin/sh

# setup_Seamax

# chkconfig: 2345 99 10
# description: add device info about Seamax

start() {
  echo -n "Setting up Seamax: "
  echo "0c52 e402" > /sys/bus/usb-serial/drivers/ftdi_sio/new_id
  RETVAL=$?
  echo
  return $RETVAL
}

case "$1" in 
  start)
    start
    ;;

  *)
    echo "Usage: $0 {start}"
    exit 1

esac

exit $RETVAL
* Add the script to chkconfig and make sure that it will start on boot
# chkconfig --add setup_Seamax
# chkconfig --list setup_Seamax
setup_Seamax   	0:off	1:off	2:on	3:on	4:on	5:on	6:off

* Create /etc/udev/rules.d/10-uc.rules
This will run when the device is detected and will set the owner/permissions that we want

SUBSYSTEM=="tty", ATTRS{idVendor}=="0c52", ATTRS{idProduct}=="e402", OWNER="kelby", MODE="0666"

REBOOT

After reboot, you should see /dev/ttyUSB0 as being owned by our regular user.

$ ll /dev/ttyUSB0 
crw-rw-rw- 1 kelby dialout 188, 0 Oct 11 09:47 /dev/ttyUSB0