May I suggest looking at owcapi ?
It does much the same, but has the initiation code as well, which I suspect is
the current problem.
The syntax is as follows: (From module/owcapi/src/include/owcapi.h)
/* initialization, required before any other calls. Should be paired with a
finish
OW_init -- simplest, just a device name
/dev/ttyS0 for serial
u or u# for USB
#### for TCP/IP port (owserver)
OW_init_string -- looks just like the command line to owfs or owhttpd
OW_init_args -- char** array usually from the main() call
return value = 0 good
< 0 error
No need to call OW_finish if an error
*/
int OW_init( const char * device ) ;
int OW_init_string( const char * params) ;
int OW_init_args( int argc, char ** args ) ;
/* OW_get -- data read or directory read
path is OWFS style name,
"" or "/" for root directory
"01.23456708ABDE" for device directory
"10.468ACE13579B/temperature for a specific device property
buffer is a char buffer that is allocated by OW_get.
buffer MUST BE "free"ed after use.
buffer_length, if not NULL, will be assigned the length of the returned data
If path is NULL, it is assumed to be "/" the root directory
If path is not a valid C string, the results are unpredictable.
If buffer is NULL, an error is returned
If buffer_length is NULL it is ignored
return value >=0 ok, length of information returned (in bytes)
<0 error
*/
int OW_get( const char * path, char ** buffer, size_t * buffer_length ) ;
/* OW_put -- data write
path is OWFS style name,
"05.468ACE13579B/PIO.A for a specific device property
buffer holds the value
ascii, possibly comma delimitted
Note NULL path or buffer will return an error.
Note: path must be null-terminated
Note: buffer_length will be used for length, there is no requirement that
buffer be null-terminated
return value = 0 ok
< 0 error
*/
int OW_put( const char * path, const char * buffer, size_t buffer_length ) ;
/* cleanup
Clears internal buffer, frees file descriptors
Normal process cleanup will work if program ends before OW_finish is called
But not calling OW_init more than once without an intervening OW_finish will
cause a memory leak
No error return
*/
void OW_finish( void ) ;
So in your case:
OW_init("/dev/ttyS0");
OW_get("/28.6DC351000000/temperature",buffer,12); // Note lower case
temperature
OW_finish() ; // Optional
On Sunday 26 February 2006 12:04 pm, Krzysztof Drewicz wrote:
> Paul Alfille napisaĆ(a):
> >On Friday 24 February 2006 06:27 pm, Krzysztof Drewicz wrote:
> >
> >
> >
> >Good. If you are going to use that interface, I guess we should start
> > using the "version" field to keep everything interoperable.
> >Version is a 4-byte field.
>
> hm, trying to link w/ owlib:
> #include "owfs_config.h"
> #include "ow.h"
>
> int main()
> {
> char tmp[1280];
> char buf[26];
> int len,i;
> int res=0;
> int marker=1;
> double temp;
>
> strcpy(tmp,"/28.6DC351000000/Temperature");
> for(i=0; i<5; i++) {
> if ((len=FS_read(tmp, buf, (size_t)12, 0))>0)
> {
>
>
> (gdb) run
> Starting program: /root/owfs/module/owfscat/src/c/ow_fscat
>
> Breakpoint 1, main () at ow_fscat.c:13
> 13 strcpy(tmp,"/28.6DC351000000/Temperature");
> (gdb) cont
> Continuing.
>
> Program received signal SIGSEGV, Segmentation fault.
> 0xb7ed4977 in BUS_normalverify (pn=0xbfa04940) at ow_verify.c:51
> 51 (ret=BUS_select(&pncopy)) || (ret=BUS_send_data( &fo,1,pn ))
>
> || (ret=BUS_verify(pn));
>
> (gdb) print pn->path
> $6 = 0x80570c8 "/28.6DC351000000/Temperature"
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers