RS233

88 views
Skip to first unread message

Daniel Goldberg

unread,
Dec 3, 2021, 8:18:54 PM12/3/21
to harbou...@googlegroups.com

Hola, tengo que comunicarme via RS232 con un equipo auto-analizador de laboratorio

Existe en Harbour puro alguna manera de hacerlo?

O algún programa externo que pueda ejecutar desde mi aplicación Harbour

La configuración es Serial es: (8N1) 8 bits de datos, 1 bit Parada, Sin Paridad

Gracias

Daniel Goldberg

La Reja Buenos Aires

 

Hello, I have to communicate via RS232 with a laboratory auto-analyzer equipment

Is there in pure Harbor any way to do it?

Or some external program that I can run from my Harbor app

The configuration is Serial is: (8N1) 8 data bits, 1 Stop bit, No Parity

Thanks

Daniel Goldberg

La Reja Buenos Aires

Jiju Chackungal

unread,
Dec 4, 2021, 12:25:25 AM12/4/21
to Harbour Users
Hello Daniel,
Please check the folder ..\contrib\hbcomm in your Harbour folder. It has some nice example code for reference.
RS232 communication is easy and very reliable with the HB_COMxxxx functions (also check hbcom.ch in the Harbour include folder).

Code snippet from one of my implementation for your reference....
//-------------------------------------------------------------------------------------------------------------------------------------------------------         
#include "hbcom.ch"
...
......
.......
IF !( hb_COMOpen( nPort) )
   ErrorMessage("Error!", "Unable to Open COM: " + Transform( nPort, "99" ), ."XXX")
   RETURN .F.
ENDIF

IF !( hb_COMInit( nPort, nBaudrate, "N", 8, 1 ) )
      ErrorMessage("COM Port Initialization Error","Unable to Initialize COM: " + Transform( nPort, "99" )+"/"+transform( hb_comGetError(nPort),"9999"),"XX")
      RETURN .F.
ENDIF

         nSendBytes := hb_comSend(nPort, cString, len(cString),1000 /*Com Port Delay*/)                     

         nreads := hb_comRecv(nPort,@rxBuffer,1,1000 /* Com Port Delay */)         
....
.....
....
hb_ComClose(nPort)
                                           
//-------------------------------------------------------------------------------------------------------------------------------------------------------         

Cheers,
JC

Reply all
Reply to author
Forward
0 new messages