Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Oncomm event not firing in mscomm
Message
 
 
À
14/01/2002 12:20:54
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00604408
Message ID:
00604412
Vues:
22
Take a look at http://fox.wikis.com/wc.dll?Wiki~MsComm32~VFP.
You can also try to search for 'mscomm' in the message area for a recent discussion about mscomm. You cann narrow the search by looking for messages that involve Andrus Moor.

>Hi all,
>Does anyone know why the oncomm event isn't firing in the code below? When I call the getver procedure I can get the data from the input property, but the oncomm event never fires. I want to trap for the data in the oncomm event and not within each procedure. Any ideas?
>
>
>PUBLIC ComForm
>ComForm = CREATEOBJECT('Form')
>ComForm.AddObject("MsCom","MSCOMMCLASS")
>DO GetVer
>DO PlayMsg
>RETURN
>
>DEFINE CLASS MsCommClass AS OLEControl
>	OLECLASS = [MSCOMMLib.MSComm.1]
>
>	PROCEDURE WaitForResponse
>		LPARAMETERS lnDelayInSeconds
>		LOCAL lnStartTime
>		lnStartTime = SECO()
>		DO WHILE SECO() <= (lnStartTime + lnDelayInSeconds) ;
>				AND NOT SECO() < lnStartTime
>			DOEVENTS()
>		ENDDO
>	ENDPROC
>	PROCEDURE OnComm
>		*---Receive Data
>		WAIT WINDOW ALLTRIM(STR(THIS.CommEvent))
>		IF THIS.CommEvent = 2
>			IF THIS.InBufferCount>0
>				lcString = THIS.Input
>				IF !(lcString == "")
>					WAIT WINDOW "SUCCESS! Version Retrieved: "+lcString
>				ENDIF
>			ELSE
>				WAIT WINDOW "Tracy! Data Should have been Received..."
>			ENDIF
>		ENDIF
>	ENDPROC
>ENDDEFINE
>
>PROCEDURE GetVer
>	WITH ComForm.MsCom
>		.RThreshold = 1
>		.SThreshold = 1
>		.Settings = [9600,n,8,1]
>		.RTSEnable = .F.
>		.InputLen = 0
>	ENDWITH
>	m_port=1
>	ComForm.MsCom.CommPort = m_port
>	ComForm.MsCom.PortOpen = .T.
>	ComForm.MsCom.Output="~VER "+CHR(13)
>	ComForm.MsCom.WaitForResponse(2)
>	lcString=ComForm.MsCom.Input
>	WAIT WINDOW lcString NOWAIT
>	ComForm.MsCom.PortOpen = .F.
>RETURN
>
>PROCEDURE PlayMsg
>	WITH ComForm.MsCom
>		.RThreshold = 1
>		.SThreshold = 1
>		.Settings = [9600,n,8,1]
>		.RTSEnable = .F.
>		.InputLen = 0
>	ENDWITH
>	m_port=1
>	ComForm.MsCom.CommPort = m_port
>	ComForm.MsCom.PortOpen = .T.
>	ComForm.MsCom.Output = "~PLAY " + chr(13)
>	ComForm.MsCom.Output = "M " + chr(13)
>	ComForm.MsCom.PortOpen = .F.
>RETURN
>
>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform