原创 Serial Ports: busy?★★★★★

2011-6-14 21:37 1528 8 8 分类: MCU/ 嵌入式
讨论如何在linux中支持多串口
 
driveoldford



Joined: 17 Sep 2009
Posts: 5
Location: NYC,NY

PostPosted: Thu Sep 17, 2009 11:43 am    Post subject: Serial Ports: busy? Reply with quote

I have several software packages for Windoz that provide for a phone/fax answering machine. In the newer wine, I can install, but cannot get access to the Com port. I have created the ln -s in dosdevices, and even did a chmod 777 on dev/ttyS0. The user is a member of groups associated w/ modems, dialout, etc.
I always get "the port is being accessed by another program". I am stuck on two very different machines. Both run Open SuSe 11.0 Anyone solved this?
Thanks, FX
Martin Gregorie
Guest





PostPosted: Thu Sep 17, 2009 1:15 pm    Post subject: Serial Ports: busy? Reply with quote

On Thu, 2009-09-17 at 12:43 -0500, driveoldford wrote:
Quote:
I have several software packages for Windoz that provide for a
phone/fax answering machine. In the newer wine, I can install, but
cannot get access to the Com port. I have created the ln -s in
dosdevices, and even did a chmod 777 on dev/ttyS0. The user is a
member of groups associated w/ modems, dialout, etc.

I always get "the port is being accessed by another program". I am
stuck on two very different machines. Both run Open SuSe 11.0 Anyone
solved this?

I had a similar problem with a WINE app that downloads files from a
logger. BTW, it applies to all programs, e.g. Kermit and minicom, as
well as WINE apps that are run by normal users. With current,
udev-based, kernels its necessary to reset the permissions
of /dev/ttyS[0-9] after every boot. I added a local rule file
to /etc/udev/rules.d:

$ cat 51-local.rules
#
# Locally defined rules.
#

#
# Give world read/write access to ttyS* and ttyUSB* serial devices
#
KERNEL=="tty[A-Z]*", GROUP="uucp", MODE="0666"
$

This works under Fedora 6 through Fedora 10. Under earlier releases it
was sufficient to add a line containing:

chmod uga+rw /dev/ttyS*

to /etc/rc.d/rc.local so it got run at boot time, but IIRC this doesn't
work with UDEV since all the /dev/ttyS* devices are no longer created ar
boot time.

On Fedora 10 and WINE 1.1.23 this works with all real serial ports (I
have two on the mobo and another 4 on an IPC card) without needing to
add COMn: symlinks to the dosdevices directory. I have never been able
to access USB serial adapters from WINE, probably because they need
special Windows drivers.


Martin
driveoldford



Joined: 17 Sep 2009
Posts: 5
Location: NYC,NY

PostPosted: Mon Sep 21, 2009 2:48 pm    Post subject: Serial Ports Reply with quote

Thanks for the reply. Unfortunately, it does not seem to be permissions problems.
I tried exactly what you had suggested - no go. I have tried three different software packages - all w/ the same result - cannot access the com port.
Anybody else having problems w/ serial ports in Wine?
Thanks, FXS
Back to top
View user's profile Send private message Visit poster's website language=JavaScript type=text/javascript>  
 
Martin Gregorie
Guest





PostPosted: Mon Sep 21, 2009 3:21 pm    Post subject: Serial Ports: busy? Reply with quote

On Mon, 2009-09-21 at 15:48 -0500, driveoldford wrote:
Quote:
Thanks for the reply. Unfortunately, it does not seem to be permissions problems.
I tried exactly what you had suggested - no go. I have tried three different software packages - all w/ the same result - cannot access the com port.
Anybody else having problems w/ serial ports in Wine?
Thanks, FXS

I forgot one thing, but AFAIK this is only important if you have more
than two serial ports.

If you have extra ports installed, Linux won't know they are there
unless you add this argument to the boot command:


8250.nr_uarts=6

where the value '6' is the number of ports you have installed (I have 6:
the two on the mother board and another 4 on an PCI serial adapter
card).

If you haven't added any serial cards, check the dmesg report (use
"dmesg | less") to make sure the kernel recognizes all the serial ports

it should. If there are missing ports, try using the '8250.nr_uarts=n'
kernel argument from GRUB's boot-time command prompt to see if it helps.
If it does, edit /boot/grub/grub.conf to make it permanent. Add it to
the default boot stanza (usually the first in the file) by adding it,
preceded by a space, to the end of the 'kernel' line. It will be
automatically copied to the new stanza each time there's a kernel
upgrade, but keep a record of it in a safe place since you'll have to
add it manually after a clean install.


The above assumes that you're using a genuine serial port (implemented
by an 8250 or 16550 chip on the mother board or an adapter card) and not
a USB serial adapter. Wine doesn't support USB serial adapters.


Martin
Back to top
language=JavaScript type=text/javascript>  
 
vitamin



Joined: 23 Feb 2008
Posts: 3674

PostPosted: Mon Sep 21, 2009 11:34 pm    Post subject: Re: Serial Ports: busy? Reply with quote

driveoldford wrote:
I have several software packages for Windoz that provide for a phone/fax answering machine.

Just pick a native Linus program instead. You moved to Linux why? So you can run some crappy windows software?
driveoldford



Joined: 17 Sep 2009
Posts: 5
Location: NYC,NY

PostPosted: Sun Sep 27, 2009 8:39 am    Post subject: Reply with quote

Martin:
"Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing enabled"
So, I guess this means the serial port (there is only one) is found.
I'm still stuck. However, on one of the computers, the serial is defined as ttyS1,
so, I'll try linking to that. Down, but not dead!
Back to top
View user's profile Send private message Visit poster's website language=JavaScript type=text/javascript>  
 
Martin Gregorie
Guest





PostPosted: Sun Sep 27, 2009 11:02 am    Post subject: Serial Ports: busy? Reply with quote

On Sun, 2009-09-27 at 09:39 -0500, driveoldford wrote:
Quote:
Martin:
"Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing enabled"
So, I guess this means the serial port (there is only one) is found.

Then it should be /dev/ttyS0 because that's what I'd expect to see. Try
running this command:

ls -l /dev/ttyS*

which should only find ttyS0 and show its access permissions. Post its
output here.

Quote:
I'm still stuck. However, on one of the computers, the serial is defined as ttyS1,
so, I'll try linking to that. Down, but not dead!

This computer should have found at least two serial to have ttyS1. Post
the output from the same command for it as well.


Martin
Back to top
language=JavaScript type=text/javascript>  
 
driveoldford



Joined: 17 Sep 2009
Posts: 5
Location: NYC,NY

PostPosted: Sun Sep 27, 2009 1:27 pm    Post subject: Reply with quote

Here goes:
linux-w5px:/proc # chmod 777 /dev/ttyS*
linux-w5px:/proc # ls -l /dev/ttyS*
crwxrwxrwx 1 root uucp 4, 64 2009-04-14 06:32 /dev/ttyS0
crwxrwxrwx 1 root uucp 4, 65 2009-04-14 06:32 /dev/ttyS1
crwxrwxrwx 1 root uucp 4, 66 2009-04-14 06:32 /dev/ttyS2
crwxrwxrwx 1 root uucp 4, 67 2009-04-14 06:32 /dev/ttyS3
crwxrwxrwx 1 root uucp 4, 68 2009-04-14 06:32 /dev/ttyS4
crwxrwxrwx 1 root uucp 4, 69 2009-04-14 06:32 /dev/ttyS5
crwxrwxrwx 1 root uucp 4, 70 2009-04-14 06:32 /dev/ttyS6
crwxrwxrwx 1 root uucp 4, 71 2009-04-14 06:32 /dev/ttyS7

I should point out that I'm trying two different computers: an old IBM laptop 600X, and, a really old Toshiba desktop. Both! have exactly the same ls listing!
Software is Chyenne Bitware Voice Mail System (works real well). When I try to "setup" the modem - the message is: "... com port currently used by another application ...". But it's not, that I am aware of.
Dmesg on the old Toshiba referenced ttyS1, so, I have links in dosdevices to both com1 and com2. As you can see, I don't think this is a permissions issue.
Interestingly, I have some really old DOS "Testcoms" software. Both report no com port (in xdosemu)!
Is this an old Bios issue?
Back to top
View user's profile Send private message Visit poster's website language=JavaScript type=text/javascript>  
 
Martin Gregorie
Guest





PostPosted: Sun Sep 27, 2009 2:56 pm    Post subject: Serial Ports: busy? Reply with quote

On Sun, 2009-09-27 at 14:27 -0500, driveoldford wrote:
Quote:
Here goes:
linux-w5px:/proc # chmod 777 /dev/ttyS*
linux-w5px:/proc # ls -l /dev/ttyS*
crwxrwxrwx 1 root uucp 4, 64 2009-04-14 06:32 /dev/ttyS0
crwxrwxrwx 1 root uucp 4, 65 2009-04-14 06:32 /dev/ttyS1
crwxrwxrwx 1 root uucp 4, 66 2009-04-14 06:32 /dev/ttyS2
crwxrwxrwx 1 root uucp 4, 67 2009-04-14 06:32 /dev/ttyS3
crwxrwxrwx 1 root uucp 4, 68 2009-04-14 06:32 /dev/ttyS4
crwxrwxrwx 1 root uucp 4, 69 2009-04-14 06:32 /dev/ttyS5
crwxrwxrwx 1 root uucp 4, 70 2009-04-14 06:32 /dev/ttyS6
crwxrwxrwx 1 root uucp 4, 71 2009-04-14 06:32 /dev/ttyS7

To my way of thinking this is a bug in your distro: since UDEV
peripheral management came in the system probes the hardware at boot
time and builds an entry in the /dev directory for everything it finds.
This implies that it should not set up device names for non-existent
devices. The extras will never be used since, if you plug in a USB
device with serial ports these are all called /dev/ttyUSB*

How many physical serial ports does each system have?

