Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Mscomm32.ocx / Serial Communications
Message
From
08/04/2003 20:13:20
James Blackburn
Qualty Design Systems, Inc.
Kuna, Idaho, United States
 
 
To
08/04/2003 12:44:34
John Vlahos
V I Software Solutions Design
Mississauga, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00775141
Message ID:
00775304
Views:
10
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?
Previous
Reply
Map
View

Click here to load this message in the networking platform