读CF GPS卡的问题
PDA是联想的XP100,CF GPS卡是PRETEC的。据PRETEC说联想PDA的端口漂移特别厉害,本来ARM机型CF兼容设备的虚拟断口是COM4,可是XP100会漂移到其他断口。
我用API来读COM口时,在CreateFile的时候就会传回非法句柄。相关代码如下:
wchar_t szPortNum[15];
wsprintf(szPortNum,_T("COM%d"),sPortNum);
//Create a serial device and return it's handle
m_hCom = CreateFile(szPortNum, // pointer to name of the file
GENERIC_READ|GENERIC_WRITE, // GENERIC_READ|GENERIC_WRITE, // access mode
0, // comm devices must be opened w/exclusive-access
NULL, // no security attributs
OPEN_EXISTING, // comm devices must use OPEN_EXISTING
0,//FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED, // overlapped I/O
NULL); // hTemplate must be NULL for comm devices
if ( m_hCom == INVALID_HANDLE_VALUE )
{
// handle the error
AfxMessageBox(_T("Open(): CreateFile() failed, invalid handle value"));
return FALSE;
}
同样的代码在笔记本上一点错误也没有,在XP100上死活也过不了。
急!!!!