USB and serial

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
Ben Okopnik

USB and serial

Post by Ben Okopnik »

Hello, everyone -

I have an old Windows app - a ship navigation program - that needs to
see GPS input on a serial port (it was written in the pre-USB days.) My
laptop, however, has no serial ports - but this same program, when run
on a friend's Windows box, can read the GPS info from the USB-connected
GPS via the "USB-Serial Driver". This is one of the frustrating bits of
this experience, since a "USB-Serial Driver" under Linux appears to mean
a module which drives a serial-in/USB-out dongle - not at all related to
what I need!

I've got the GPS - two different ones, actually - being recognized by
Linux; in fact, the appropriate modules are being loaded, the
appropriate device (/dev/ttyUSB9) is being created, and the NMEA
sentences are being read (as confirmed by "gpsd -D2 -nN /dev/ttyUSB9".)

My /var/log/messages says:
-------------------------------------------------------------------------
Dec 31 19:38:16 Tyr kernel: [23431.897090] /build/buildd/linux-2.6.24/drivers/usb/serial/usb-serial.c: USB Serial support
registered for Garmin GPS usb/tty
Dec 31 19:38:16 Tyr kernel: [23431.897112] garmin_gps 2-2:1.0: Garmin GPS usb/tty converter detected
Dec 31 19:38:16 Tyr kernel: [23431.897215] usb 2-2: Garmin GPS usb/tty converter now attached to ttyUSB9
Dec 31 19:38:16 Tyr kernel: [23431.897226] usbcore: registered new interface driver garmin_gps
Dec 31 19:38:16 Tyr kernel: [23431.897228] /build/buildd/linux-2.6.24/drivers/usb/serial/garmin_gps.c: garmin gps driver v0.31
-------------------------------------------------------------------------

-------------------------------------------------------------------------
Jan 9 13:38:51 Tyr kernel: [20080.693463] usb 1-2: new full speed USB device using ohci_hcd and address 3
Jan 9 13:38:51 Tyr kernel: [20080.900226] usb 1-2: configuration #1 chosen from 1 choice
Jan 9 13:38:53 Tyr kernel: [20083.182714] /build/buildd/linux-2.6.24/drivers/usb/serial/usb-serial.c: USB Serial support
registered for pl2303
Jan 9 13:38:53 Tyr kernel: [20083.183795] pl2303 1-2:1.0: pl2303 converter detected
Jan 9 13:38:53 Tyr kernel: [20083.184503] usb 1-2: pl2303 converter now attached to ttyUSB9
Jan 9 13:38:53 Tyr kernel: [20083.185094] usbcore: registered new interface driver pl2303
Jan 9 13:38:53 Tyr kernel: [20083.185101] /build/buildd/linux-2.6.24/drivers/usb/serial/pl2303.c: Prolific PL2303 USB to serial
adaptor driver
-------------------------------------------------------------------------

As far as Wine goes, I've got a link in ~/.wine/dosdevices - in fact,
I've created _all_ the com ports that the app recognizes (COM1 through
COM9) and linked them to /dev/ttyUSB9. Unfortunately, there's no joy in
Mudville: the app does not see the data. Even the nice little feature in
its configurator which shows the raw input on any of the com ports is
completely silent.

What could I possibly be missing? Is there any way to troubleshoot those
com ports from inside Wine (perhaps by listening to them with, I dunno,
Hyperterm or something)? Am I mistaken in the whole concept of linking a
USB device to a com port? Any and all suggestions would be highly
appreciated; I've lost many, many hours to beating my head against this
particular brick wall.


--
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *
User avatar
André H.
Moderator
Moderator
Posts: 207
Joined: Sun Dec 07, 2008 8:33 am

Post by André H. »

Just create one Com-Port-Link: COM1
not more not less
and why the hell its ttyUSB9 and not ttyUSB0 ???
Ben Okopnik

USB and serial

Post by Ben Okopnik »

On Tue, Jan 13, 2009 at 11:58:32AM -0600, Andr? H. wrote:
Just create one Com-Port-Link: COM1
not more not less
I did that. According to the program, there's no data on COM1 - although
I *know* that there is data on /dev/ttyUSB9.

Incidentally, I hope that case doesn't matter: the links I created were
called 'com1', 'com2', and so on. I'll try 'COM1' and so on later today,
when I get a chance.
and why the hell its ttyUSB9 and not ttyUSB0 ???
Because that's the device that the Linux drivers create by default. I
promise you that I didn't have anything to do with it. :)


--
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *
User avatar
André H.
Moderator
Moderator
Posts: 207
Joined: Sun Dec 07, 2008 8:33 am

Post by André H. »

try some kind of terminal inside wine to see if the data gets into wine but maybe not into your program
austin987
Wine Developer
Wine Developer
Posts: 2383
Joined: Fri Feb 22, 2008 8:19 pm

USB and serial

Post by austin987 »

On Mon, Jan 12, 2009 at 2:49 PM, Ben Okopnik <[email protected]> wrote:
Hello, everyone -

I have an old Windows app - a ship navigation program - that needs to
see GPS input on a serial port (it was written in the pre-USB days.) My
laptop, however, has no serial ports - but this same program, when run
on a friend's Windows box, can read the GPS info from the USB-connected
GPS via the "USB-Serial Driver". This is one of the frustrating bits of
this experience, since a "USB-Serial Driver" under Linux appears to mean
a module which drives a serial-in/USB-out dongle - not at all related to
what I need!

I've got the GPS - two different ones, actually - being recognized by
Linux; in fact, the appropriate modules are being loaded, the
appropriate device (/dev/ttyUSB9) is being created, and the NMEA
sentences are being read (as confirmed by "gpsd -D2 -nN /dev/ttyUSB9".)

My /var/log/messages says:
-------------------------------------------------------------------------
Dec 31 19:38:16 Tyr kernel: [23431.897090] /build/buildd/linux-2.6.24/drivers/usb/serial/usb-serial.c: USB Serial support
registered for Garmin GPS usb/tty
Dec 31 19:38:16 Tyr kernel: [23431.897112] garmin_gps 2-2:1.0: Garmin GPS usb/tty converter detected
Dec 31 19:38:16 Tyr kernel: [23431.897215] usb 2-2: Garmin GPS usb/tty converter now attached to ttyUSB9
Dec 31 19:38:16 Tyr kernel: [23431.897226] usbcore: registered new interface driver garmin_gps
Dec 31 19:38:16 Tyr kernel: [23431.897228] /build/buildd/linux-2.6.24/drivers/usb/serial/garmin_gps.c: garmin gps driver v0.31
-------------------------------------------------------------------------

-------------------------------------------------------------------------
Jan 9 13:38:51 Tyr kernel: [20080.693463] usb 1-2: new full speed USB device using ohci_hcd and address 3
Jan 9 13:38:51 Tyr kernel: [20080.900226] usb 1-2: configuration #1 chosen from 1 choice
Jan 9 13:38:53 Tyr kernel: [20083.182714] /build/buildd/linux-2.6.24/drivers/usb/serial/usb-serial.c: USB Serial support
registered for pl2303
Jan 9 13:38:53 Tyr kernel: [20083.183795] pl2303 1-2:1.0: pl2303 converter detected
Jan 9 13:38:53 Tyr kernel: [20083.184503] usb 1-2: pl2303 converter now attached to ttyUSB9
Jan 9 13:38:53 Tyr kernel: [20083.185094] usbcore: registered new interface driver pl2303
Jan 9 13:38:53 Tyr kernel: [20083.185101] /build/buildd/linux-2.6.24/drivers/usb/serial/pl2303.c: Prolific PL2303 USB to serial
adaptor driver
-------------------------------------------------------------------------

As far as Wine goes, I've got a link in ~/.wine/dosdevices - in fact,
I've created _all_ the com ports that the app recognizes (COM1 through
COM9) and linked them to /dev/ttyUSB9. Unfortunately, there's no joy in
Mudville: the app does not see the data. Even the nice little feature in
its configurator which shows the raw input on any of the com ports is
completely silent.

What could I possibly be missing? Is there any way to troubleshoot those
com ports from inside Wine (perhaps by listening to them with, I dunno,
Hyperterm or something)? Am I mistaken in the whole concept of linking a
USB device to a com port? Any and all suggestions would be highly
appreciated; I've lost many, many hours to beating my head against this
particular brick wall.


--
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *

Serial support in wine is pretty buggy:
http://bugs.winehq.org/buglist.cgi?quic ... erial+port

--
-Austin
vitamin
Moderator
Moderator
Posts: 6605
Joined: Sat Feb 23, 2008 2:29 pm

Re: USB and serial

Post by vitamin »

Ben Okopnik wrote:As far as Wine goes, I've got a link in ~/.wine/dosdevices - in fact,
I've created _all_ the com ports that the app recognizes (COM1 through
COM9) and linked them to /dev/ttyUSB9. Unfortunately, there's no joy in
Mudville: the app does not see the data. Even the nice little feature in
its configurator which shows the raw input on any of the com ports is
completely silent.
Does your program sees a serial port at all? If not, you might need to add some registry keys.

A google search will show you few locations in registry where some programs might look for available serial ports.
Ben Okopnik

USB and serial

Post by Ben Okopnik »

On Tue, Jan 13, 2009 at 03:45:22PM -0600, Austin English wrote:
Serial support in wine is pretty buggy:
http://bugs.winehq.org/buglist.cgi?quic ... erial+port
Thanks, Austin. Following the above, I discovered how to turn on
WINDEBUG; I probably went a bit overboard with
'WINEDEBUG="+comm,+file,+serial", but I did spot the following coming
out of the firehose:

------------------------------------------------------------------------
trace:file:RtlDosPathNameToNtPathName_U (L"C:\\windows\\serialui.dll",0x32eed8,(nil),(nil))
trace:file:RtlGetFullPathName_U (L"C:\\windows\\serialui.dll" 520 0x32ec5c (nil))
warn:file:wine_nt_to_unix_file_name L"serialui.dll" not found in /home/ben/.wine/dosdevices/c:/windows
------------------------------------------------------------------------

That certainly seems like it would torpedo any attempt to communicate
via a serial port. Any suggestions of where I can download such a
critter?


--
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *
austin987
Wine Developer
Wine Developer
Posts: 2383
Joined: Fri Feb 22, 2008 8:19 pm

USB and serial

Post by austin987 »

On Tue, Jan 13, 2009 at 7:52 PM, Ben Okopnik <[email protected]> wrote:
On Tue, Jan 13, 2009 at 03:45:22PM -0600, Austin English wrote:
Serial support in wine is pretty buggy:
http://bugs.winehq.org/buglist.cgi?quic ... erial+port
Thanks, Austin. Following the above, I discovered how to turn on
WINDEBUG; I probably went a bit overboard with
'WINEDEBUG="+comm,+file,+serial", but I did spot the following coming
out of the firehose:

------------------------------------------------------------------------
trace:file:RtlDosPathNameToNtPathName_U (L"C:\\windows\\serialui.dll",0x32eed8,(nil),(nil))
trace:file:RtlGetFullPathName_U (L"C:\\windows\\serialui.dll" 520 0x32ec5c (nil))
warn:file:wine_nt_to_unix_file_name L"serialui.dll" not found in /home/ben/.wine/dosdevices/c:/windows
------------------------------------------------------------------------

That certainly seems like it would torpedo any attempt to communicate
via a serial port. Any suggestions of where I can download such a
critter?


--
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *

To list as well:

That's a false warning...it means it didn't see the fake dll we have
for some dlls. Some apps check for the file name, rather than
functionality.

You can try overriding it with native, and see if that helps.

--
-Austin
Ben Okopnik

USB and serial

Post by Ben Okopnik »

On Tue, Jan 13, 2009 at 05:03:50PM -0600, vitamin wrote:
Ben Okopnik wrote:
As far as Wine goes, I've got a link in ~/.wine/dosdevices - in fact,
I've created _all_ the com ports that the app recognizes (COM1 through
COM9) and linked them to /dev/ttyUSB9. Unfortunately, there's no joy in
Mudville: the app does not see the data. Even the nice little feature in
its configurator which shows the raw input on any of the com ports is
completely silent.
Does your program sees a serial port at all? If not, you might need to add some registry keys.

A google search will show you few locations in registry where some programs might look for available serial ports.
Good question, thanks! I've run 'regedit' and searched the registry, and
came up with HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Ports .
Under it, there was a list containing LPT1:-3:, FILE:, and COM1:-5: .
I added COM6:-9: just in case, exported the file, and copied the above
section to
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Ports
(the plain 'Windows' section didn't have a 'Ports' key.)

I've also just recently learned about WINDEBUG, and running it before
doing the above mod shows lines like

---------------------------------------------------------------------
warn:file:CreateFileW Unable to create file L"\\\\.\\COM1" (status c0000034)
---------------------------------------------------------------------

Afterwards, the above are only reported for COM5 and up, which I suppose
is a big improvement - presumably, it means that COM1-COM4 are
operational. I'll check that out once I get back to my GPS.

Thanks for the help, all!


--
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *
Ben Okopnik

USB and serial

Post by Ben Okopnik »

Hi again, all -

So, I'm back home and can hook up my GPS again, so I can actually test
stuff. :) As a recap, I'm running Ubuntu 8.04 and trying to get an old
piece of Windows software to see my GPS. This works fine on Windows,
even though the software can only read COM1:-COM10: and the GPS is
USB-only.

Here's what I've got so far:

1) I hook up the GPS and modprobe the 'garmin_gps' module; the log says:

-------------------------------------------------------------------------
Jan 20 22:03:04 Tyr kernel: [ 6235.593930] usb 2-2: new full speed USB device using ohci_hcd and address 2
Jan 20 22:03:04 Tyr kernel: [ 6235.693948] usb 2-2: configuration #1 chosen from 1 choice
Jan 20 22:03:37 Tyr kernel: [ 6251.991681] /build/buildd/linux-2.6.24/drivers/usb/serial/usb-serial.c: USB Serial support registered for Garmin GPS usb/tty
Jan 20 22:03:37 Tyr kernel: [ 6251.992726] garmin_gps 2-2:1.0: Garmin GPS usb/tty converter detected
Jan 20 22:03:37 Tyr kernel: [ 6251.993251] usb 2-2: Garmin GPS usb/tty converter now attached to ttyUSB9
Jan 20 22:03:37 Tyr kernel: [ 6251.993738] usbcore: registered new interface driver garmin_gps
Jan 20 22:03:37 Tyr kernel: [ 6251.993742] /build/buildd/linux-2.6.24/drivers/usb/serial/garmin_gps.c: garmin gps driver v0.31
-------------------------------------------------------------------------

Testing the connection with 'gpsd -nND8 /dev/ttyUSB9' works fine (I see
the position data being sent back by the GPS), and 'gpsdrive' shows that
I'm getting a 3-D fix - i.e., the GPS and the connection both work fine.

2) I execute "ln -s /dev/ttyUSB9 ~/.wine/dosdevices/com1" and get a
symlink; running Hyperterm, however, shows no available ports (just
"TCP/IP (Winsock)").

3) After doing a bunch of research and tweaking, I figure out that I
need to add the following to my ~/.wine/system.reg:

-------------------------------------------------------------------------
[Hardware\\Devicemap\\Serialcomm] 1231984861
@=""
"Serial0"="COM1"
"Serial1"="COM2"
"Serial2"="COM3"
"Serial3"="COM4"
"Serial4"="COM5"
"Serial5"="COM6"
"Serial6"="COM7"
"Serial7"="COM8"
"Serial8"="COM9"
-------------------------------------------------------------------------

The next time I run Hyperterm, it shows COM1-COM9 (hurrah!) - and
choosing 'COM1' brings up the terminal window (this doesn't happen if I
select an inactive port; I get "Unable to open COM2. Please check your
port settings" as an error.) In theory, this says that Wine can see COM1
and it is indeed active.

4) Switching over to the directory with my legacy program, I run the
port configurator (the gadget that tells the rest of the programs where
to find the GPS.) The GPS data does not show up at any of the ports in
the configurator; scanning for it produces no results. The console from
which I launched it says:

-------------------------------------------------------------------------
err:ole:CoGetClassObject class {7729cd04-cdff-11d1-bc22-0000b43866a1} not registered
err:ole:CoGetClassObject no class object
{7729cd04-cdff-11d1-bc22-0000b43866a1} could be created for context 0x1
fixme:comm:set_queue_size insize 2048 outsize 2048 unimplemented stub
fixme:comm:set_queue_size insize 2048 outsize 2048 unimplemented stub
fixme:comm:set_queue_size insize 2048 outsize 2048 unimplemented stub
fixme:comm:set_queue_size insize 2048 outsize 2048 unimplemented stub
fixme:comm:set_queue_size insize 2048 outsize 2048 unimplemented stub
fixme:comm:set_queue_size insize 2048 outsize 2048 unimplemented stub
fixme:comm:set_queue_size insize 2048 outsize 2048 unimplemented stub
fixme:comm:set_queue_size insize 2048 outsize 2048 unimplemented stub
-------------------------------------------------------------------------

...with the last set of lines being incremented by two every couple of
seconds until I close the program.

5) I got a copy of "serialui.dll" and put it into the current directory,
then added it to "Libraries" in winecfg and set it as 'native'. The
result of running the configurator is exactly the same as before.

=======================================================================

At this point, I'm out of my depth, and would appreciate further help.


--
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *
User avatar
DanKegel
Moderator
Moderator
Posts: 1164
Joined: Wed May 14, 2008 11:44 am

Post by DanKegel »

Did you make sure you can access the serial port
from Linux yet?
See http://blog.mypapit.net/2008/05/how-to- ... buntu.html
for more info. Once that's working, maybe Wine will be happy.
User avatar
DanKegel
Moderator
Moderator
Posts: 1164
Joined: Wed May 14, 2008 11:44 am

Post by DanKegel »

Never mind, I see you did. Apologies.
User avatar
André H.
Moderator
Moderator
Posts: 207
Joined: Sun Dec 07, 2008 8:33 am

Post by André H. »

mmh, you should even see some data when opening with the terminal-software, a gps-mouse sends always, doesnt it?
Ben Okopnik

USB and serial

Post by Ben Okopnik »

On Wed, Jan 21, 2009 at 10:23:12AM -0600, DanKegel wrote:
Never mind, I see you did. Apologies.
No worries. I did output a bunch of info, and missing a byte doesn't
count against you. :)


--
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *
Ben Okopnik

USB and serial

Post by Ben Okopnik »

On Wed, Jan 21, 2009 at 11:55:35AM -0600, Andr? H. wrote:
mmh, you should even see some data when opening with the terminal-software, a gps-mouse sends always, doesnt it?
Yep; 'gpsd' shows a new "NMEA paragraph" (chunk of position data) being
output every few seconds. Perhaps Hyperterm isn't the right thing to use
- if you have any recommendations for terminal that will run under Wine
and read a serial port, that would be great. Especially if it's
something I can download: I don't have an actual Windows machine
anywhere handy.


--
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *
User avatar
André H.
Moderator
Moderator
Posts: 207
Joined: Sun Dec 07, 2008 8:33 am

Post by André H. »

Ben Okopnik

USB and serial

Post by Ben Okopnik »

On Thu, Jan 22, 2009 at 01:07:25PM -0600, Andr? H. wrote:
Thanks, Andre - I've just tried this out in both of the above, and I'm
not seeing any data (although firing up 'gpsd' shows that it is indeed
there.) What can I do to get it to show up?

Again, to recap: I have a Garmin GPS that's connected to /dev/ttyUSB9
via the 'garmin_gps' module. I can see it fine in Linux; I can't see it
with anything in Wine. I've created a symlink (~/.wine/dosdevices/com2
-> /dev/ttyUSB9) and added

----------------------------------------------------
[Hardware\\Devicemap\\Serialcomm] 1231984861
@=""
"Serial0"="COM1"
"Serial1"="COM2"
"Serial2"="COM3"
"Serial3"="COM4"
"Serial4"="COM5"
"Serial5"="COM6"
"Serial6"="COM7"
"Serial7"="COM8"
"Serial8"="COM9"
----------------------------------------------------

to the registry (this was needed to make the ports show up at all in any
of the software under Wine; without it, the only "port" was TCP/IP via
Winsock.)

What else can I do to make the data visible to software running under Wine?


Thanks in advance,
--
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *
Ben Okopnik

USB and serial

Post by Ben Okopnik »

On Tue, Jan 13, 2009 at 03:45:22PM -0600, Austin English wrote:
Serial support in wine is pretty buggy:
http://bugs.winehq.org/buglist.cgi?quic ... erial+port
So... does this mean I should give up trying? Or is there another avenue
I can follow to have my USB device visible to an app under Wine?

At this point, I've tried HyperTerm (no way to tell if it worked or not
- it doesn't do anything when you tell it to connect, of when you type
anything at the screen; wxterm (which I couldn't get to work at all),
and Hterm (actually gives some useful indications, like "No such port"
when it doesn't see one, and "Internal error when initializing COM3"
when it does but can't open it - but it still doesn't show the data.)
No idea where to take this next.


--
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *
User avatar
André H.
Moderator
Moderator
Posts: 207
Joined: Sun Dec 07, 2008 8:33 am

Re: USB and serial

Post by André H. »

Ben Okopnik wrote: Again, to recap: I have a Garmin GPS that's connected to /dev/ttyUSB9
via the 'garmin_gps' module. I can see it fine in Linux; I can't see it
with anything in Wine. I've created a symlink (~/.wine/dosdevices/com2
-> /dev/ttyUSB9) and added
*
May the garmin_gps module is always connected over the serial channel and so no other connections can be opened?
Ben Okopnik

USB and serial

Post by Ben Okopnik »

On Sat, Jan 24, 2009 at 03:37:19AM -0600, Andr? H. wrote:
Ben Okopnik wrote:
Again, to recap: I have a Garmin GPS that's connected to /dev/ttyUSB9
via the 'garmin_gps' module. I can see it fine in Linux; I can't see it
with anything in Wine. I've created a symlink (~/.wine/dosdevices/com2
-> /dev/ttyUSB9) and added
*
May the garmin_gps module is always connected over the serial channel and so no other connections can be opened?
The module is the gadget that "translates" the stuff coming in from the
Garmin, creates the port, and connects /dev/ttyUSB9 to it. Without the
module, there's no device - serial or otherwise - to which 'com1', etc.
could be connected.

I can see the output in Linux - whether by running 'gpsd' in debug mode
or running 'gpsdrive' and having it show my correct location. I just
can't see it under Wine, although there are some indications that
there's _something_ connected to the serial port.


--
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *
Locked