其他串口也一样,都试了。多次打开了同一个串口,这个可能可以排除。我又写了一简单的只有串口操作的程
序,串口可以打开但无法配置串口,VSPM和VSPD XP 5都是这样,
if(!handlePort)
{handlePort = CreateFile("COM2",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
if (GetCommState(handlePort,&config) == 0)
{
AfxMessageBox("Get configuration port has problem.");
return FALSE;
}
config.BaudRate = CBR_9600;
config.StopBits = 1;
config.Parity = 1;
config.ByteSize = 8;
if (SetCommState(handlePort,&config) == 0)
{
AfxMessageBox("Set configuration port has problem.");
return FALSE;
}
SetCommState返回0值,是不是我的虚拟串口配置有问题啊?
我现在写的串口程序是读取单片机发送的数据,是不是我用的虚拟串口软件不对啊?
序,串口可以打开但无法配置串口,VSPM和VSPD XP 5都是这样,
if(!handlePort)
{handlePort = CreateFile("COM2",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
if (GetCommState(handlePort,&config) == 0)
{
AfxMessageBox("Get configuration port has problem.");
return FALSE;
}
config.BaudRate = CBR_9600;
config.StopBits = 1;
config.Parity = 1;
config.ByteSize = 8;
if (SetCommState(handlePort,&config) == 0)
{
AfxMessageBox("Set configuration port has problem.");
return FALSE;
}
SetCommState返回0值,是不是我的虚拟串口配置有问题啊?
我现在写的串口程序是读取单片机发送的数据,是不是我用的虚拟串口软件不对啊?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货