Balanza con conexion USB

Balanza con conexion USB

Postby devwin2010 » Wed Jan 07, 2015 7:41 pm

Estimados Colegas

Alguien tiene algun ejemplo como leer los datos de una balanza con conexion USB

desde ya muchas gracias
Fabian
devwin2010
 
Posts: 61
Joined: Tue Jul 17, 2007 12:37 pm

Re: Balanza con conexion USB

Postby karinha » Thu Jan 08, 2015 11:34 am

cual és el modelo?

Teste este ejemplo cambiando el puerto:

Code: Select all  Expand view

#include "FiveWin.ch"

// Protocolo Prt1 STXPPPPPETX
// Protocolo Prt2 STXPPPPPPCR
// Protocolo Prt3 STXP/I/N/SETX

#DEFINE ENQ chr(05)
#DEFINE STX chr(02)
#DEFINE ETX chr(03)
#DEFINE CR chr(13)

static hLib, hDib, oSpoolTimer, nCom

Function Main(_tempo_,cComm)
 Default _tempo_ := "05", cComm := "COM4"
 nCom := APRICOM( cComm )
 cConteudo := STX + strZero( Random( 999999 ), 6 ) + ETX
 for i = 1 to len( cConteudo )
   SENDSTR( nCom, Substr( cConteudo, i, 1 ) )
 next
 cConteudo := ""
 Return NIL        

STATIC FUNCTION TASTI( nCom, nKey )
  SENDSTR( nCom, CHR( nKey ) )
  RETURN NIL

STATIC FUNCTION APRICOM( cComm )
  LOCAL nCom, cDcb
  BEGIN SEQUENCE
    nCom = OPENCOMM( cComm, 16384, 16384 )
    IF nCom < 0
      ? "Errore di apertura della porta di comunicazione."
      BREAK
    ENDIF
    BUILDCOMMDCB( cComm+":115200,N,8,1", @cDcb )
    IF !SETCOMMSTATE( nCom, cDcb )
      ? "Errore di impostazione della porta di comunicazione."
      BREAK
    ENDIF
    Connect( nCom )
  RECOVER
    nCom = -1
  END SEQUENCE
  RETURN nCom

STATIC FUNCTION CONNECT( nCom )
  LOCAL cStr
  ENABLECOMMNOTIFICATION( nCom, 0, 1, -1 )
  cStr = RECEIVESTR( nCom )
  cStr = STRTRAN( cStr, CHR( 13 ), "" )
  cStr = STRTRAN( cStr, CHR( 10 ), CRLF )
  RETURN NIL

STATIC FUNCTION SENDSTR( nCom, cString )
  LOCAL nBytes := WRITECOMM( nCom, cString )
  RETURN nBytes = LEN( cString )

STATIC FUNCTION RECEIVESTR( nCom )
  LOCAL cBuf := SPACE( 1000 )
  RETURN LEFT( cBuf, READCOMM( nCom, @cBuf ) )

STATIC FUNCTION Random( nMaximo )
  static nRandom
  local nTemporal
  nMaximo = if( nMaximo == NIL, 65535, nMaximo )
  if nRandom == NIL
   nRandom = seconds()
  endif
  nTemporal = ( nRandom * seconds() ) % ( nMaximo + 1 )
  nRandom = nTemporal + seconds()
  RETURN int( nTemporal )
 


salu2
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7794
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], russimicro and 40 guests