Salut à tous,
J'ai un projet à mener pour mes études il sagit de déveloper une aplication en C++ capable de se connecter à un lecteur RFID de lire des tags RFID et d'écrire dessus.
Je me suis fait acheter (lol la chance) le kit skyetekmodule developer M2. Avec ce kit est fournit un exemple mais j'avoue que je séche lamentablement à le comprendre! C'est pourquoi je demande votre aide. Il s'agit d'un exemple qui lit les tag en boucle si j'ai bien compris. Je met le code à la suite si quelqu'un comprend et qu'il veux bien m'expliquer ce qu'il en est.
merci beaucoup par avance!
Voila le code:
#include "stdafx.h"
#include "SkyeTekAPI.h"
#include "SkyeTekProtocol.h"
// stop flag
bool isStop = false;
// FUNCTION: SelectLoopCallback(LPSKYETEK_TAG, void *)
// PURPOSE: Callback called by SkyeTek_SelectTags whenever
// a tag is selected. This returns 1 to continue
// and zero to stop.
unsigned char SelectLoopCallback(LPSKYETEK_TAG lpTag, void *user)
{
if( !isStop )
{
if( lpTag != NULL )
{
printf("Tag: %s; Type: %s\n", lpTag->friendly,
SkyeTek_GetTagTypeNameFromType(lpTag->type));
SkyeTek_FreeTag(lpTag);
}
}
return( !isStop );
}
//
// FUNCTION: ThreadProc(LPVOID)
// PURPOSE: Main thread function. It sits in a loop until the
// reader is discovered and then it calls the
// SkyeTek_SelectTags function, which does not return
// until the loop stops. To stop the loop, the
// SelectLoopCallback needs to return zero.
DWORD WINAPI ThreadProc(LPVOID lpParameter)
{
LPSKYETEK_DEVICE *devices = NULL;
LPSKYETEK_READER *readers = NULL;
SKYETEK_STATUS st;
unsigned int numDevices;
unsigned int numReaders;
printf("Discovering reader...\n");
while( !isStop )
{
numDevices = SkyeTek_DiscoverDevices(&devices);
if( numDevices == 0 )
{
Sleep(100);
continue;
}
if( isStop )
return 1;
numReaders = SkyeTek_DiscoverReaders(devices, numDevices, &readers);
if( numReaders == 0 )
{
SkyeTek_FreeDevices(devices,numDevices);
OCTOBER 6, 2006 SELECT LOOP SAMPLE
SKYETEK, INC. WWW.SKYETEK.COM PAGE 7 OF 7
Sleep(100);
continue;
}
break;
}
// set reader info
printf("Found reader: %s\n", readers[0]->friendly);
// the SkyeTek_SelectTags function does not return until the loop is done
printf("Entering select loop...\n");
st = SkyeTek_SelectTags(readers[0],AUTO_DETECT,SelectLoopCallback,0,1,NULL);
if( st != SKYETEK_SUCCESS )
printf("Select loop failed\n");
printf("Select loop done\n");
// clean up readers
SkyeTek_FreeReaders(readers, numReaders);
SkyeTek_FreeDevices(devices, numDevices);
return 1;
}
int main(int argc, char* argv[])
{
DWORD id1;
HANDLE h;
char line[128];
printf("SkyeTek API Loop Example\n");
printf("Hit return to exit\n");
if( (h=CreateThread(NULL,0,ThreadProc,NULL,0,&id1)) == NULL )
return FALSE;
gets(line);
CloseHandle(h);
printf("Done\n");
isStop = true;
return 0;
}