Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Comm Port access
Message
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00231862
Message ID:
00231888
Views:
24
>I need to access a black box thru the pc serial port comm1. the data is ascII. I have created a comm object and the property o.portopen does equal true. Problem is I can not create a handshake or transmit or recieve to a buffer. I thought I could use fopen(), but the handle comes back -1.
>Any ideas?, here is the code to access the port. After that ?
>PUBLIC ComPort
> ComPort = CREATEOBJECT('Form')
> ComPort.AddObject("Usecom","Olecontrol","MSCOMMLib.MSComm")
> ComPort.USecom.CommPort = 1 && Use Comm1, The first Serial Port.
>
> * Comm Port settings 9600 baud, Even Parity,7 data Bits, 1 Stop Bit
> ComPort.USecom.Settings = This.pBaudRate+','+This.pParity+','+This.pDataBits+','+This.pStopBits
> ComPort.USecom.PortOpen = .T.
> ComPort.USecom.Output ="C:\SPS\PHOENIX.DAT"
>

I would assume from the example that you're trying to send the string "C:\SPS\PHOENIX.DAT" out the comm port. To send a file, you'd have to read it line by line and send it out.

What type of handshaking are you trying to do? There are a bunch of properties to control the type of handshaking done with the other end; you may want to set the state of the Handshaking property (the default of 0 is no handshaking used), DTREnable property (the default is .F.) and RTSEnable property (the default is .F.), depending on how the box at the other end behaves.

The genberal approach you've taken uses polled I/O; this pretty much means that your application will have to spend most of its time checking for responses from the black box. Until VFPCOM.DLL became available, this was your only option available with the MSCOMM32 control, since there was no way to attach VFP code to the OnComm event; with VFPCOM.DLL, you can create a wrapper object that can be bound to the control's event and use VFPCOMM's BindEvents method to bind an instance of a VFP class to an instance of the MSCOMM32 control, allowing you to respond to send and receive events as they occur, rather than polling continuously.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform