Ver Mensaje Individual
  #1  
Antiguo 11-04-2010
ASAPLTDA ASAPLTDA is offline
Miembro
 
Registrado: jun 2003
Ubicación: COLOMBIA-CALI
Posts: 639
Reputación: 21
ASAPLTDA Va por buen camino
Leer datos lectora de tarjetas Soyal AR721H

Hola Foristas, iniciado el proceso de generar un sistema que utiliza la lectora de tarjetas de aproximacion soyal ar721h , y si alguno a logrado leer la informacion de esta lectora nos cuente como lo hizo, He tratado de hacerlo y ahi voy pero algunos problemas de mi total desconocimiento del lenguaje C me detienen.

En la parte inferior adjunto el ejemplo codigo hecho en lenguaje C provisto por el proveedor y parte del codigo hecho en delphi para ejecutar la mismo informacion

Como ven mi expereincia en leguaje c es igual a 0 ahora si algunos de ustedesw me pueden orientar estare presto a leer la informacion

por ejemplo estas definiciones como se harian en delphi
las siguientes la he hecho y parecen funcionar

Código:
var
  Form1: TForm1;
   pComm:Pointer ;
   nPort:integer;
   nLen :WORD;

   function IsPortAvailable(p:integer):integer ; stdcall external 'SoyalComm.dll';
   function CreateSPort()             :pointer ; stdcall external 'SoyalComm.dll';
   function DeleteSPort(p:Pointer )   :integer ; stdcall external 'SoyalComm.dll';

   function OpenSComm( pcomm:Pointer; nPort:integer )  :integer ; stdcall external 'SoyalComm.dll';
   function CloseSComm( pcomm:Pointer)  :integer ; stdcall external 'SoyalComm.dll';

// PROCESO DE LECTURA
procedure TForm1.Button1Click(Sender: TObject);
var
 p:integer;
 r:integer;
 TxBfx :string [255];   // <--- EL MANUAL DICE 256 DELPHI ACEPTA 255
 RxBfx  :string [255]; // <--- EL MANUAL DICE 256 DELPHI ACEPTA 255

// ? COMO CONVERTIR ESTO A DELPHI 
//	void*	pComm;
//	int		i;
//	WORD	nLen;
//	BYTE	TxBfx[256], RxBfx[256];
//	DWORD	deError;



begin
  nPort:= strtoint(Edit_Puerto.text);
  r:= IsPortAvailable(nPort);    // nombre funcion o procedure de la dll
   showmessage('IsPortAvailable ' + IntToStr(r) );

// CREAR PUERTO
  if r = 1 then
  pComm:= CreateSPort() ;

// OPEN PUERTO
  r:=OpenSComm( pcomm  , nPort  );
   showmessage('OpenSComm ' + IntToStr(r) );

// LEER PUERTO
									// Command of Soyal AR737H1356:

// ? COMO CONVERTIR ESTO A DELPHI 

 			TxBfx[0] := '0xFF';		// Destination Node Address
 			TxBfx[1] := '0x12';		// Node information
 			TxBfx[2] := '0x02';		// Read Command
 			TxBfx[3] := 'R';			// Parameters
 			nLen     := 4;

// CLOSE PUERTO
  r:=CloseSComm( pcomm)  ;
   showmessage('CloseSComm: ' + IntToStr(r) );

// DELTE PUERTO
  r:= DeleteSPort(  pComm )  ;
   showmessage('DeleteSPort: ' + IntToStr(r) );


end;


Código:
  CODIGO HECHO EN C PARA PROCESAR DLL PARA CONVERTIR A DELPHI 
////////////////////////////////////////////////////////////////////////////
//	Usage:
//
//
//	#include	"SoyalComm.h"
//
// void  main()
// {
//	void*	pComm;
//	int		i;
//	WORD	nLen;
//	BYTE	TxBfx[256], RxBfx[256];
//	DWORD	deError;
//
//		//////////////////////////////////////////////////////
//		// Fine the available serial ports from COM1 ... COM6
//		for( i=0; i < 6; i++ ) {
//			if( IsPortAvailable( i ) ) {
//				// Do something like add to selection box
//			}
//		}
//
//		if( (pComm = CreateSPort()) == NULL ) {
//			printf( "Cann't create SoyalComm object !\n" );
//			return;
//		}
//
//		////////////////////////////////////////////////////////
//		// Connect the SoyalComm object to serial port (COM1)
//		if( OpenSComm( pComm, 0 ) {
//									// Command of Soyal AR737H1356:
//			TxBfx[0] = 0xFF;		// Destination Node Address
//			TxBfx[1] = 0x12;		// Node information
//			TxBfx[2] = 0x02;		// Read Command
//			TxBfx[3] = 'R';			// Parameters
//			nLen = 4;
					// Get AR721H Node(001) Event -> TxBfx[0] = 0x01, TxBfx[1] = 0x18, nLen = 2
//			if( ReadWriteSComm( pComm, TxBfx, RxBfx, &nLen ) ) {
//				///////////////////////////////////////////////////
//				// The Header code will be included in return data
//				// RxBfx: 7E 0C 01 ...
//				// Do something
//				//		...
//			} else {
//				dwError = GetSCommStatus( pComm );
//				if( dwError & COMM_RXTIMEOUT ) {
//					printf( "Timeout !\n" );
//				}
//				if( dwError & COMM_RXERRSUM ) {
//					printf( "Check Sum Error !\n" );
//				}
//				if( dwError & COMM_TXERRLENGTH ) {
//					printf( "Cann't send to serial port !\n" );
//				}
//			}
//			CloseSComm( pComm );
//		} else {
//			printf( "Cann't connect to serial port " );
//		}
//		DeleteSPort( pComm );
//		return;
//
// }
//
Responder Con Cita