Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to check a device connected to COM1 from VFP
Message
De
10/03/2005 04:45:31
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 7
OS:
Windows XP SP2
Network:
Windows 2003 Server
Divers
Thread ID:
00994316
Message ID:
00994333
Vues:
19
>Hi,
>
>Does any one knows how to check whether a device connected to com1 is working? This device is not a modem.
>
>Thanks.

Using VFP? If so you can use MSComm activex control. Check for serial.zip in downloads. It has all the details in a good article (Marc DeGrajover? - sorry if I do not remember name right. Has been long I didn't see any posts from him).
Here is a simple test (correct port speed and other settings matter):
local lcData,ltStart
* 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=''
	ltStart = datetime()
	Do while datetime()-m.ltStart < 5 && Check port for around 5 secs max
		.InputLen = 1
		lcDATA = m.lcDATA+.input
	Enddo

	* Close the port
	.PortOpen = .F.
Endwith
Release oComm
if len(m.lcDATA) = 0
  ? "Couldn't read from port"
else 
  ? "Read "+trans(len(m.lcData))+" bytes:"+m.lcData
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform