Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Don Higgins
  Where is Don Higgins?
 Peoria
 Illinois - United States
 Don Higgins
 To: aris suguitan
  Where is aris suguitan?
 quezon
 Philippines
 aris suguitan
 Tags
Subject: RE: open serial port for communication
Thread ID: 288988 Message ID: 289010 # Views: 47 # Ratings: 3
Version: Visual FoxPro 9 Category: VFP and .NET
Date: Monday, December 27, 2010 7:50:19 PM         
   


> can someone able to help me create a code that will open serialport com1 or com2
> with details below
>
> port selection com1~com8
> baud rate 9600
> echo off
> data bits selection 1~8
> parity none
> stop bits 1
>
> when a button named activate is press and displays the status of connection to taskbar. like connected 9600,7,1 with timer.
>
> i will use this to read data from serialport
>
> sample data coming from serialport
> 000100051234567890123
> 000100051234567890125
> 000100051234567890124
>
> and the data will be saved with user provided filename.
>
> thank you
>
> aris1781



I assume you already dropped a mscomm OLE onto your form.

In the INIT() of the mscomm control use this code to get you started:

* INIT of Comm OLE 
* Uses form property OR direct from database
* for CommPort and settings
With This

	If ! .PortOpen
		* Select SETUP.DBF to get communication Port number
		Select SETUP
		* Get communication Port Number from SETUP.DBF field CommPort
		.commport = setup.CommPort

		* Settings if need to be changed from Default go below this line

		* Now open the port
		.PortOpen = .T.
	Endif

Endwith




If you need to run this off a COMMAND BUTTON you will need to modify the code above



To read the port then use


* Transfer information from communication port to a FORM PROPERTY
* 
* Assumes you have the form property called Comm_Port_Data and the mscomm control is called ComCt1

With Thisform
	* Check to see if port is open before running line below otherwise an error will occur

	.comm_port_data = .comCtl.Input  

Endwith




Don Higgins



http://www.youtube.com/watch?v=dcuFx85o8XU


ENTIRE THREAD

open serial port for communication Posted by aris suguitan @ 12/27/2010 3:44:33 PM
RE: open serial port for communication Posted by William Sanders @ 12/27/2010 5:22:27 PM
RE: open serial port for communication Posted by Borislav Borissov @ 12/27/2010 5:31:45 PM
RE: open serial port for communication Posted by Caramatescu Adrian @ 12/27/2010 5:32:00 PM
RE: open serial port for communication Posted by Don Higgins @ 12/27/2010 7:50:19 PM