FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Comm with USB device
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Comm with USB device
Posted: Fri Oct 08, 2010 06:17 PM

Can someone point me to a reference for using Comm communications with a USB port ? All samples of OpenComm are with Com1-4. Thanks.

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Comm with USB device
Posted: Mon Oct 11, 2010 04:37 PM

I'm putting this back up the list in case anyone has an answer.

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 95
Joined: Fri Nov 23, 2007 04:43 AM
Re: Comm with USB device
Posted: Mon Oct 11, 2010 06: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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Comm with USB device
Posted: Sat Oct 16, 2010 04:46 PM

I have a devise with the bridge working on Com 7, so now I'm moving ahead with testing.

Unfotunately the device instructions were not exactly clear. Hopefully I'll have this fully working soon.

Tim

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Comm with USB device
Posted: Tue Oct 19, 2010 09:46 PM

All examples use OPENCOMM and WRITECOMM, but no examples show READCOMM.

It is supposed to place the value from the pointer in the referenced field, and return the number of bytes in the string. I get a return value of 8, which is correct, but no string placed in the buffer.

Thoughts ?

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit

Continue the discussion