利用CreateFile建立RS232,遇到問題了。 |
尚未結案
|
hanklin
一般會員 發表:3 回覆:3 積分:1 註冊:2003-03-26 發送簡訊給我 |
|
hanklin
一般會員 發表:3 回覆:3 積分:1 註冊:2003-03-26 發送簡訊給我 |
我在網路上search到以下片段文章,有人看地懂嗎? I am using 16-port serial card and was not able to access serial ports
com10 - com18. I have seen a couple of people complaining about the same
problem. The cause of the problem is that CreateFile accepts strings "com1" -
"com9" as names of devices and reject to do so for two and more digit
numbers. In order to open "com10" and above we actually have to feed
"\\\\.\\com10" string to CreateFile. The simple fix to winsup/path.cc given below would solve the problem.
Can someone integrate this? Stas. bash-2.02$ diff -u path.cc.00 path.cc
--- path.cc.00 Wed Oct 27 20:55:55 1999
path.cc Thu Dec 16 14:49:36 1999
@@ -400,7 400,7 @@
"\\dev\\ttym",
"\\dev\\tty%d",
"\\dev\\ptym",
- "com%d",
"\\\\.\\com%d",
"\\dev\\pipe",
"\\dev\\piper",
"\\dev\\pipew",
bash-2.02$
|
hanklin
一般會員 發表:3 回覆:3 積分:1 註冊:2003-03-26 發送簡訊給我 |
|
brook
資深會員 發表:57 回覆:323 積分:371 註冊:2002-07-12 發送簡訊給我 |
|
venson0704
一般會員 發表:3 回覆:3 積分:1 註冊:2002-08-29 發送簡訊給我 |
|
axsoft
版主 發表:681 回覆:1056 積分:969 註冊:2002-03-13 發送簡訊給我 |
列舉COM port 清單void __fastcall TForm1::Button1Click(TObject *Sender) { TStrings *Coms = new TStringList(); HANDLE hCom; char chPort[5]; memset( chPort, '\0', sizeof( chPort ) ); for (int i=1; i<20; i ) { sprintf( chPort , "\\\\.\\COM%d" , i ); hCom = CreateFile( chPort , GENERIC_READ | GENERIC_WRITE , 0 , NULL , OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , 0 ); if ( hCom != INVALID_HANDLE_VALUE ){Coms->Add( AnsiString(chPort) ); } CloseHandle( hCom ); } delete Coms; } /*生活是一種藝術,用心生活才能享受生活*/發表人 - axsoft 於 2003/09/16 15:46:30 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |