Hi Paul,

On 07/07/2011 10:55 PM, Eloy Paris wrote:

[...]

> After your explanations I am accomplishing what I need like this (for
> example):
>
> shell$ owread --hex --size=16 --start=0 /99.010203040506/generic/memory

This had me scratching my head -- I was reading from microcontroller 
memory, using owshell's owread, the following 7 bytes:

0x63, 0x00, 0x4C, 0x08, 0x6C, 0x08, and 0xAC

However, the output from owread --hex was:

63004C086C08FFFFFFAC

There were obviously some mysterious bytes in there, but after realizing 
that the last byte has its most significant bit set, and realizing that 
the extra bytes are 0xff, it was obvious that there was an unintended 
integer conversion from a small size to a larger size (signed char to 
integer).

Below you'll find the patch that fixed the problem for me. We could 
change the type of the argument of the function (from char to unsigned 
char) instead of using a cast, but that probably would require changes 
to other places inside ow_server.c (function prototype, add casts to 
arguments when the function is called, or change the type of arguments 
being passed to the function) so I thought casting in one place would be 
easier.

Cheers,

Eloy Paris.-

---------------------------------------------------------------

--- module/owshell/src/c/ow_server.c.orig       2011-07-07 23:23:53.568305295 
-0400
+++ module/owshell/src/c/ow_server.c    2011-07-07 23:30:03.824315008 -0400
@@ -367,6 +367,6 @@
  {
        int i ;
        for ( i=0 ; i<length ; ++i ) {
-               printf("%.2X",buffer[i]);
+               printf("%.2X", (unsigned char) buffer[i]);
        }
  }


------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to