scene: xDevice --(I2C)--> xDriver --(stream interface)--> OS --(file object)--> Application
xDriver provides stream interface for COM port driver to the OS, and the OS provides file objects of a COM port device to applications. The application obtains information from xDriver through file objects to the COM port.
for example: (sample code on application layer)
BOOL xDriver::Open()
{
m_Handle = CreateFile( _T("COM7:"),
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
if(m_Handle == INVALID_HANDLE_VALUE) return FALSE;
return TRUE;
}
如果return false, 一個原因可能是與registry記錄的"Index"值不同而無法開啟。
in my case,
到 "...PLATFORM\PROJECT\FILES" -> PLATFORM.REG
然後查是否有 跟ap code 相對應的driver的 registry
如果有相對應的driver存在,檢查
"Prefix"="COM"
"Index"=dword:6
可以看到此driver是透過COM6,因此只要把sample code的 COM7 改成 COM6 就可以溝通了
Wednesday, March 28, 2007
problem: cannot open COM port
Posted by cins at 5:47 PM
Labels: Application Programming
Subscribe to:
Post Comments (Atom)
1 comments:
加油...記得有問題時多互相討論 : )
Post a Comment