Hi all, a found a possible bug in v3.0.0.0 version of com0com.
I was created a pair COM59 COM60/ Open COM60 in Putty terminal, and COM60 in my test program:
#include"stdafx.h"#include<Windows.h>DWORDWINAPIThFu(void*p){HANDLEh=(HANDLE)p;DWORDdw;charbuf[2];buf[0]='z';while(1){Sleep(2000);WriteFile(h,buf,1,&dw,NULL);printf("w\n");}}int_tmain(intargc,_TCHAR*argv[]){HANDLEhf[3];COMMTIMEOUTSts;DWORDdw;COMMCONFIGcc;charbuf[128];buf[0]='r';hf[2]=CreateFile("\\\\.\\COM59",GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);if(hf[2]==INVALID_HANDLE_VALUE){printf("cant open port!\n");return-1;}dw=sizeof(cc);memset(&cc,0,sizeof(cc));cc.dwSize=sizeof(cc);cc.dcb.DCBlength=sizeof(DCB);GetCommConfig(hf[2],&cc,&dw);dw=sizeof(cc);cc.dcb.fDtrControl=0;cc.dcb.fDsrSensitivity=0;cc.dcb.fOutxCtsFlow=0;cc.dcb.fOutxDsrFlow=0;cc.dcb.fRtsControl=0;SetCommConfig(hf[2],&cc,dw);COMMTIMEOUTStm;GetCommTimeouts(hf[2],&tm);tm.ReadIntervalTimeout=MAXDWORD;tm.ReadTotalTimeoutMultiplier=MAXDWORD;tm.ReadTotalTimeoutConstant=MAXDWORD-1;tm.ReadIntervalTimeout=MAXDWORD;tm.WriteTotalTimeoutMultiplier=0;tm.WriteTotalTimeoutConstant=0;SetCommTimeouts(hf[2],&tm);printf("run\n");CreateThread(NULL,0,&ThFu,hf[2],0,&dw);while(1){ReadFile(hf[2],buf,1,&dw,NULL);printf("readed=%d\n",dw);}return0;}
I expected to see 'z' every 2 seconds in Putty, but nothing happens. WriteFile succeded only after input in COM60 terminal (something rad on COM59). So, WriteFile blocked forever while ReadFile blocked on read. In asynchronous OVERLAPPED logic (FILE_FLAG_OVERLAPPED in CreateFile + overlapped in read write) all working just fine.
Whats wrong? How to fix?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all, a found a possible bug in v3.0.0.0 version of com0com.
I was created a pair COM59 COM60/ Open COM60 in Putty terminal, and COM60 in my test program:
I expected to see 'z' every 2 seconds in Putty, but nothing happens. WriteFile succeded only after input in COM60 terminal (something rad on COM59). So, WriteFile blocked forever while ReadFile blocked on read. In asynchronous OVERLAPPED logic (FILE_FLAG_OVERLAPPED in CreateFile + overlapped in read write) all working just fine.
Whats wrong? How to fix?
I\m try to enable "emulate baudrate" an enable "buffer overrun", bot no luck