Jonathan Thomson's web journal

Parallax USB Oscilloscope in WINE October 10, 2009

Filed under: Electronics — jethomson @ 1:19 am

How to make the COM ports available to the Parallax USB Oscilloscope in WINE.

This HOWTO was tested on: Debian Lenny/Linux 2.6.26-2-686
My version of wine is: wine-1.0.1-174-gc4039bd

These instructions most likely will work on Ubuntu, but you’ll probably want to replace "su -c" with "sudo".

Steps
(0)
Install the USB Oscilloscope program. I installed version 5.1.1.
This HOWTO might work for the older version 4.0 but I didn’t test it out.

(1)
Unplug the oscilloscope.
Open a terminal.
$ lsusb
There’s no need to study the output. You want to compare this output to the output you receive after you plug in the oscilloscope and run lsusb a second time.

$ ls /dev/ttyUSB*
It’s not a problem if you see “No such file or directory”. Again, this output will be for comparison.

(2)
Plug in the USB Oscilloscope.
$ lsusb
You should notice a change indicating the FTDI chip was recognized.
Something like:
Bus 003 Device 002: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC

$ ls /dev/ttyUSB*
You should notice a new entry, /dev/ttyUSBn, where n is a number. If it is your first USB tty device n will be 0.

(3)
Go to your .wine directory:
$ cd .wine
Backup your .reg files:
$ ls *.reg | xargs -I "{}" cp "{}" "{}".BAK
Download comport.reg to the .wine directory:
$ wget -O comport.reg http://bugs2.winehq.org/attachment.cgi?id=10210
Import comport.reg using regedit:
$ regedit comport.reg

(4)
While having root permissions, make a symbolic link to /dev/ttyUSBn, where n is the number you discovered in step 2:
$ su -c "ln -s /dev/ttyUSBn /dev/ttyS4"

(5)
Make sure you are in the group that has permission to use the serial devices.
For example when I run:
$ ls -l /dev/ttyUSB0
I get the following output:
crw-rw---- 1 root dialout 188, 0 2009-10-09 19:48 /dev/ttyUSB0
Therefore I should check /etc/group to make sure I’m a member of group dialout.
$ grep dialout /etc/group
Which outputs:
dialout:x:20:jthomson
So indeed I’m a member of dialout.

If I were not, I could add myself to the dialout group like this:
$ su -c "usermod -a -G dialout jthomson"

Your group may not be named dialout, but you should be able to figure out your group’s name from the example given above.

(6)
Open the USB Oscilloscope program.
Go to Settings–>COM Settings…
Choose COM5 and close. The USB icon should be green now. Hit Run to test things out.

(7)
After rebooting or shuffling around other devices that create ttyUSB entries, you’ll need to recreate the ttyS4 link so that it points to the correct ttyUSBn. To do this remove the old link (if it’s there) and repeat steps 2 and 4.

Tips/Troubleshooting

If the program runs slowly, unplug cable before starting the program then plug it back in after starting the program OR trying plugging into a different USB port. For my computer the program only runs correctly if the scope is plugged into a specific, physical port. Unplugging and plugging back into a new port will probably destroy and recreate the same ttyUSBn device you linked to earlier.
You can use “diff system.reg system.reg.BAK” to make sure comport.reg was applied.
A graphical version of regedit can be opened by simply typing “regedit” in a terminal. comport.reg can be imported graphically with Registry–>Import Registry File…
comport.reg only creates 5 COM ports. If for some reason you can’t use ttyS4, try linking ttyS0-3 to ttyUSBn. If you use ttyS3 –> ttyUSB0, then you need to select COM4 (instead of COM5) in USB Oscilloscope. Likewise ttyS2 corresponds to COM3, and so on.

Links
http://bugs.winehq.org/show_bug.cgi?id=9902
http://bugs.winehq.org/show_bug.cgi?id=11811
http://wiki.jswindle.com/index.php/Wine_Registry#Serial_Com_Port
http://forum.winehq.org/viewtopic.php?p=24139