-
Notifications
You must be signed in to change notification settings - Fork 1
/
getIDm.cpp
72 lines (57 loc) · 1.49 KB
/
getIDm.cpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <stdio.h>
#include <string>
#include <string.h>
#include "RCS620S.h"
#include "unistd.h"
#include <stdlib.h>
int main()
{
RCS620S rcs620s;
//初期化
int ret = rcs620s.initDevice();
if (!ret)
{
printf("can't open pasori\n");
return 0;
}
//読み取り部分
char *s;
char *p;
s = (char*)calloc(256,sizeof(char));
p = (char*)calloc(256,sizeof(char));
if (s==NULL || p ==NULL) {
return 0;
}
while (true){
usleep(10000);
ret = rcs620s.polling();
if (ret)
{
uint8_t *pmm = rcs620s.pmm;
//idを取得
uint8_t *idm = rcs620s.idm;
//変数sに出力
sprintf(p, "PMm: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
pmm[0], pmm[1], pmm[2], pmm[3],
pmm[4], pmm[5], pmm[6], pmm[7]);
sprintf(s, "IDm: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
idm[0], idm[1], idm[2], idm[3],
idm[4], idm[5], idm[6], idm[7]);
}
if (strlen(s) != 0) {
//出力
printf(p);
printf(s);
free(s);
free(p);
s = (char*)calloc(256,sizeof(char));
p = (char*)calloc(256,sizeof(char));
sleep(3);
}
}
//読み取りをオフにする
rcs620s.rfOff();
free(s);
free(p);
return 0;
}