Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
299 views
in Technique[技术] by (71.8m points)

c++ - Serial port connection in VirtualBox between Windows and Ubuntu

I have installed Ubuntu on VirtualBox as guest and the host is Windows10, I'm working on serial programming and I have made the following configurations for serial port in VirtualBox

enter image description here

This is my code running on Ubuntu in VirtualBox :

...
int main() {

    // Open a serial port. 
    int serial_com = open("COM1", O_RDWR);
    if (serial_com < 0) {
        cout << "Error while opening device..." << "errno = " << errno << endl;
        exit(1);
    }
...

However, when I run the program, after connecting my gps with usbuart converter, I get this error:

Error while opening device... errno=2

I tried also names for port path like /dev/ttySX Where X = 0, 1, 2, 3 but it didn't work it gives me errno:13

Are my configurations correct for serial port in the VirtualBox?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...