zoukankan      html  css  js  c++  java
  • WinAPI打开串口失败

    串口号为COM11,通过WinAPI始终无法打开串口,才发现原因如下:

    http://www.advancedvirtualcomport.com/faq.html

    How do I open a virtual serial port with a number higher than 9 from my application?
    Windows automatically maps COM1-COM9 ports to the right device name. COM ports with higher numbers should be opened as \\.\COMxxx, where xxx is a port number.

    Example for C/C++/C#: 
    hPort = CreateFile("\\\\.\\COM15", ...); 

    Example for VB: 
    hPort = CreateFile("\\.\COM15", ...); 

    Example for Delphi: 
    hPort := CreateFile('\\.\COM15', ...);


    另发现:如果出现1~9 COM port打不开,可能会因为是之前打开后忘记关闭了,系统自动映射会有记录,再次打开时无法成功打开,需要关闭该COM口或者重启电脑(比较裸)。

  • 相关阅读:
    html表单
    html基础
    MySQL数据库 数据的更新
    JAVA数据库编程
    集合框架
    线程和进程
    反射
    centos 7环境
    js中的this
    javascript的作用域以及闭包现象
  • 原文地址:https://www.cnblogs.com/yxy8023ustc/p/2797933.html
Copyright © 2011-2022 走看看