/
ow_fs_id.c
67 lines (56 loc) · 1.88 KB
/
ow_fs_id.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
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
OWFS -- One-Wire filesystem
OWHTTPD -- One-Wire Web Server
Written 2003 Paul H Alfille
email: paul.alfille@gmail.com
Released under the GPL
See the header file: ow.h for full attribution
1wire/iButton system from Dallas Semiconductor
*/
/* General Device File format:
This device file corresponds to a specific 1wire/iButton chip type
( or a closely related family of chips )
The connection to the larger program is through the "device" data structure,
which must be declared in the acompanying header file.
The device structure holds the
family code,
name,
device type (chip, interface or pseudo)
number of properties,
list of property structures, called "filetype".
Each filetype structure holds the
name,
estimated length (in bytes),
aggregate structure pointer,
data format,
read function,
write funtion,
generic data pointer
The aggregate structure, is present for properties that several members
(e.g. pages of memory or entries in a temperature log. It holds:
number of elements
whether the members are lettered or numbered
whether the elements are stored together and split, or separately and joined
*/
#include <config.h>
#include "owfs_config.h"
#include "ow_standard.h"
/* ------- Prototypes ------------ */
/* ------- Functions ------------ */
ZERO_OR_ERROR FS_ID(struct one_wire_query *owq)
{
ASCII id[12];
struct parsedname *pn = PN(owq);
bytes2string(id, &(pn->sn[1]), 6);
return OWQ_format_output_offset_and_size(id, 12, owq);
}
ZERO_OR_ERROR FS_r_ID(struct one_wire_query *owq)
{
int sn_index, id_index;
ASCII id[12];
struct parsedname *pn = PN(owq);
for (sn_index = 6, id_index = 0; sn_index > 0; --sn_index, id_index += 2) {
num2string(&id[id_index], pn->sn[sn_index]);
}
return OWQ_format_output_offset_and_size(id, 12, owq);
}