首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

串口转USB的程序C编程USB serial Port,该怎么处理

2013-09-24 
串口转USB的程序C编程USB serial Port后来才发现原来的串口插上显示的是prolific USB-to-Serial,而新连接

串口转USB的程序C编程USB serial Port

串口转USB的程序C编程USB serial Port,该怎么处理
串口转USB的程序C编程USB serial Port,该怎么处理
后来才发现原来的串口插上显示的是prolific USB-to-Serial,而新连接的设备是USB serial Port
小弱没遇到过这种问题啊,这个USB serial Port的编程和原来的有什么区别啊,网上也没有找到解决方案,求大神指点啊,有没有参考程序啊串口转USB的程序C编程USB serial Port,该怎么处理
串口转USB的程序C编程USB serial Port,该怎么处理
串口转USB的程序C编程USB serial Port,该怎么处理
后来才发现原来的串口插上显示的是prolific USB-to-Serial,而新连接的设备是USB serial Port
小弱没遇到过这种问题啊,这个USB serial Port的编程和原来的有什么区别啊,网上也没有找到解决方案,求大神指点啊,有没有参考程序啊串口转USB的程序C编程USB serial Port,该怎么处理
[解决办法]
估计是你串口名写错了吧, 超过10的串口名格式应该要以:  TCHAR comName[] = TEXT("\\\\.\\COM19");
[解决办法]
Device Handles
A DeviceIoControl call specifies a handle to a device driver to identify the device being accessed. You can use the CreateFile function to get a device driver handle.

The CreateFile call must specify either the name of a device or the name of the driver associated with a device. To specify a device name, the lpszname parameter of CreateFile specifies a string with the format

\\.\DeviceName 
 
The types of devices that you can open and the method that you must use to specify them in the CreateFile function depend on the Win32 platform on which your application is running. 



Windows NT: The DeviceIoControl function can open a handle to a specific device. For example, to open a handle to the logical drive A:, specify "\\\\.\\a:". Alternatively, you can use the names "\\\\.\\PhysicalDrive0", "\\\\.\\PhysicalDrive1", and so on, to open handles to the physical drives on a system.

Windows 95 and Windows 98: For Win32-based applications, DeviceIoControl must specify a handle to a virtual device driver. For example, to open a handle to the system VxD, specify "\\\\.\\vwin32".

The CreateFile call should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when opening a handle to a device driver. However, when opening a communications resource, such as a serial port, CreateFile must specify exclusive access. Other CreateFile parameters are used as follows when opening a device handle: 

The fdwCreate parameter must specify the OPEN_EXISTING flag. 
The hTemplateFile parameter must be NULL. 
The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped (asynchronous) I/O operations. 
 

热点排行