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

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

Postby yunbg1 » Sun Jun 11, 2006 2:11 pm

Hi Antonio.

The case to use the com1.

Code: Select all  Expand view  RUN
#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
yunbg1
 
Posts: 107
Joined: Sun Nov 13, 2005 12:40 am
Location: Winnipeg Canada

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

Postby Enrico Maria Giordano » Sun Jun 11, 2006 4:18 pm

SetCommState() requires two parameters:

Code: Select all  Expand view  RUN
if ! SetCommState( nComm, cDcb )


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 55 guests