Discussion:
[Owfs-developers] owcapiexample parameters to pass
bdrmachine
2017-01-13 17:23:21 UTC
Permalink
Wouldsomeone Please help me with the input string needed forthe owcapiexample program. I am trying to read my 18b20 sensors that areattached to my Raspberry Pi 3 using the I2C interface. I can readthem with my browser @ “localhost:2121”. The problem is I cannot get the example code that was loaded at(/usr/share/doc/libowfs-dev/examples/owcapi/C) to work. I need helpfiguring out what parameters to pass to ./owcapiexample ??? ????
Ihave spent countless hours at this. Please help.
ThanksBrian
Jan Kandziora
2017-01-13 19:22:00 UTC
Permalink
Post by bdrmachine
Wouldsomeone Please help me with the input string needed forthe
owcapiexample program. I am trying to read my 18b20 sensors that
areattached to my Raspberry Pi 3 using the I2C interface. I can
get the example code that was loaded
at(/usr/share/doc/libowfs-dev/examples/owcapi/C) to work. I need
helpfiguring out what parameters to pass to ./owcapiexample ??? ????
Ihave spent countless hours at this. Please help. ThanksBrian
Please understand this very simple test program first:

=== Makefile ========================================================================
.PHONY: all clean
CFLAGS=-I /opt/owfs/include/
LDFLAGS=-L /opt/owfs/lib64/ -lowcapi

all: owcapitest

clean:
-rm *.o owcapitest

owcapitest: owcapitest.o
$(CC) $(LDFLAGS) -o $@ $^

=== owcapitest.c ====================================================================
#include <stdio.h>
#include <stdlib.h>
#include <owcapi.h>

int main(int argc, char* argv[]) {
size_t rs;
char *buf;
ssize_t rss;

if ((rss = OW_init("-s localhost:4304")) < 0) {
perror("OW_init failed");
exit(EXIT_FAILURE);
}

if ((rs = OW_get("/uncached/10.AE9C54020800/temperature", &buf, &rs)) < 0) {
perror("OW_get failed");
exit(EXIT_FAILURE);
}

printf("%s\n",buf);
}
=====================================================================================


Kind regards

Jan
Jan Kandziora
2017-01-14 01:03:10 UTC
Permalink
Okay I give up. I thought there was a simple way to add parameters
to that code to learn how to use C.
Um, it was giving exactly *two* OWFS specific calls, which are pretty
understandable. What's the problem?
I have code that work in python
but that is not what I like to use. This learning curve is taking
more time than I have. For some reason your code won't compile.
If you'd show me the log, I could tell you why.

If you don't like python and have problems setting up you C compiling
environment, why don't use one of the numerous *other* language
bindings? Ow the owshell tools?

Kind regards

Jan

Loading...