This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / [求助]从SERIAL PORT读取数据.
-rainzw(rainzw);
2004-4-1
{921}
(#1668099@0)
-
It seems ok. Why not post all code?
-bugkiller(Driver Coding);
2004-4-2
(#1669119@0)
-
全部代码就是这样了. 我试过CBUILDER, 试过.NET, 都一样, 说那个HANDLE无效.
-rainzw(rainzw);
2004-4-2
(#1669186@0)
-
try "COM1" or "\\\\.\\COM1"
-canadiantire(Crappy Tire);
2004-4-2
(#1669361@0)
-
same. 我的机器有COM1 AND COM2, 我用COM1:, COM1, COME2, COM2, \\\\.\\COM1, 都可以在CREATEFILE取得HANDLE,而一旦我用COM3, 就会在开始FAIL, INVALID HANDLE, 我就是不明白, 怎么开始都行, 到了READFILE就出错了, CBUILDER说是ACCESS VIOLATION, .NET说是什么OBJECT REFERENCE 没有定义, 总之就是HANDLE无效.
-rainzw(rainzw);
2004-4-2
{186}
(#1669619@0)
-
try seek to the begin of the file
-argcsina(我是陌生人);
2004-4-2
(#1669641@0)
-
什么意思? 能详细点么?本人编程初级水平...
-rainzw(rainzw);
2004-4-2
(#1669713@0)
-
I mean ,using fseek function move file pointer to the begin of the file
-argcsina(我是陌生人);
2004-4-3
(#1670353@0)
-
记得以前Windows缺省并没有COM3,你需要到Control Panel加一个虚的。
-canadiantire(Crappy Tire);
2004-4-2
(#1669750@0)
-
我不知道怎么加一个虚拟的, 但是我可以这样一来, DISABLE COM2, 再运行程序, COM2在CREATEFILE就是INVALID HANDLE了.就是说, 从CREATEFILE, 到SETCOMM, HANDLE都是可以的, 一到READFILE就歇菜了.
-rainzw(rainzw);
2004-4-2
{72}
(#1669781@0)
-
There is no COM3 at all.
-bugkiller(Driver Coding);
2004-4-5
(#1672818@0)
-
debug the code to find out when the handle becomes invalid....
-dundas888(登达寺);
2004-4-2
(#1669699@0)
-
就在READFILE那一行里面, 我COMMENTS了所有关于CONFIGURATION的代码.HWND m_Port;
try{
//open handle
m_Port = CreateFile("COM1",GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
if (m_Port == INVALID_HANDLE_VALUE){
// Handle the error.
Memo->Lines->Add("Invalid Handle");
return;
}
char input[200];
unsigned int lenBuff = 200;
LPDWORD lenMessage;
if(ReadFile(m_Port,input,lenBuff,lenMessage,NULL)==0){
Memo->Lines->Add("Failed in Reading Data");
}else{
Memo->Lines->Add(input);
}
-rainzw(rainzw);
2004-4-2
{502}
(#1669709@0)
-
Change lenMessage from LPDWORD to DWORD, use &lenMessage in ReadFile (). It will be ok.
-bugkiller(Driver Coding);
2004-4-5
(#1672837@0)