Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 11-04-2010
ASAPLTDA ASAPLTDA is offline
Miembro
 
Registrado: jun 2003
Ubicación: COLOMBIA-CALI
Posts: 639
Poder: 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
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Guardar/leer datos en TXT chipset Varios 2 15-11-2008 18:52:58
Leer y escribir tarjetas con banda magnetica juanelo Varios 1 13-03-2008 22:29:50
Leer datos de los puertos de la PC trex2000 Varios 2 06-08-2007 17:59:08
leer datos del scanner raudelink Varios 2 16-10-2004 02:13:30


La franja horaria es GMT +2. Ahora son las 15:52:34.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi