Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Mscomm32.ocx / Serial Communications
Message
De
08/04/2003 20:13:20
James Blackburn
Qualty Design Systems, Inc.
Kuna, Idaho, États-Unis
 
 
À
08/04/2003 12:44:34
John Vlahos
V I Software Solutions Design
Mississauga, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00775141
Message ID:
00775304
Vues:
9
I have been doing this for years on a couple of different apps. You have to remember that the data is allways being sent. You have to get more than the 15 characters because you don't know for sure where the string was cut off when you got it last. Also, you have to get the most current weight from the string. Here is the code that I use:
WITH this.oleweight
	IF TYPE("NVL(oapp,'')") = "O"
		IF NOT this.lfrezzweight 
			LOCAL lnnum, lnSecs, lnNumber, lnDataLen, x
			LOCAL lacodes[1]
      *// get the lenght of the string comming from the indicator
			lnDataLen = oapp.osite.WS_datalength
 			IF .inBufferCount >= (lnDataLen*2)
				lcnum = .input
        * store the last string to look for motion codes
				this.clastscalestring = lcNum
				*// DEBUGOUT lcnum
				IF RAT(CHR(13),lcnum,1) > 0
					lcnum = SUBSTR(lcnum,RAT(CHR(13),lcnum,1)-lnDataLen,lnDataLen)
				ENDIF
				IF LEN(lcNum) < 10
					RETURN
				ENDIF
				lnNumber = INT(VAL(retnum(lcnum)))
				IF BETWEEN(lnNumber,0,999999)
					this.txtweight.Value = lnNumber
				ELSE
					this.txtweight.Value = 0
				ENDIF
				this.txtweight.Refresh()
       * Check for motion codes
				FOR x = 1 TO ALEN(this.acodes)
					IF ATC(this.acodes[x],lcnum) > 0
						this.lmotion = .t.
						EXIT
					ELSE
						this.lmotion = .f.
					ENDIF
				NEXT
			ENDIF
		ENDIF 
	ELSE
		.interval = 0		
	ENDIF 
ENDWITH 
>I am using the MSCOMM32.OCX provided with VFP 7.0 to commubicate with a WEIGH-TRONIX weight indicator through the RS-232 (Com 2). The weight indicator is continuously scanning the scale and is continuously sending the weight change as an outout to the rs232.
>
>An example of the continous output by the indicator is the following (string length of 15):
> G 0 lb 0
> G 0 lb 0
> G 0 lb 0
> G 0 lb 0
> G 0 lb 0
> G 0 lb 0
> G 0 lb 0
> G 0 lb 0
> G 50.5 lb 0
> G 50.5 lb 0
>
>However when I use MSCOMM32 to read the input, I get only " G ", string length of 8.
>
>Is there any obvious reason for this?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform