LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-01-2012, 05:39 PM   #1
lev0207
LQ Newbie
 
Registered: Feb 2009
Location: Portsmouth, Rhode Island
Distribution: Ubuntu
Posts: 6
Blog Entries: 1

Rep: Reputation: 0
Best Practice for determining if a USB serial device is still valid.


I have a micro-controller board connected to a home server computer (Ubuntu Linux 10.04) via USB. The board appears as a serial device (i.e. ttyUSB000). If the USB cable is disconnected the lock on the device remains and the process controlling it still thinks the device is there. When the cable is reconnected the device will appear as a different device (i.e. ttyUSB001). What is the best way for a process to determine if this has happened and find the new device name. I am using Java to program the process. Everything works fine but If I start doing some cable switching then I lose contact with the device. I assume that I know the device name and would also like to know if there is a better way of finding the device.

Thanks, no hurry,
Ernie
 
Old 03-01-2012, 07:10 PM   #2
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Australia
Distribution: Devuan
Posts: 5,477

Rep: Reputation: Disabled
have you considered creating an udev rule for the device.

consider this
http://hackaday.com/2009/09/18/how-to-write-udev-rules/

---------- Post added 02-03-12 at 08:10 ----------

have you considered creating an udev rule for the device.

consider this
http://hackaday.com/2009/09/18/how-to-write-udev-rules/
 
1 members found this post helpful.
Old 03-01-2012, 07:13 PM   #3
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS7
Posts: 267

Rep: Reputation: 58
What is the output from: lsusb ?
 
Old 03-02-2012, 07:54 AM   #4
lev0207
LQ Newbie
 
Registered: Feb 2009
Location: Portsmouth, Rhode Island
Distribution: Ubuntu
Posts: 6

Original Poster
Blog Entries: 1

Rep: Reputation: 0
Aus9,

Udev rules might be at least a part of the answer. At least I should be able to determine the behaviour of the device if I can't communicate with it.


david1941,

I'm not sure that I want to be using lsusb from within my Java program. I could do that, but I'm not sure what value it would give me. Here is the specific lsusb line for this device.

Bus 001 Device 015: ID 16c0:0483 VOTI

Remember that I'm using it as a serial device ttyUSB000.

Thanks again
Ernie
 
Old 03-02-2012, 09:24 AM   #5
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS7
Posts: 267

Rep: Reputation: 58
I don't know if it does help but I had a similar problem with the device changing on my scanner and set this up years ago and it still works:
Code:
# Determine scanning device - Epsom Prefection 640U attached (we hope)
DEVBUS=`/sbin/lsusb |grep Epson|cut -d " " -f2`
DEVDEV=`/sbin/lsusb |grep Epson|cut -d " " -f4`
DEVDEV=`echo $DEVDEV |sed s/://`
SANE_DEFAULT_DEVICE="epson:libusb:$DEVBUS:$DEVDEV"
[ -z "$DEVDEV" ] && SANE_DEFAULT_DEVICE=""
# The above discovers the usb device.  If power has cycled on the scanner, 
# the usb port changes, therefore using the environment doesn't always work. 

[ -n $SANE_DEFAULT_DEVICE ] || (echo "Cannot find the scanner!" && exit 1)
 
Old 03-03-2012, 08:09 AM   #6
lev0207
LQ Newbie
 
Registered: Feb 2009
Location: Portsmouth, Rhode Island
Distribution: Ubuntu
Posts: 6

Original Poster
Blog Entries: 1

Rep: Reputation: 0
david1941

Excellent stuff. Thanks for you help. I'm not sure yet exactly what I'm going to do but it appears that I now have a couple of solutions.

Thanks again,
Ernie
 
Old 03-06-2012, 08:16 AM   #7
lev0207
LQ Newbie
 
Registered: Feb 2009
Location: Portsmouth, Rhode Island
Distribution: Ubuntu
Posts: 6

Original Poster
Blog Entries: 1

Rep: Reputation: 0
I consider my question resolved at this point but I don't know how to make that indication.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Serial input device using usb-serial connector slackiz Linux - Hardware 4 01-12-2009 06:04 AM
not a valid block device on a USB LaCie drive which formerly mounted mad1 Linux - Newbie 1 04-18-2008 09:47 AM
Valid block device for USB memory stick on SUSE 9.2 amala Linux - Hardware 5 12-24-2004 01:20 PM
mount-problem usb harddisk: not a valid block device micha Mandriva 2 11-21-2004 11:29 AM
usb thumbdrive not valid block device cjdock Linux - Hardware 1 02-07-2004 05:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration