open_com proc

invoke CreateFile,ADDR com_name,GENERIC_READ or GENERIC_WRITE,0 ,NULL,OPEN_EXISTING,FILE_FLAG_OVERLAPPED,NULL
mov ,eax
cmp eax,INVALID_HANDLE_VALUE
jnz com_ok
mov eax,FALSE
ret
com_ok:

invoke SetCommMask,,EV_RXCHAR
invoke SetupComm,,256,256
invoke PurgeComm,,0fh
invoke SetCommTimeouts,,ADDR timeouts

invoke GetCommState,,ADDR MY_DCB
mov esi,offset MY_DCB
mov eax,
mov ,eax
mov ebx,
mov ,bl
mov eax,
mov ,al
mov ebx,

mov ,bl
mov eax,
mov eax,1h
mov ,eax
mov ,0
mov ,0
mov byte ptr ,FALSE
mov byte ptr ,FALSE

invoke SetCommState,,ADDR MY_DCB

invoke EscapeCommFunction,,SETDTR
invoke EscapeCommFunction,,SETRTS


;invoke WriteFile,,ADDR pufi, 1,NULL,ADDR ov

invoke SetCommMask,,EV_BREAK or EV_CTS or EV_DSR or EV_ERR or EV_RING or EV_RLSD or EV_RXCHAR or EV_RXFLAG or EV_TXEMPTY


;EV_BREAK ; A break was detected on input.
;EV_CTS ; The CTS (clear-to-send) signal changed state.
;EV_DSR ; The DSR (data-set-ready) signal changed state.
;EV_ERR ; A line-status error occurred. Line-status errors are CE_FRAME, CE_OVERRUN, and CE_RXPARITY.
;EV_RING ; A ring indicator was detected.
;EV_RLSD ; The RLSD (receive-line-signal-detect) signal changed state.
;EV_RXCHAR ; A character was received and placed in the input buffer.
;EV_RXFLAG ; The event character was received and placed in the input buffer. The event character is specified in the device's DCB structure, which is applied to a serial port by using the SetCommState function.
;EV_TXEMPTY    ; The last character in the output buffer was sent.

break_point
invoke  CreateThread,0,0,ADDR CommListener,,4,ADDR CommListenerID
break_point
mov ,eax
invoke  ResumeThread,



mov eax,TRUE
ret



open_com endp


CommListener proc _hcom:DWORD
break_point
mov esi,offset pufi
mov al,
mov eax,[_hcom]
mov ebx,
; invoke WriteFile,[_hcom],ADDR pufi+2, 1,NULL,ADDR ov
invoke WaitCommEvent,[_hcom],ADDR comevent ,ADDR ov

invoke WriteFile,[_hcom],ADDR pufi+1, 1,NULL,ADDR ov


ret
CommListener endp


WaitCommevent not waiting comm event.
What is a problem?

please correct or post work sample in waitcommevent api call

thx

Posted on 2006-03-19 09:06:06 by korte