G'Day,

        I am currently trying to weed out why I still cannot read from my
DS2431 device, and in my testing I stumbled across a minor bug in
BUS_send_data().

        When I `cat 2D.serial/memory', it does not work, so I checked `cat
statistics/errors/BUS_*' and noticed that BUS_send_data_errors was 1,
however, when I checked `cat statistics/errors/OMAP_*', everything was
0!  The only logical explanation is that the error being generated by
BUS_send_data() was not due to OMAP_sendback_data() returning a non-zero
value, rather that memcmp() was coming back non-zero.  When I checked
the code for this section, I noticed a small mistake.

        The line is as follows:
                (ret=BUS_sendback_data( data, resp, len,pn )) ||
                ((ret=memcmp(data, resp, (size_t) len))?-EPROTO:0) ;
Which, if I assume BUS_sendback_data() is returning `0' and memcmp is
returning `unknown', evaluates to:
                0 || (unknown ? -EPROTO : 0)
In other words, that *line* evaluates to either 0 or -EPROTO, but the
value or ret will be the value of unknown.  You can fix this by moving
the bracket like so:
                (ret = BUS_sendback_data( data, resp, len,pn )) ||
                ((ret = memcmp(data, resp, (size_t) len) ? -EPROTO : 0));
Now, if memcmp returns a non-zero value, ret will equal -EPROTO.

        I have also noticed that owfs seems to fall asleep on me at times:
sometimes when I give a command (ls, cat, etc), it will just hang on
that.  If I background the ls/cat and `killall owfs' it will finally act
on the command (with a predictable `No such file or directory' error).
I have tried disabling multithreading, but that did not seem to be the
problem.  Has anyone else experienced anything like this before?

        As to the specifics of the function called when catting
2D.serial/memory/, perhaps it is just my misunderstanding, but it seems
to me like calling BUS_send_data() is not the best thing to do.
BUS_send_data(x,3,y) sends three bits, then reads three bits and
compares them.  If I am correctly understanding the way this device
works, are the bits you read back there not the contents of the memory?
I could very well be wrong here, as I am finding the documentation for
the device a little hard to follow at times, but that is just how it
seems to me: I need to send 0xF0, some sort of reference address, then
start reading back data stored in that address.

        -- Matthew



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to