RS232

RS232

Postby Robert Frank » Mon Dec 03, 2007 7:28 pm

From few years I used FW 2.3 version of FW. I've used RS232 to print barcodes on serial printers.
Now when I change my environment to xHarbour and install FWH 7.12 I found that my code doesn't work correctly.

I've started do debug my program and I've found that SetCommState(cDcb)
hangs up my program. Has somebody an idea how to use serial ports with xHarbour?

Function COM_OPEN(xPORT)
Local pNAME:=IIF(xPORT=1,"COM1","COM2")
Local nError,cDCB
Local xRESZTA:=.T.
hPORT:= OpenComm( pNAME, 2048, 2048 )
If ! BuildCommDcb( pNAME+cSPEED, @cDcb )
nError = GetCommError( hPORT )
MsgInfo( "BuildCommDcb Error: " + Str( nError ) )
xRESZTA:=.F.
EndIf
If ! SetCommState( cDcb )

// there programs brakes //

nError = GetCommError( hPORT )
MsgInfo( "SetCommState Error: " + Str( nError ) )
xRESZTA:=.F.
EndIf
....
Return

Regards
Robert
User avatar
Robert Frank
 
Posts: 95
Joined: Fri Nov 23, 2007 4:43 am
Location: Gdynia-Poland

RS232

Postby TimStone » Mon Dec 03, 2007 7:56 pm

You might want to post that on one of the xHarbour newsgroups.
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: RS232

Postby Robert Frank » Mon Dec 03, 2007 8:00 pm

TimStone wrote:You might want to post that on one of the xHarbour newsgroups.


It works again
I've found my mistake, there are small differences between clipper and harbour in using SetCommState()

correct line is:
If ! SetCommState( hPORT, cDcb )

I'm going to test RS communication with laboratory analysers now. :)

Robert
User avatar
Robert Frank
 
Posts: 95
Joined: Fri Nov 23, 2007 4:43 am
Location: Gdynia-Poland

Postby Antonio Linares » Mon Dec 03, 2007 8:40 pm

Robert,

Very good :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Robert Frank » Mon Dec 03, 2007 8:55 pm

Antonio Linares wrote:Robert,

Very good :-)


Antonio
Like a beginers, I've started to read examples and sources :)
User avatar
Robert Frank
 
Posts: 95
Joined: Fri Nov 23, 2007 4:43 am
Location: Gdynia-Poland


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 69 guests