SOLVED! - Serial usb adapter - Mint 20.3 host - Win XP VM

Discussions related to using VirtualBox on Linux hosts.
Post Reply
AustinR
Posts: 3
Joined: 2. Nov 2023, 18:11

SOLVED! - Serial usb adapter - Mint 20.3 host - Win XP VM

Post by AustinR »

I have an old macbook (2009) with Linux Mint 20.3 on it. Works great. I want to use this machine to read and write to old-ish PLCs, so I created a Windows XP 32bit VM in virtualbox and installed the appropriate software (GX Developer). Now I want to connect to a PLC with a USB to RS422 adapter cable for Melsec FX. The cable came with a driver on a cd and I installed that onto the XP VM.

Virtualbox > Settings > Serial Ports:
-Port 1 enabled
-Port Number: COM1
-Port Mode: Host Device
-Path/Address: tried "/dev/sdc1", "/dev/tty0", "/dev/ttyS1", "/dev/bus/usb/004/001,002,003,etc". Nothing works. VM won't boot.

The user is the admin and I did add the group dialout after finding that in a search.

Results:
"/dev/sdc1"
-If a usb drive is plugged in: VM aborts boot and says: "Cannot open host device '/dev/sdc1' for read/write access. Check the permissions of that device ('/bin/ls -l /dev/sdc1'): Most probably you need to be member of the device group. Make sure that you logout/login after changing the group settings of the current user (VERR_ACCESS_DENIED)."
-If a usb drive is not plugged in: VM aborts boot and says: "Failed to open host device '/dev/sdc1' (VERR_FILE_NOT_FOUND)."

Note: I came up with /dev/sdc1 by plugging a usb stick into the usb port I'm using and running lsblk:

Code: Select all

russell@russell:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 232.9G  0 disk 
├─sda1   8:1    0   487M  0 part /boot/efi
├─sda2   8:2    0   1.9G  0 part [SWAP]
├─sda3   8:3    0    14G  0 part /
└─sda4   8:4    0 216.6G  0 part /home
sdc      8:32   1   3.8G  0 disk 
└─sdc1   8:33   1   3.8G  0 part /media/russell/USB DISK
sr0     11:0    1  1024M  0 rom
"/dev/tty0"
-Hail mary. After searching I saw other people using/referring to this path. Didn't work. VM aborts boot and again says: "Cannot open host device '/dev/tty0' for read/write access. Check the permissions of that device..."

"/dev/ttyS1"
-Also a hail mary. Found reference to this path as well. Didn't work. VM aborts boot and says: "Failed to open host device '/dev/ttyS1' (VERR_DEV_IO_ERROR).

"/dev/bus/usb/004/001" Note: I also tried files 002, 003, and 010 because those are also files in that directory
-I came up with this path by plugging in my actual adapter cable and running lsusb and it shows up as:

Code: Select all

russell@russell:~$ lsusb
Bus004 Device 009: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
But unfortunately no matter what file in the /dev/bus/usb/004 directory I choose it returns the same thing again: "Cannot open host device '/dev/bus/usb/004/001' for read/write access. Check the permissions of that device..."

For what it's worth, I do have the USB port working in XP. If I'm in the VM and plug in a usb stick, it shows up and I am able to open it. But if I have the serial port settings on anything other than "disconnected", it won't even boot.

What am I doing wrong? Thank you.

System: Kernel: 5.4.0-164-generic x86_64 bits: 64 compiler: gcc v: 9.4.0
Desktop: Cinnamon 5.2.7 wm: muffin dm: LightDM Distro: Linux Mint 20.3 Una
base: Ubuntu 20.04 focal
Machine: Type: Laptop System: Apple product: MacBookPro5,5 v: 1.0 serial: <filter> Chassis:
type: 10 v: Mac-F2268AC8 serial: <filter>
Mobo: Apple model: Mac-F2268AC8 serial: <filter> UEFI: Apple
v: MBP55.88Z.00AC.B03.0906151708 date: 06/15/09
VirtualBox: 7.0.10r158379
Last edited by AustinR on 2. Nov 2023, 22:06, edited 1 time in total.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Need Help - Serial usb adapter - Mint 20.3 host - Win XP VM

Post by scottgus1 »

I can't speak to the serial sharing question, though I guess that in "/dev/???", ??? has to be what is actually showing up in the host device list as the serial port generated by the adapter. I don't know if you have already tried that.

However, since it's a USB device, you can make a USB filter for it if there are XP drivers available for it, and pass the whole device into the VM. Then the VM can control the serial port directly. You would disable the Virtualbox serial sharing settings. See USB basics and troubleshooting
AustinR
Posts: 3
Joined: 2. Nov 2023, 18:11

SOLVED: Need Help - Serial usb adapter - Mint 20.3 host - Win XP VM

Post by AustinR »

I just tried creating a filter for it, and it sort-of worked! The XP VM recognized the cable when it booted, but the PLC programming software doesn't have a usb connection option, only serial.

So then with the cable unplugged, I tried running ls -clt /dev/

Code: Select all

russell@russell:~$ ls -clt /dev/
total 0
drwxrwxrwt  2 root root            40 Nov  2 14:45 shm
drwxr-xr-x  2 root root          4400 Nov  2 14:44 char
drwxr-x---  6 root vboxusers      120 Nov  2 14:18 vboxusb
drwxr-xr-x  2 root root           340 Nov  2 11:51 block
drwxr-xr-x  2 root root           100 Nov  2 11:51 bsg
...
...
Then I plugged in the cable and ran it again

Code: Select all

russell@russell:~$ ls -clt /dev/
total 0
drwxrwxrwt  2 root root            40 Nov  2 14:45 shm
drwxr-xr-x  2 root root          4440 Nov  2 14:45 char
drwxr-xr-x  4 root root            80 Nov  2 14:45 serial
crw-rw----  1 root dialout   188,   0 Nov  2 14:45 ttyUSB0
drwxr-x---  6 root vboxusers      120 Nov  2 14:45 vboxusb
drwxr-xr-x  2 root root           340 Nov  2 11:51 block
drwxr-xr-x  2 root root           100 Nov  2 11:51 bsg
...
...
There's a couple new ones: ttyUSB0 and serial.
I put ttyUSB0 into the Port 1 path in VM settings.
I tried booting it without the cable plugged in; VM won't boot and says file not found... Makes sense, the file isn't there if the cable isn't plugged in.
So I plugged in the cable, booted the VM [IT BOOTED!!], opened the software, and successfully connected to and pulled logic from a PLC! Incredible!

This was probably the obvious thing to do in the first place...I'm definitely on the noob side of the spectrum when it comes to Linux. This was SUCH a major win! After your reply, I even came up with "ls -clt /dev/" by looking at man pages hahaha!
Thank you for your help!
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: SOLVED! - Serial usb adapter - Mint 20.3 host - Win XP VM

Post by scottgus1 »

Glad to be of assistance! Nice that you're up and running.

FWIW:
AustinR wrote: 2. Nov 2023, 22:05 I just tried creating a filter for it, and it sort-of worked! The XP VM recognized the cable when it booted, but the PLC programming software doesn't have a usb connection option, only serial.
XP should have seen a new serial port in its Device Manager when using the USB Filter option. You'd then attach the PLC software through the new serial port. The PLC would not need to use a USB connection, because the serial connection is now there.
AustinR
Posts: 3
Joined: 2. Nov 2023, 18:11

Re: SOLVED! - Serial usb adapter - Mint 20.3 host - Win XP VM

Post by AustinR »

Ah ha! You are correct. I was doing a couple things wrong.

First, I think I still had the serial port enabled in the VM settings. Then I may have also been booting the VM with the cable plugged in. The correct recipe was to disable the serial ports in the VM settings, boot the VM, then plug the cable in.

Then I went to device manager in XP and found the USB-Serial port was COM3. I think I was previously just trying COM1. I changed the settings in the PLC programming software to look at COM3 and it worked!

The advantage of doing it this way with the USB filter is I can now boot the XP VM with or without the cable plugged in, and if the cable comes unplugged while the VM is active, there won't be a "non-fatal error" like before when the /dev/ttyUSB0 file disappears out from under the VM. So now I can use the cable like normal. Great!

Thank you again for your help! Very much appreciated!
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: SOLVED! - Serial usb adapter - Mint 20.3 host - Win XP VM

Post by scottgus1 »

Yep, I think you got it now. Glad to help. Happy programming!
Post Reply