How if we open at the same time a com1 com2 ?

Post Reply
yunbg1
Posts: 107
Joined: Sun Nov 13, 2005 12:40 am
Location: Winnipeg Canada

How if we open at the same time a com1 com2 ?

Post by yunbg1 »

Hi Antonio.

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

The use a com1, com2 at the same time ?

YUN JIN SONG.
FWH User
FWPPC User
FWLinux User
Post Reply