Page 1 of 1

Error Lectura en COM

PostPosted: Tue Jul 25, 2006 5:31 pm
by mariocorona
Hola tengo configurado un com para lectura
el problema es que recibe basura
pero si antes abro el hiper-terminal de windows y lo cierro y entro a el programa en five win.. si lo lee bien
al reiniciar la maquina tengo que hacerlo nuevamente,
he intentado de todo.. pero no le encuentro, utilizo FW xHarbour

tengo que mandar algun caracter al puerto o que puede ser?

De antemano Gracias

Re: Error Lectura en COM

PostPosted: Tue Jul 25, 2006 6:31 pm
by karinha
mariocorona wrote:Hola tengo configurado un com para lectura
el problema es que recibe basura
pero si antes abro el hiper-terminal de windows y lo cierro y entro a el programa en five win.. si lo lee bien
al reiniciar la maquina tengo que hacerlo nuevamente,
he intentado de todo.. pero no le encuentro, utilizo FW xHarbour

tengo que mandar algun caracter al puerto o que puede ser?

De antemano Gracias



http://www.fivewin.com.br/Dicas/606PORTA.ZIP

Saludos.

PostPosted: Tue Jul 25, 2006 6:58 pm
by mariocorona
karinha:

Pregunta... en donde consigo

nBytes := OutBufClr(nComm) // Limpa o Buffer de Saida.
nBytes := InbufSize(nComm) // Pega Dados do Buffer.

de Antemano Gracias

PostPosted: Tue Jul 25, 2006 9:15 pm
by karinha
mariocorona wrote:karinha:

Pregunta... en donde consigo

nBytes := OutBufClr(nComm) // Limpa o Buffer de Saida.
nBytes := InbufSize(nComm) // Pega Dados do Buffer.

de Antemano Gracias



//-> COMANDOS DE LA HBCOMM.LIB

#pragma BEGINDUMP
/*

The Harbour interface routines for the HBCOMM library. It is not clear who
produced the harbour routines to interface with Harold Howe's TCommPort
encapsulation. Regardless, the Harbour interface has been modified to
allow for more than one port to be open (MAXOPENPORTS) compiled at 20 and
to allow for the sending and receiving of data containing NULL characters
(Chr(0)).

As a C/C++ coder, I make a fair plumber. Anyone who wishes to clean-up my
code is welcome to do so.

Ned Robertson
XpertCTI, LLC
Richmond, VA USA
July, 2003

*/

#include "hbapi.h"
#include "hbcomm.h"

static int aHandles[ MAXOPENPORTS ] ; // assumes initialized to zeros
static int nHBase = 256 ;

// ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ //

HB_FUNC(INIT_PORT) /* Nx_port(string),Nbaud(numerico),Ndata(numerico),Nparity(numerico),Nstop(numerico),nBufferSize(numerico)
retorna .t. se abriu a porta */

/* cPort, nBaudrate, nDatabits, nParity, nStopbits, nBuffersize

Main initiator/port opener.

cPort may take either the form 'COMn' or the more general '\\.\COMn'
The more general form is required for port numbers > 9.

nParity codes: 0,1,2,3 -> none, odd, mark, even

nStopBits codes: 0,1,2 -> 1, 1.5, 2

Returns a "handle" >= 256. A return of -1 means open failed.

The handle must be used on all references to the port and is equivalent to
nComm used in 16 bit Clipper/Fivewin routines. All routines take the
handle reference as their first argument.

*/

{

int i = 0, n = -1, nHandle ;

while ( n < 0 && i < MAXOPENPORTS ) {

if ( aHandles[ i++ ] == 0 )

n = i - 1 ;

}

if ( n != -1 ) {

nHandle = nHBase++ ;

aHandles[ n ] = nHandle ;

if ( hb_init_port( n, hb_parc( 1 ) , hb_parnl( 2 ) ,
hb_parnl( 3 ) , hb_parnl( 4 ) , hb_parnl( 5 ) ,
hb_parnl( 6 ) ) )

hb_retnl( nHandle ) ;

else

hb_retnl( 0 ) ;

}

}

// ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ //

HB_FUNC( OUTBUFCLR ) // purge output buffer -> Limpeza da Saida do Buffer
{
int nIdx ;

nIdx = FindIndex( hb_parnl( 1 ) ) ;

if ( nIdx != -1 ) {

hb_outbufclr( nIdx ) ;

hb_retl( TRUE ) ;

}

else

hb_retl( FALSE ) ;


}

// ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ //

HB_FUNC( ISWORKING ) // See if port is opened correctly
{
int nIdx ;

nIdx = FindIndex( hb_parnl( 1 ) ) ;

if ( nIdx != -1 )

hb_retl( hb_isworking( nIdx ) );

else

hb_retl( FALSE ) ;

}

// ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ //

HB_FUNC( INCHR ) // fetch hb_parnl( 2 ) chars into hb_parc( 3 )
{

int nIdx ;

nIdx = FindIndex( hb_parnl( 1 ) ) ;

if ( nIdx != -1 )

// hb_retc( hb_inchr( nIdx, hb_parnl( 1 ) ) );
hb_retnl( hb_inchr( nIdx, hb_parnl( 2 ), hb_parc( 3 ) ) ); // EDR*7/03

else

hb_retnl( 0 ) ;

}

// ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ //

HB_FUNC( OUTCHR ) // Send out characters. Returns .t. if successful.
{

int nIdx ;

nIdx = FindIndex( hb_parnl( 1 ) ) ;

if ( nIdx != -1 )

// hb_retl( hb_outchr( hb_parc( 1 ) ) );
hb_retl( hb_outchr( nIdx, hb_parc( 2 ), hb_parclen( 2 ) ) ); // EDR*7/03

else

hb_retl( FALSE ) ;

}

// ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ //

HB_FUNC( INBUFSIZE ) // Find out how many chars are in input buffer
{

int nIdx ;

nIdx = FindIndex( hb_parnl( 1 ) ) ;

if ( nIdx != -1 )

hb_retnl( hb_inbufsize( nIdx ) );

else

hb_retnl( 0 ) ;

}

// ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ //

HB_FUNC( OUTBUFSIZE ) // Find out how many characters are in out buf ?
{

int nIdx ;

nIdx = FindIndex( hb_parnl( 1 ) ) ;

if ( nIdx != -1 )

hb_retnl( hb_outbufsize( nIdx ) );

else

hb_retnl( 0 ) ;

}

// ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ //

HB_FUNC( UNINT_PORT ) // Close port and clear handle
{
int nIdx ;

nIdx = FindIndex( hb_parnl( 1 ) ) ;

if ( nIdx != -1 ) {

hb_unint_port( nIdx );

aHandles[ nIdx ] = 0 ;

hb_retl( TRUE ) ;

}

else

hb_retl( FALSE ) ;
}

// ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ //

int FindIndex ( int nH ) // Convert "handle" to tcomm array index
{
int i = 0, n = -1 ;

while ( n < 0 && i < MAXOPENPORTS ) {

if ( aHandles[ i++ ] == nH )

n = i - 1 ;

}

// printf( "index= %8d\n", n );

return n ;
}

// ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ //

HB_FUNC( CHKIDX ) // For debugging - not normally used

{
int nIdx ;

nIdx = FindIndex( hb_parnl( 1 ) ) ;

hb_retnl( nIdx );

}

#pragma ENDDUMP

PostPosted: Thu Jul 27, 2006 5:16 pm
by mariocorona
este archivo que me hiciste el favor de pegar...
como lo convierto a LIB ?
o de donde lo bajo como lib.. o PRG
o que sigue....

De antemano Gracias

PostPosted: Thu Jul 27, 2006 5:29 pm
by karinha
DE MI PUNTO DE VISTA, NO HAY NECESIDAD DE LA REGENERAR.

PUÉS LA LIBRERIA HABCOMM.LIB, ÉS FREE.

PUEDES PEDIRLA A ANTONIO, O CUALCUER OTRO MEMBRO DE ACÁ.

OU EN EL SITE DEL PROYECTO XHARBOUR, HABLAS COM LUIZ RAFAEL CULIK.

Saludos

PostPosted: Thu Jul 27, 2006 6:06 pm
by clemerson
funciona para ler LTP1 ?

Clemerson

PostPosted: Thu Jul 27, 2006 8:13 pm
by karinha
clemerson wrote:funciona para ler LTP1 ?

Clemerson


NO COMPRENDO?! PORQUE LA DUDA??

HBCOMM.LIB CREO KE ÉS SOLAMENTE PARA LECTORES SERIALES.

COM1, COM2, COM3... Etc.

Puedo estar errado.

Saludos.