FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How if we open at the same time a com1 com2 ?
Posts: 109
Joined: Sun Nov 13, 2005 12:40 AM
How if we open at the same time a com1 com2 ?
Posted: Sun Jun 11, 2006 02:11 PM
Hi Antonio.

The case to use the com1.

#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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: How if we open at the same time a com1 com2 ?
Posted: Sun Jun 11, 2006 04:18 PM
SetCommState() requires two parameters:

if ! SetCommState( nComm, cDcb )


EMG

Continue the discussion