/
lookup.c
53 lines (42 loc) · 887 Bytes
/
lookup.c
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
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include <stdlib.h>
#include <mlan.h>
int main(int argc, char **argv)
{
MLan *mlan=NULL;
uchar serial[MLAN_SERIAL_SIZE];
char *serial_in=NULL, *s=NULL, *dev=NULL;
int i;
if(argc<2) {
fprintf(stderr, "Need a serial number.\n");
exit(1);
}
serial_in=argv[1];
if(getenv("MLAN_DEVICE")) {
dev=getenv("MLAN_DEVICE");
} else {
dev="/dev/tty00";
}
mlan=mlan_init(dev, PARMSET_9600);
assert(mlan);
mlan->debug=0;
mlan->parseSerial(mlan, serial_in, serial);
if(mlan->ds2480detect(mlan)!=TRUE) {
printf("Found no DS2480\n");
}
for(i=0; i<MLAN_SERIAL_SIZE; i++) {
printf("%02x ", serial[i]);
}
printf("\n");
s=get_sample(mlan, serial);
if( s != NULL ) {
printf("\tTemperature reading: %s\n", s);
}
mlan->destroy(mlan);
return(0);
}
/*
* arch-tag: 204206D1-13E5-11D8-91CF-000393CFE6B8
*/