There is a sample from Enrico that read/write to COM
http://forums.fivetechsupport.com/viewt ... ad+comport
A com port is reading text data, but can also read a power signal ? It has to open a cashdrawer with a power signal)
BTW : I have no background on technics...
MENUITEM "DrawerOpen" ACTION Drawer('Open Drawer','COM1',4800,chr(27)+chr(112)+chr(0)+chr(7)+chr(35),'','')
Code: Select all
function Drawer(x0,x1,x2,x3,x4,x5)
local cDcb, nBytes
local nComm := OpenComm( alltrim(x1),x2, 128 )
local nError
if empty(x1) .or. alltrim(x1)='-' .or. alltrim(x1)='SCREEN'
return .t.
endif
if upper(left(x1,3))='LPT'
BuildCommDcb( alltrim(x1)+":"+str(x2,4)+",n,8,1", @cDcb )
SetCommState( cDcb )
cNxLine=CRLF
else
if alltrim(x1)<>'SCREEN'
x3=padl(left(x3,20),20,' ')
x4=padl(left(x4,20),20,' ')
endif
cNxLine=CHR(13)
if ! BuildCommDcb( alltrim(x1)+":"+str(x2,4)+",n,8,1", @cDcb )
nError = GetCommError( nComm )
Msgwait( x0+" : BuildCommDcb Error: " + Str( nError ),'',.3 )
endif
if ! SetCommState( cDcb )
nError = GetCommError( nComm )
Msgwait( "SetCommState Error: " + Str( nError ),'',.3 )
return .t.
endif
endif
if !empty(x5)
for iii=1 to len(x5)
if ( nBytes := WriteComm( nComm, x5[iii]) ) < 0
nError = GetCommError( nComm )
Msgwait( "WriteComm Error: " + Str( nError ),'',.1 )
else
Msgwait( x0+' : Ok','',.1 )
endif
next
else
if ( nBytes := WriteComm( nComm, x3+cNxLine ) ) < 0
nError = GetCommError( nComm )
Msgwait( "WriteComm Error: " + Str( nError ),'',.1 )
else
Msgwait( x0+' : Ok','',.1 ) // important, do not change the delay
endif
if !empty(x4)
if ( nBytes := WriteComm( nComm, x4+cNxLine ) ) < 0
nError = GetCommError( nComm )
Msgwait( "WriteComm Error: " + Str( nError ),'',.1 )
else
Msgwait( x0+' : Ok','',.1 )
endif
endif
endif
if FlushComm( nComm, 0 ) != 0
nError = GetCommError( nComm )
Msgwait( x0+" : FlushComm Error: " + Str( nError ),'',.01 )
endif
if ! CloseComm( nComm )
nError = GetCommError( nComm )
Msgwait( "CloseComm Error: " + Str( nError ),'',.01 )
endif
return nil
So in this code there is the power signal to open the drawer.
This kind of sensor could give a powersignal to the COM port
It is that signal that I want to track and use in a FW app.