Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to read data from RS232 port
Message
From
05/12/2001 07:26:06
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
05/12/2001 06:57:40
Imanali Padania
Sardinia Computer System
Mumbai, India
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00589704
Message ID:
00589714
Views:
21
>I have got assignement from a dairy to prepare dairy automation system , i have to capture data from Fat testing machine having RS232 output port which can be connected to PC
>Whenever machine Throw Data (numeric FatReading e.g. 5.6) this data should appear on my form where operator can further add more data
>
>PLEASE HELP ME IT'S VERY URGENT,
>IS THERE ANY SITE WHERE I CAN LEARN HOW TO READ DATA FROM RS232 port

Imanali,
Basically you would use MSComm32 activex. You can find valueable information in download area. Check for serial.zip by Marc Grajover.
Below sample waits data from a GPS for 5 seconds max with strings '$GPGGA' and '$GPGSA' in it (GPS was sending data at 4800 baud) :
* load mscomm
oComm = CREATEOBJ('MSCOMMLib.MSComm')
* Open and Initialize COM port #1 for use
With oComm
	.CommPort = 1
	.Settings = "4800,N,8,1"
	.InputLen = 1
	.PortOpen = .T.

	lcDATA=''
	lnStart = seconds()
	llDataReady = .F.
	Do while seconds()-lnStart < 5
		.InputLen = 1
		lcDATA = lcDATA+.input
		lnGGA = at('$GPGGA',lcData)
		lnGSA = at('$GPGSA',lcData)
		If lnGGA > 0 and lnGSA > lnGGA && Read enough
			llDataReady = .T.
			Exit
		Endif
	Enddo

	* Close the port
	.PortOpen = .F.
Endwith
Release oComm
if llDataReady
	? lcDATA, len(lcDATA)
else
	wait window timeout 2 'GPS timedout!'
endif
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform