Comm with USB device

Comm with USB device

Postby TimStone » Fri Oct 08, 2010 6: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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Comm with USB device

Postby TimStone » Mon Oct 11, 2010 4: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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Comm with USB device

Postby 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
User avatar
Robert Frank
 
Posts: 95
Joined: Fri Nov 23, 2007 4:43 am
Location: Gdynia-Poland

Re: Comm with USB device

Postby TimStone » Sat Oct 16, 2010 4: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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Comm with USB device

Postby TimStone » Tue Oct 19, 2010 9: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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: nageswaragunupudi and 106 guests