Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MSCOMM32.OCX Problem.
Message
 
To
13/03/1997 19:05:29
General information
Forum:
Visual FoxPro
Category:
Third party products
Miscellaneous
Thread ID:
00023767
Message ID:
00024192
Views:
49
>Glen,
>I have been following this topic for educational purposes, but something constantly eludes me. It is embarassing to be sure, but here goes. . .
> Throughout *all* of the examples (from everyone) there is lots and lots of Property setting but never anything being 'executed' (except WAIT). Am I missing some "convention" used in describing these thing (I am newish to these Internet facilities) or is it so obvious that anyone would know or???
>
>Curiously,
>Jim N.

Jim,

I think you have described what a lot of people find confusing about the control. It is controlled by properties, and takes *action* based on the properties, in a buffered mode. When characters are placed in the output property, and the number of characters meets, or exceeds the Sthreshold, then the characters are sent, by the control. When characters are received by an open comport, and the number of characters meets or exceeds the Rthreshold, then the characters are placed in the Input property, ready for you to use. InputLen determines how many characters are emptied, when you read the input property.

There are two distinct *modes* (for lack of a better name) for receiving input. Manually empty the Input property, or create code in the ONCOMM method to respond as a receive event. Other variations of control use are also possible, and a matter of preference.

I think of the control as a buffer object. We send to, and receive from, the control object. Hidden from us is the automated interface to the UART, doing it's work in a buffered mode. We do not have direct communication with the UART.

Whether these are a really properties, or methods, is probably open for interpretation.

The code shown below can be cut & pasted into a program, that can then be executed with DO ProgramName.prg I've added some comments to the code, to illustrate the property use. This is quick and dirty code, if you will, that does not check for errors / feedback from the control. This is acceptable for this test, but not in my opinion for production work.

***** Top Code*****

* create a form object
* for test purposes, this does not
* have to be visible
ComForm = CREATEOBJECT('Form')

* place a mscomm object on the
* form, from the library
ComForm.AddObject("Testcom","Olecontrol","MSCOMMLib.MSComm")

* set the port & data properties
ComForm.Testcom.CommPort = 2
ComForm.Testcom.Settings = "9600,N,8,1"

* set the PortOpen Property
* the control will respond by
* actually opening the port
* for test purposes, we are not
* checking feedback to see if the
* port actually opened
ComForm.Testcom.PortOpen = .T.

* Set the send threshold property
* to one character. From here on,
* any characters placed in the output
* property will be transmitted.
ComForm.Testcom.Sthreshold=1

* set the inputlen property to 0
* this will read *all* characters
* when reading the input property
ComForm.Testcom.InputLen=0

* standard modem reset
* place reset string in output property
* and control will send it, since the length
* meets/exceeds Sthreshold
ComForm.Testcom.OUTPUT="AT&F"+CHR(13)

* US robotics and some other FAX modem reset
*ComForm.Testcom.OUTPUT="AT&F1"+CHR(13)

* wait for modem to reset. For test
* purposes, we will use a wait window
* with timeout
wait window "modem reset" timeout 2

* Read the input property. Since inputlen
* is set to 0, we should read everything
* that has been received so far.
cTestData=ComForm.Testcom.INPUT

* test for OK in received data
IF ! "OK"$cTestData
wait window "Modem Failed to reset"
ENDIF

* send a reasonably benign and generally acceptable
* init string to the modem
ComForm.Testcom.OUTPUT="ATE1V1&C1&D3S7=30X4"+CHR(13)

* wait for init string to transmit
wait window "modem initialize" timeout 2

* read input property and test for OK
cTestData=ComForm.Testcom.INPUT
IF ! "OK"$cTestData
wait window "Modem Failed to initialize"
ENDIF

* send dialing to modem
ComForm.Testcom.Output = "ATDP3716660" + chr(13)

* wait for modem to dial
wait window "dialing - press any key to exit"

* drop the DTR and leave low for
* 3 seconds to hang up
ComForm.Testcom.DTREnable=.F.
wait window "disconnecting" timeout 3

* raise the DTR Then Close the port
ComForm.Testcom.DTREnable=.T.
ComForm.Testcom.PortOpen = .F.
***** End Code ***

HTH
Glenn
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform