File: test_wiegand.c

package info (click to toggle)
pigpio 1.78-1.1
  • links: PTS
  • area: main
  • in suites: sid, trixie
  • size: 7,088 kB
  • sloc: ansic: 17,891; python: 4,232; sh: 741; cpp: 281; makefile: 135
file content (42 lines) | stat: -rw-r--r-- 514 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>

#include <pigpio.h>

#include "wiegand.h"

/*

REQUIRES

Wiegand contacts 0 and 1 connected to separate gpios.

TO BUILD

gcc -o wiegand_c test_wiegand.c wiegand.c -lpigpio -lrt

TO RUN

sudo ./wiegand_c

*/

void callback(int bits, uint32_t value)
{
   printf("bits=%d value=%u\n", bits, value);
}

int main(int argc, char *argv[])
{
   Pi_Wieg_t * w;

   if (gpioInitialise() < 0) return 1;

   w = Pi_Wieg(14, 15, callback, 5);

   sleep(300);

   Pi_Wieg_cancel(w);

   gpioTerminate();
}