SCIENTIFIC-LINUX-USERS Archives

July 2009

SCIENTIFIC-LINUX-USERS@LISTSERV.FNAL.GOV

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
WILLIAM J LUTTER <[log in to unmask]>
Reply To:
WILLIAM J LUTTER <[log in to unmask]>
Date:
Tue, 14 Jul 2009 14:10:12 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (44 lines)
I don't do a lot of work with serial ports and I know this should be an obvious question.  I've several linux boxes running SL4.7 or 5.0.  

I have a digitizer connecting to a serial port via RS232 cable with trivial settings (start bits 1, data bits 8, parity none, stop bit 1 with a variety of baud rates supported - which works with windows hyperterminal.

I know that  /dev/ttyS files are the serial device files.  I can cat /proc/interrupts to see the serial IRQ that is active (4):
 4:      43043      40334    IO-APIC-edge  serial

I can do sudo setserial -bg /dev/ttyS* to see which are available:
/dev/ttyS0 at 0x03f8 (irq = 4) is a 16550A

or do
sudo setserial -g /dev/ttyS[0-9]
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4
/dev/ttyS1, UART: unknown, Port: 0x02f8, IRQ: 3
/dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4
/dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3
/dev/ttyS4, UART: unknown, Port: 0x0000, IRQ: 0
...(same)

At this point, I'm not sure of a few things.  This is linux SL4.7  PC with a PS/2 mouse.  
1) When I connect cable to 9-pin serial  port, which device is associated with it?
2) stty presumably allows me to configure the serial port to my liking, but which ones do I want for my trivial usage?
I'm thinking...
stty -F /dev/ttyS2
-parenb (disable parity generation and detection)? I've got no parity?
cs8 - this is character size, so this is 8 data bits?
-cstopb - use one stop bit per character (stop bits: 1)
19200 - desired  baud rate
Not sure about start bit = 1 setting or if above is appropriate, so many parameters with stty.  

So, stty -F /dev/ttyS2 -parenb cs8 -cstopb 19200

and then the ttyS2 file is available for use, if ttyS2 was associated with my serial port connection.

Then, a c program could open and work with this
fd = open("/dev/ttyS2",O_RDWR | O_NDELAY | O_SYNCIO)

or matlab could open the serial port?  Currently matlab tells me no ports are available.
s2 = serial('/dev/ttyS2');
get(s2); 
fopen(s2);

Bill Lutter

ATOM RSS1 RSS2