W
wu_xin_kuai_yu
Unregistered / Unconfirmed
GUEST, unregistred user!
//初始化 我第一次怎么也不能正确读去 但是 我只要运行依次 com设备的测试程序就
// 可以正确读出来,我搞不懂,我这里是不是那里不对了?
aCom:='com1';
//初始化串口[blue][/blue]
handle:=CreateFile(PChar(aCom),
GENERIC_READ+GENERIC_WRITE,
0,
nil,
OPEN_EXISTING,
0,
0 );
if handle = INVALID_HANDLE_VALUE then
begin
showmessage('无法打开串口:'+aCom);
exit;
end;
SetupComm(handle,4096,4096);
GetCommState(handle,dcb);
with dcb do
begin
BaudRate:=9600;
ByteSize:=8;
StopBits:=1;
Parity:=0;
end;
SetCommState(handle,dcb);
setLength(buf,7);
purgecomm(handle,PURGE_RXCLEAR);
ReadFile(handle,Buf[1],7,offset,nil);
buf读出的东西不是 'EEEEEEE'就是'UUUUUUU' 不应该是这样的
// 可以正确读出来,我搞不懂,我这里是不是那里不对了?
aCom:='com1';
//初始化串口[blue][/blue]
handle:=CreateFile(PChar(aCom),
GENERIC_READ+GENERIC_WRITE,
0,
nil,
OPEN_EXISTING,
0,
0 );
if handle = INVALID_HANDLE_VALUE then
begin
showmessage('无法打开串口:'+aCom);
exit;
end;
SetupComm(handle,4096,4096);
GetCommState(handle,dcb);
with dcb do
begin
BaudRate:=9600;
ByteSize:=8;
StopBits:=1;
Parity:=0;
end;
SetCommState(handle,dcb);
setLength(buf,7);
purgecomm(handle,PURGE_RXCLEAR);
ReadFile(handle,Buf[1],7,offset,nil);
buf读出的东西不是 'EEEEEEE'就是'UUUUUUU' 不应该是这样的