Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using MSCOMM with USB to serial device
Message
From
29/05/2008 13:24:13
 
 
To
29/05/2008 11:45:22
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01320080
Message ID:
01320314
Views:
22
>>I can type the following in the command window and get the correct data back from the device.
>>
>>ot = CREATEOBJECT('mscommlib.mscomm')
>>ot.CommPort = 4
>>ot.Settings='115200,n,8,1'
>>ot.PortOpen = .T.
>>lqout = 0hA0A20001B700B7B0B3
>>ot.Output = lqout
>>lqin = ot.Input
>>ot.PortOpen = .F.
>>CREATE CURSOR test (testrec Q(100))
>>INSERT INTO test VALUES(lqin)
>>
>
>You do execute that line by line? Not Select it, right click and then Execute Selection, do you?
>
I think I need to clarify my procedure when I run the code from inside a PRG. I insert SET STEP ON right before the ot.output = lqout. When the program stops at that line, I expand the ot object in the watch window. I then step into the next line (ot.output = lqout). I can see somthing flash in Input in the watch window and then immediately disappear before moving to the next line.

I thought stepping through one line at at time would be the same as typing into the command window as far as timing and waiting for a response goes.

>It's surely the other way around as you think, Input is not cleared before you take it into lqin, it just did not yet arrive. 115200 baud is still rather slow...
>
>Checking with COVERAGE a line like lqin = ot.Input takes 0.000205 seconds to execute. ot.Output = lqout took 0.002050 secs. With a baud rate of 14400 Bytes per second you gave the comport the chance to transfer about 32 Bytes forth and back, not taking into account some latency times and the time VFP needs to execute.
>
>If waiting for receive comm event seems over the top for you in this case, then simply give some time between output and input.
>
>
>ot.Output = lqout
>wait window '' timeout .1
>lqin = ot.Input
>
>
>Bye, Olaf.
Thanks for this suggestion. I tried it but for the reason I explained above did not give me a value for the data received.

I appreciate your help.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform