LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
LinkBack Search this Thread
Old 08-16-2007, 03:40 PM   #1
Ultrus
Member
 
Registered: Jan 2006
Posts: 45

Rep: Reputation: 15
Question USB to RS232 (serial port)? - no I need to configure anything?


Hello,
I bought a usb-to-serial port adapter to use on my Linux Suse 10.2 laptop that does not have a serial port. While using Python to communicate through the serial port, I get errors saying that the "com1" port is not found. Is this because I need to configure the usb-to-serial port communication somehow?

I found this page:
http://www.linux-usb.org/USB-guide/x356.html

I was able to execute the commands shown on the page, but had to change "mknod /dev/usb/ttyUSB0 c 188 0" etc., to "mknod /dev/bus/usb/ttyUSB0 c 188 0". I did not know what to do with "insmod usb-serial.o vendor=0xVVVV product-0xPPPP", where you need to change the VVVV and PPPP to match your device. I'm not sure where to find those numbers. I have a RadioShack 26-183 usb to serial cable.

One thought is that everything was OK to begin with and I have problems with my Python code. Another thought is that I need to make some kind of aliases. Maybe I need to do something with the "insmod usb-serial.o vendor=0xVVVV product-0xPPPP" command.

Any thoughts on this? I appreciate the feedback.

Note: After posting, I read the top hardware sticky, and typed "dmesg" in the command prompt. The following lines of note were found:

usb 2-1: new full speed USB device using uhci_hcd and address 2
usb 2-1: new device found, idVendor=1452, idProduct=4026
usb 2-1: new device strings: Mfr=1, Product=2, SerialNumber=0
usb 2-1: Product: USB-Serial Controller
usb 2-1: Manufacturer: Prolific Technology Inc.
usb 2-1: configuration #1 chosen from 1 choice
pl2303 2-1:1.0: pl2301 converter detected
usb 2-1: pl2303 converter now attached to ttyUSB0

still having the Python errors. Any way to make an alias or fix to fool Python into thinking it is looking at "com1"? This may be a Python question? I will ask around.


Note 2: Akk, I can change the port name in my script e.g. "com1". Changing it to "ttyUSB0" produces the same errors.

Last edited by Ultrus; 08-16-2007 at 04:11 PM.
 
Old 08-16-2007, 04:15 PM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 95
Hi.

Sounds like your Python script was intended for Windows.
You might get some joy using '/dev/ttyUSB0' instead of 'com1', but I wouldn't bet the rent on it.

Dave
 
Old 08-16-2007, 04:29 PM   #3
Ultrus
Member
 
Registered: Jan 2006
Posts: 45

Original Poster
Rep: Reputation: 15
Nope. No joy. :P

Is there a linux command that will let me see what all my port names are? also, should I "link" to /dev/ttyUSB0 ?
 
Old 08-16-2007, 04:39 PM   #4
zirkus
LQ Newbie
 
Registered: Aug 2007
Posts: 1

Rep: Reputation: 0
Test the device with minicom first

I suggest using minicom to make sure that the device is working properly first.
 
Old 08-16-2007, 04:54 PM   #5
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 95
Any chance you could post the part of the Python script that refers to 'com1'?

Dave
 
Old 08-16-2007, 05:16 PM   #6
Ultrus
Member
 
Registered: Jan 2006
Posts: 45

Original Poster
Rep: Reputation: 15
I made my own script based on examples separate from the other script I was working on with some interesting results. Here is the code:

Code:
import serial
ser = serial.Serial(0)
print ser.portstr
ser.close()
I get this error:
serial.serialutil.SerialException: Could not open port: [Errno 13] Permission denied: '/dev/ttyS0'

Note the '/dev/ttyS0'.
 
Old 08-16-2007, 05:22 PM   #7
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 95
OK.

Does the /dev/ttyS0 device exist? If not, try 'ln -s /dev/ttyUSB0 /dev/ttyS0'

Dave
 
Old 08-16-2007, 05:30 PM   #8
Ultrus
Member
 
Registered: Jan 2006
Posts: 45

Original Poster
Rep: Reputation: 15
It looks like there is already a ttyS0 to ttyS7 under /dev. I wonder if I messed something up when I executed the 16 commands from my first post. Would it make sense to delete my ttyS0, then do what you mentioned above? Or would it make sense to delete what I did in my first post, then run the dmesg command again?
 
Old 08-16-2007, 05:34 PM   #9
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 95
Scratch that - you probably want something like:
Code:
ser = serial.Serial('/dev/ttyS1', 9600, timeout=0)
or something. I don't know the details of pySerial (or Python, to be honest), but this page:
http://pyserial.sourceforge.net/
seems to indicate that you can specify the device to use in the serial.Serial call manually.

Dave
 
Old 08-16-2007, 05:43 PM   #10
Ultrus
Member
 
Registered: Jan 2006
Posts: 45

Original Poster
Rep: Reputation: 15
You're right. I was playing around with that. Still the same error message only with other things I specify like /dev/ttyUSB0. I also tried backing up the ttyS0 file, linking a new one, and that did not work as well. hmmmph.

I'm still experimenting. I'm sure there is a solution around the corner.
 
Old 08-16-2007, 05:45 PM   #11
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 95
Do you have read access to /dev/ttyUSB0? Depending on the config of your box, it may only be accessible by root.
Code:
id
ls -l /dev/ttyUSB0
Dave

Last edited by ilikejam; 08-16-2007 at 05:49 PM.
 
Old 08-16-2007, 05:57 PM   #12
Ultrus
Member
 
Registered: Jan 2006
Posts: 45

Original Poster
Rep: Reputation: 15
Oh! If I log in as root and run the code using 0 or /dev/ttyUSB0 as the argument, I don't get an error message!

I think 0 works because of that new link. I was also able to make it work for non-root by changing the permissions of /dev/ttyS0 and /dev/bus/usb/ttyUSB0.

Dave, you're the best! Thanks for the help.
 
Old 08-16-2007, 06:00 PM   #13
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 95
Yay! Outstanding.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disabling local echo on rs232 serial port... Fred_213 Programming 1 11-02-2006 04:30 PM
RS232 serial port errors when performing mutliple writes riffy Linux - Newbie 0 07-11-2006 12:12 PM
console login through RS232/serial port ? Yalla-One Linux - Software 3 02-24-2005 04:12 PM
RS232 serial port programing blackzone Programming 2 08-11-2004 12:54 AM
serial port: RS232 RS574? blackzone Linux - Hardware 1 08-10-2004 04:15 AM


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

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration