Herunterladen Inhalt Inhalt Diese Seite drucken

Rumpf Eines Kommunikationsprogramms - Cgc Usb-Rfid Bedienungsanleitung

Rfid-leseeinheit
Inhaltsverzeichnis
Seite: 25/26
USB-RFID: Softwareschnittstelle

Rumpf eines Kommunikationsprogramms

#include <stdio.h>
#include <windows.h>
#include "USB-RFID.h"
int main()
{
// check the DLL version:
if ((USB_RFID_Version() & 0xFF00) != 0x0100)
{
printf ("Wrong DLL Version: expected 1.x, found %d.%02d\n",
USB_RFID_Version() / 0x100, USB_RFID_Version() & 0xFF);
return -1;
}
// define the port number:
const unsigned short PortNum = 0;
// open the port, attach it to COM1:
if (USB_RFID_Open (PortNum, 1))
{
// handle a possible error:
printf ("%s\n", USB_RFID_ErrorMessage (PortNum));
return 1;
}
// insert setup here
// main program loop:
while (true)
{
// check for automatic data:
WORD CommandID;
const int Result =
USB_RFID_CheckAutoInput (PortNum, CommandID);
if (Result != 0) // handle possible errors
{
if (Result < 0)
printf ("%s\n", USB_RFID_ErrorMessage (PortNum));
else
printf ("Unexpected command received\n");
continue; // do not proceed on errors
}
// check if RFID data is ready
if (CommandID & AUTO_RFID)
{
BYTE Data [8];
CGC Instruments
CGC Instruments
CGC Instruments
CGC Instruments
Hübschmannstr. 18 | D–09112 Chemnitz
Tel.: +49 (371) 355 098–55
Fax: +49 (371) 355 098–60
Internet: www.cgc-instruments.com
E–Mail: info@cgc-instruments.com
Inhaltsverzeichnis
loading

Inhaltsverzeichnis