简体   繁体   English

增强串行通信,拒绝COM端口,并显示错误“打开:拒绝访问”

[英]Boost serial communication, COM port is denied with error “open: access is denied”

I have a simple program, the Boost library, built and linked etc. 我有一个简单的程序,Boost库,已构建并已链接等。

When I run the code below, I get an error saying " open: access is denied". 当我运行下面的代码时,出现错误消息“打开:访问被拒绝”。 I get that is may well mean the port is already open and therefore not available. 我知道这很可能意味着该端口已经打开,因此不可用。 however, I can access the COM port very easily in both C# and another C++ program, however I have no idea how implement that in Boost and my search hasn't been very productive. 但是,我可以在C#和另一个C ++程序中非常轻松地访问COM端口,但是我不知道如何在Boost中实现该功能,并且搜索效率不高。

void main()
{
try 
{       
    SerialSimple ss("COM12", 115200);       
    //ss.writeString("hi");
}
catch (exception& e)
{
    cout << "Standard exception: " << e.what() << endl;
}

_getch();
}

Cheers 干杯

问题可能是您试图为每个读取打开相同的端口,而没有在单独的实例(C#或此程序)中将其关闭。

Solved it by disconnecting connection and then starting it again - am using Tera Term. 通过断开连接再重新启动来解决它-使用Tera Term。 Even though I have no idea how, it must have been opened by something else when I was attempting to write to it. 即使我不知道该怎么做,但在尝试对其进行写操作时,必定已将其打开。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM