Hi,
I dropped the oleControl object on my form and called it oleComm. I have a table called Balance which I use to easily put/change the settings I want to use. The CommPort field stores which comm port the scale is plugged into, the settings field stores the baud rate, parity and so on that the scale has been set to, the Handshak field stores the handshake setting used by the scale and the Output field stores the command that gets sent to the scale to print the output, in my case this was "P" for print. The scale I have used is an Ohaus Adventurer Pro.
In it's Init() method I have:
WITH this
TRY
.CommPort = Balance.Commport
.Settings = Balance.Settings
.handshaking = Balance.HandShak
.PortOpen = .T.
CATCH
m.llInitOK = .F.
ENDTRY
ENDWITH
_vfp.AutoYield = .F.
Then when I want to read the value from the scale:
TRY
WITH THIS.oleComm
FOR lnCount = 1 TO Balance.NumTimes
.OUTPUT = Balance.OUTPUT
DOEVENTS
lnStart = SECONDS()
WAIT WINDOW NOWAIT "Reading weight from scale..."
DO WHILE SECONDS() - lnStart <= Balance.WaitInt
DOEVENTS
ENDDO
lnBufferCount = .inBufferCount
lcString = .INPUT
IF lnBufferCount > 0
WAIT WINDOW NOWAIT "Weight from scale..."+'[' + lcString +']'
ENDIF
WAIT CLEAR
ENDFOR
ENDWITH
CATCH
ENDTRY
RETURN VAL(CHRTRAN(UPPER(lcString), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", ""))
Hope this helps.
>Something like this :
>
>IF !THISFORM.oleControl1.portOpen
> thisform.oleControl1.portOpen = .T.
>ENDIF
>mtest = THISFORM.oleControl1.input
>
>Or I need to send request code to the machine in order to get feedback?
>How I know the data from Scale Machine is start, and end? What is the string format?
>
>My Client Machine is Teraoka DS-480c. I go to Teraoka Web Site, but can't get the information.
>
>Do you mind to share your code, or any web site can tell more about this.
>
>Thanks.