Set up the serial port in Wine

 Author:   Posted on:   Updated on:  -
The serial port is not of much use today, but there are still some things that rely on serial port communication. For example DIY microcontrollers electronics projects or some firmware updaters require connecting devices via serial port.

Another issue is that modern computers no longer have serial ports. But this can be easily solved by using a USB-to-serial adapter when you need a serial port.

Windows detects and names serial ports as COM1, COM2, COM3, etc. It doesn't make the difference between genuine ports or USB adapters. Linux on the other hand names hardware ports as /dev/ttyS0, /dev/ttyS1, /dev/ttyS2, etc. and USB adapter ports as /dev/ttyUSB0, /dev/ttyUSB1, /dev/ttyUSB2, etc.

Set up the serial port in Wine
The question is how do you map a Wine Windows serial port to a Linux device. Most answers I was able to find said you just have to add a symbolic link to the port in Wine's dosdevices directory. But when I did that, the STB firmware updater I was trying to use still didn't detect any serial port.

No serial port detected in Wine
No serial port detected in Wine
So, here is what I did to make it work. First of all, unless you want to run Wine each time as root, add yourself to the dialout group, so you can access serial ports without root permissions. This can be done from Terminal:
sudo adduser <your_username> dialout
You should log off and back in for the changes to take effect. This affects not only Wine, but all other Linux application that need serial port access.

The first step is to make the necessary symbolic links. Again, in Terminal:
ln -s /dev/ttyUSB0 ~/.wine/dosdevices/com1
ln -s /dev/ttyS0 ~/.wine/dosdevices/com2
Adapt these commands for your situation. The first one is needed if you use a serial to USB adapter while the second one is for hardware motherboard ports. Add a symbolic link for each of the available serial ports. This command actually gives access to serial ports from Wine. And any Windows software where you can manually edit the serial port will work with only this. However many Windows apps allow user to select a port from a detected ports list. And they will detect nothing in Wine.

Now you need to add a Wine registry key as stated on Strangen0tes blog. Although you could use Wine's regedit, it is easier to launch a text editor and add the required registry key(s). In Terminal:
gedit ~/.wine/system.reg
What you should add here is not clearly known, so you should try with the following options from Wine Wiki until you find something that works.

This is the common option that works with most applications:
[Hardware\\Devicemap\\Serialcomm] 1231984861
The other one is:
[Hardware\\Devicemap\\Serialcomm] 1131331688
Both worked for me. Yet there may be apps that don't read this registry key when looking for serial ports.

The association between COMx and /dev/ttyX is made in the symbolic link you made earlier.

If you use Linux and rely on a Windows only serial port application, besides virtualization, you could use Wine. If you configure it, most Windows applications will be able to detect and use the serial ports. Have you succeeded?

No comments :

Post a Comment

Please read the comments policy before posting.