Guide to configuring a Virtual COM Port using socat (linked with CP2104) on macOS and utilizing it within WINE for development and testing purposes. Compatible with Apple Silicon.
This example is based on CP2104 from Silicon Labs running on macOS 15.1 (Apple Silicon M4 Max).
-
Install the Silicon Labs driver: Download it from Silicon Labs USB to UART Bridge VCP Drivers
Alternatively, use the file located inattachments/SiLabsUSBDriverDisk.dmg
. -
Execute the following command to list available devices:
ls /dev/cu.*
Example output:
/dev/cu.Bluetooth-Incoming-Port /dev/cu.SLAB_USBtoUART /dev/cu.debug-console /dev/cu.usbserial-025XXX1F
-
Copy the path to the device labeled
SLAB_USBtoUART
. -
Create a virtual COM port using the path from Step 3 by executing the following
socat
command:socat -d -d \ PTY,link=/tmp/virtualport,raw,echo=0,ispeed=19200,ospeed=19200,cs8,clocal,ignbrk,cread \ FILE:/dev/cu.SLAB_USBtoUART,raw,echo=0,ispeed=19200,ospeed=19200,cs8,clocal,ignbrk,cread
Note: The
baudrate
in this example is set to19200
. You can adjust it as per your requirements. -
Do not close the terminal. Open another terminal window.
-
Ensure you have the latest version of
wine
orwine@devel
installed.Instructions for installing Wine are not provided here.
-
Create a physical link for the virtual port to Wine by executing:
ln -s /tmp/virtualport ~/.wine/dosdevices/com5
Note: The port is named
com5
to be used within WINE. -
Launch the Wine Registry Editor by executing:
wine regedit
-
In the Registry Editor, navigate to:
HKEY_LOCAL_MACHINE/Software/Wine/Ports
-
Create a new String Value in this section:
- Name:
com5
- Value:
/tmp/virtualport
- Name:
-
Exit the Registry Editor, launch your Wine application, select
COM5
, and start using it!
To enable cross-communication, where you can send data to virtualport_client
and have it received by virtualport
, use the following socat
command:
socat -d -d PTY,link=/tmp/virtualport,raw,echo=0,ispeed=19200,ospeed=19200,cs8,clocal,ignbrk,cread PTY,link=/tmp/virtualport_client,raw,echo=0,ispeed=19200,ospeed=19200,cs8,clocal,ignbrk,cread
#VirtualCOMPort #WINE #macOS #AppleSilicon #M1 #M2 #M3 #M4 #CP2104 #TTL #COM #socat #SerialCommunication #USBtoUART #WineDevelopment #macOSDevelopment #VirtualPortSetup #SiliconLabs #SerialPort #UART #RS232 #WineCOMPort #USBDriver