Assume anything that exists is numbered from zero and only use items in
that range. You could also try limiting it to reality by adding the

8250.nr_uarts=6

kernel argument to the GRUB boot command line Its usually
in /boot/grub/grub.conf and you should add it to the end of the first
'kernel' line in the file. Needless to say, the number after the '=' is
the number of serial ports you actually have - I have six.

Quote:
Is this an old Bios issue?

No. AFAIK Linux doesn't use the BIOS at all. However, the GRUB boot
loader does: the BIOS starts it and then it uses BIOS disk access calls
to read the Linux kernel into memory. Once that's done it is overwritten
and vanishes.


Martin
Back to top
language=JavaScript type=text/javascript>  
 
driveoldford



Joined: 17 Sep 2009
Posts: 5
Location: NYC,NY

PostPosted: Tue Sep 29, 2009 3:20 pm    Post subject: Reply with quote

Martin:
Thanks for your continued interest and input.
Most of my effort is on the old Toshiba. This is a multi-boot machine w/ Win 2000,Open SuSe 11.0 and Knoppix, which is a debian distro.
This machine has one physical serial port.
In Knoppix, the ls command shows 4 serial ports.
Wine, in Knoppix, is showing the same non-functioning with the software as was the case w/ SuSe 11.0
Just to be sure, I attempted to install all 3 commercial packages that I have. Same result. The software does not seem to properly capture the serial port. W/ communicate Pro (not a very good package) the software claimed that it did, in fact, connect w/ the proper serial port ( a success message) - but - nothing really worked at all and I had to terminate w/ a kill command.
I can tell you that this is an embarrassment for me since one of our business lines is to convert people to linux! But the "answering/fax machine" is running on Windoz!
Regards, FXS
Back to top
View user's profile Send private message Visit poster's website language=JavaScript type=text/javascript>  
 
Martin Gregorie
Guest





PostPosted: Tue Sep 29, 2009 8:34 pm    Post subject: Serial Ports: busy? Reply with quote

Quote:
In Knoppix, the ls command shows 4 serial ports.

Despite what I said earlier, Fedora does the same. This laptop, which
has no serial ports, still shows /dev/ttyS[0-3] if you run:

ls /dev/ttyS*

The problem becomes one of working out which, if any, of these devices
work. Try setserial:

setserial -a /dev/ttyS0

where -a tells setserial to report everything it knows about the serial
device. There are three possible outcomes:

1) $ setserial -a /dev/ttyS0
/dev/ttyS0, Line 0, UART: 16550A, Port: 0x03f8, IRQ: 4
Baud_base: 115200, close_delay: 50, divisor: 0
closing_wait: 3000
Flags: spd_normal skip_test

This means the device file exists and is mapped to a physical serial
port, known as a UART. The following word is its type: usually it
will be an 8250, 16550 or 16550A.

2) # setserial -a /dev/ttyS0
/dev/ttyS0, Line 0, UART: unknown, Port: 0x03f8, IRQ: 4
Baud_base: 115200, close_delay: 50, divisor: 0
closing_wait: 3000
Flags: spd_normal skip_test auto_irq

This means that the device file exists but it is mapped to a broken
or non-existent UART, described as 'unknown'.

3) # setserial -a /dev/ttyS4
/dev/ttyS4: No such file or directory

The device file doesn't exist.

Quote:
Wine, in Knoppix, is showing the same non-functioning with the
software as was the case w/ SuSe 11.0

I've only tried two WINE apps so far. One 'just works' and can see all
six serial ports, but it is known to run under all versions of Windows
from Win98 to XP. This program downloads data from a flight recorder and
can configure it (set aircraft registration, pilot details and sync its
clock to the PC).

The other one, from the same company, can't see any serial ports. This
program was written for Windows 95/98 and has never been upgraded for
later versions of Windows. It does the same as the downloader and in
addition can analyse and display the data it has downloaded.

What is the most target version of Windows for your programs? This may
have a bearing on their ability to see the serial ports.

IME serial ports are a nightmare under DOS or Windows 95/98. I tried
programming serial ports under DOS/Win95 and could not discover any
documented serial port APIs for DOS, Windows or on the Broland C
libraries. I tried using some public domain assembler without much
success before buying the COMM-DRV package from Willies Computing Inc,
which worked perfectly. I tend to generalise this to mean that everybody
who tried serial programming on the same platform ran into the same
problems and everybody used a different solution. Consequently, I think
it may be pot luck whether a program of that age can use WINE for serial
comms.

Quote:
I can tell you that this is an embarrassment for me since one of our
business lines is to convert people to linux! But the "answering/fax
machine" is running on Windoz!

I sympathise. However, have you looked for a native Linux solution? That
may be the way to go, particularly as I'd expect a sensibly designed
Linux FAX solution to interface more or less seamlessly with e-mail via
the local MTA.


Martin
Back to top
language=JavaScript type=text/javascript>  
 

文章评论0条评论)

登录后参与讨论
我要评论
0
8
关闭 站长推荐上一条 /2 下一条