Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Mscomm.ocx serial port receiving
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00212263
Message ID:
00212286
Views:
19
>I am using mscomm to send data to the serial port but i cant get data
>from it with mscomm.
>
>Please send me a code sample how i get data from the serial com in real time.

Here is a sample that opens the COM port. Loops for a while waiting to get a "B". When a "B" is found, then read in next 8 characters. I didn't use the ONEVENTS tigger for this solution since it was unecessary.
oComm = CREATEOBJ('MSCOMMLib.MSComm')
* Open and Initialize COM port #1 for use
oComm.CommPort = 1
oComm.Settings = "9600,N,8,1"
oComm.InputLen = 0
oComm.PortOpen = .T.
for i = 1 to 10000 && loop until get first character for a few seconds
	oComm.inputlen = 1
	lnChar = oComm.input
	IF lnchar = "B"   && break out, found character
	        * Read in the rest of the bytes from the buffer 
		oComm.inputlen = 8
		cnetstring = oComm.input
		return "OK"
	ENDIF
ENDFOR
* "CLOSE THE PORT"
oComm.PortOpen = .F.
release oComm
Previous
Reply
Map
View

Click here to load this message in the networking platform