FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Read com port
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Read com port
Posted: Fri Apr 15, 2011 09:53 PM

I can't help you, it works for me.

EMG

Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: Read com port
Posted: Sat Apr 16, 2011 12:07 PM
This is what I use to read data from a medical device:
Code (fw): Select all Collapse
Local cDataRead:=Space( 10 )   //length of data to read
Local cDCB
Local nComm

//Setup COM port
if ! BuildCommDcb( "COM1":9600,n,8,1", @cDcb )
   MsgInfo("BuildComm Error")
endif
      
if ! SetCommState(  nComm, cDcb )
   MsgInfo("SetComm Error")
endif

if FlushComm( nComm, 1 ) != 0
   MsgInfo("FlushComm Error")
endif


//Read the COM port
ReadComm( nComm, @cDataRead )
Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Read com port
Posted: Sat Apr 16, 2011 12:16 PM
Jeff Barnes wrote:
Code (fw): Select all Collapse
if ! BuildCommDcb( "COM1":9600,n,8,1", @cDcb )


Code (fw): Select all Collapse
if ! BuildCommDcb( "COM1:9600,n,8,1", @cDcb )


EMG
Posts: 95
Joined: Fri Nov 23, 2007 04:43 AM
Re: Read com port
Posted: Sat Apr 16, 2011 02:05 PM
?
Jeff Barnes wrote:This is what I use to read data from a medical device:



Jeff, have you got an example of ASTM communication in fivewin?
Robert Frank
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: Read com port
Posted: Sat Apr 16, 2011 02:14 PM

Thanks Enrico .... a slip of the finger :)

Robert ... What is ASTM ?

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 95
Joined: Fri Nov 23, 2007 04:43 AM
Re: Read com port
Posted: Mon Apr 18, 2011 09:28 AM
Jeff Barnes wrote:Thanks Enrico .... a slip of the finger :-)

Robert ... What is ASTM ?


Standard of communication (via RS232 or sockets) between medical software and medical analysers.
Robert Frank
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: Read com port
Posted: Mon Apr 18, 2011 12:27 PM

Sorry ... I do not have an example of ASTM.

I simply just read the data on the port and process it. I wasn't even aware there was an actual protocol for RS2332 and medical devices.

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 7
Joined: Thu Sep 17, 2009 08:10 AM
Re: Read com port
Posted: Wed Apr 20, 2011 07:34 PM

Everything I'd tried to solve the problem but to no avail! The only thing I said to use FWH2.7.
I only have a few questions:
- Do I need a library hbcomm.lib? If I need where I can find?
- If your example of you doing, what your opinion may be a reason for me not working?

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Read com port
Posted: Wed Apr 20, 2011 08:02 PM

It could be a problem in your FWH release.

EMG

Posts: 95
Joined: Fri Nov 23, 2007 04:43 AM
Re: Read com port
Posted: Thu Apr 21, 2011 05:23 AM
Favory, Jef and Enrico wrotes main point of this subiect.

Jeff Barnes wrote:
if ! SetCommState( nComm, cDcb )
MsgInfo("SetComm Error")
endif


You wrote in your example
favory wrote:
if ! SetCommState( cDcb )
MsgStop( "Error SETCOMM!" )
return .f.
endif


Did you correct it to them version? SetCommState( nComm, cDcb )
Robert Frank
Posts: 7
Joined: Thu Sep 17, 2009 08:10 AM
Re: Read com port
Posted: Fri Apr 22, 2011 09:49 AM

With version FW1.92 everything works without problems! So the problem is FWH2.7 or xHarbour. Why? I don't know! I have another question. how do I make a simultaneous communication with multiple serial ports?

Continue the discussion