The case to use the com1.
Code: Select all
#include "FiveWin.ch"
function Main()
local oDlg, nComm := InitComm()
DEFINE DIALOG oDlg TITLE "Testing Comm functions"
oDlg:bCommNotify = { | nComm, nStatus | BytesAtPort( nComm, nStatus ) }
ACTIVATE DIALOG oDlg ;
ON INIT EnableCommNotification( nComm, oDlg:hWnd, 20, 20 )
CloseComm( nComm )
return nil
function InitCOMM()
local cDcb, nError, nBytes
local nComm := OpenComm( "COM1", 1024, 128 )
if ! BuildCommDcb( "COM1:9600,n,8,1", @cDcb )
MsgStop( "Error BUILD!" )
return .f.
endif
if ! SetCommState( cDcb )
MsgStop( "Error SETCOMM!" )
return .f.
endif
return nComm
function BytesAtPort( nComm, nStatus )
local cBuffer := Space(20 )
Msginfo( nSTATUS)
ReadComm( nComm, @cBuffer ) // <<<<---- program will lock here
Msginfo( AllTrim( cBuffer ))
return nil
YUN JIN SONG.