1 /*
2     OWFS -- One-Wire filesystem
3     OWHTTPD -- One-Wire Web Server
4     Written 2003 Paul H Alfille
5     email: paul.alfille@gmail.com
6     Released under the GPL
7     See the header file: ow.h for full attribution
8     1wire/iButton system from Dallas Semiconductor
9 */
10 
11 /* ow_server talks to the server, sending and recieving messages */
12 /* this is an alternative to direct bus communication */
13 
14 #include "ownetapi.h"
15 #include "ow_server.h"
16 
OWNET_present(OWNET_HANDLE h,const char * onewire_path)17 int OWNET_present(OWNET_HANDLE h, const char *onewire_path)
18 {
19 	unsigned char buffer[MAX_READ_BUFFER_SIZE];
20 	int return_value;
21 
22 	struct request_packet s_request_packet;
23 	struct request_packet *rp = &s_request_packet;
24 	memset(rp, 0, sizeof(struct request_packet));
25 
26 	CONNIN_RLOCK;
27 	rp->owserver = find_connection_in(h);
28 	if (rp->owserver == NULL) {
29 		CONNIN_RUNLOCK;
30 		return -EBADF;
31 	}
32 
33 	rp->path = (onewire_path == NULL) ? "/" : onewire_path;
34 	rp->read_value = buffer;
35 	rp->data_length = MAX_READ_BUFFER_SIZE;
36 	rp->data_offset = 0;
37 
38 	return_value = ServerPresence(rp);
39 	/* 0 is ok, <0 not found */
40 
41 	CONNIN_RUNLOCK;
42 	return return_value;
43 }
44 
45