by Robert Frank » Mon Oct 11, 2010 6:22 pm
Tim
I use USB to RS232 bridge, so I still think like "normal com".
(PL-2303 USB to Serial Bridge Controller)
I guess it isn't answer for your question, but maybe is way to do it what you want:)
Regards
Robert
Function COM_OPEN(xPORT)
Local pNAME
Local nError,cDCB
Local xRESZTA:=.T.
Do Case
Case xPORT=1
pNAME:="COM1"
Case xPORT=2
pNAME:="COM2"
Case xPORT=3
pNAME:="COM3"
Case xPORT=4
pNAME:="COM4"
Case xPORT=5
pNAME:="COM5"
Case xPORT=6
pNAME:="COM6"
Case xPORT=7
pNAME:="COM7"
Case xPORT=8
pNAME:="COM8"
Case xPORT=9
pNAME:="COM9"
EndCase
hPORT:= OpenComm( pNAME, 2048, 2048 )
If ! BuildCommDcb( pNAME+cSPEED, @cDcb )
nError = GetCommError( hPORT )
MsgInfo( "BuildCommDcb Error: " + Str( nError ) )
xRESZTA:=.F.
EndIf
If ! SetCommState( hPORT, cDcb )
nError = GetCommError( hPORT )
MsgInfo( "SetCommState Error: " + Str( nError ) )
xRESZTA:=.F.
EndIf
If xRESZTA
oWND:oMSGBAR:cMSGDEF:=PNAME+" : OPEN"
oWND:oMSGBAR:Refresh(.T.)
Else
oWND:oMSGBAR:cMSGDEF:=PNAME+" : NOT OPEN"
oWND:oMSGBAR:Refresh(.T.)
EndIf
Return xRESZTA
Function COM_SEND(cTEKST)
Local xMESSAGE
Local nBYTES
Local nERROR
If ( nBytes := WriteComm( hPORT, cTEKST) ) <= 0
nError = GetCommError( hPORT )
MsgInfo( "WriteComm Error: " + Str( nError ) )
Else
// any GUI reaction
EndIf
Return .T.
Robert Frank