Function OW_w_mem in OW_set_resolution not entered

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Function OW_w_mem in OW_set_resolution not entered

Ritchie
Hello all,

I am trying to debug the communication to the DS2450.

I found a problem of my communication within the "OW_set_resolution"
function in the ow_DS2450.c Module.

I add "printf" functions to see where the program does something.


Here the modified function:

static GOOD_OR_BAD OW_set_resolution( int resolution, struct parsedname
* pn )
{
        int stored_resolution ;
        /* Resolution */
        if ( BAD( Cache_Get_SlaveSpecific(&stored_resolution,
sizeof(stored_resolution), SlaveSpecificTag(RES), pn))
                || stored_resolution != resolution) {
                        // need to set resolution
                BYTE p[_1W_2450_PAGESIZE];

                RETURN_BAD_IF_BAD( OW_r_mem(p, _1W_2450_PAGESIZE,
_ADDRESS_CONTROL_PAGE, pn) ) ;


                p[_1W_2450_REG_A] &= ~_1W_2450_RC_MASK ;
                p[_1W_2450_REG_A] |= ( resolution & _1W_2450_RC_MASK ) ;
                p[_1W_2450_REG_B] &= ~_1W_2450_RC_MASK ;
                p[_1W_2450_REG_B] |= ( resolution & _1W_2450_RC_MASK ) ;
                p[_1W_2450_REG_C] &= ~_1W_2450_RC_MASK ;
                p[_1W_2450_REG_C] |= ( resolution & _1W_2450_RC_MASK ) ;
                p[_1W_2450_REG_D] &= ~_1W_2450_RC_MASK ;
                p[_1W_2450_REG_D] |= ( resolution & _1W_2450_RC_MASK ) ;

         printf("2450 OW_set_resolution OW_r_mem o.k. \n") ;

                RETURN_BAD_IF_BAD( OW_w_mem(p, _1W_2450_PAGESIZE,
_ADDRESS_CONTROL_PAGE, pn) );

         printf("2450 OW_set_resolution OW_w_mem o.k. \n") ;


                return Cache_Add_SlaveSpecific(&resolution, sizeof(int),
SlaveSpecificTag(RES), pn);
        }
       
        return gbGOOD ;
}


I also add debug code in the OW_w_mem() function to see the problem.
Here the function :


//write bytes[size] is now common for normal and eeprom
static GOOD_OR_BAD OW_w_mem(BYTE * data, size_t size, off_t offset,
struct parsedname * pn)
{
        size_t remain = size ;
        off_t local_offset = 0 ;
        int retry=0; //retry at 32byte block level because it is sometime hard
to have a scuccession of 16 successfull bloc writes

         printf("OW_w_mem entered \n") ;
       
        while ( remain > 0 )
         {
                size_t gulp = remain ;
                if ( gulp > _FC02_MAX_READ_GULP ) {
                        gulp = _FC02_MAX_READ_GULP ;
                }
// RETURN_BAD_IF_BAD( OW_w_mem_small( &data[local_offset], gulp,
offset+local_offset, pn ));
                if ( BAD( OW_w_mem_small( &data[local_offset], gulp,
offset+local_offset, pn )))
             {
             printf("Bad 2450 OW_w_mem Remain : %i Gulp : %i\n",remain,
gulp) ;

                        if (retry++>3) return gbBAD;
                        UT_delay(2) ; //give 1.5 msec to finish prev write before retrying
(specificly for eeprom write)
             }
         else
             {
             printf("Good 2450 OW_w_mem Remain : %i Gulp : %i\n",remain,
gulp) ;
                        remain -= gulp ;
                        local_offset += gulp ;
                        retry=0;
             }
        }
        return gbGOOD ;
}



But I do not get the print out "OW_w_mem entered" and I do not know why.

The only print out I get is "2450 OW_set_resolution OW_r_mem o.k."

Where is my failure ?

Best regards
Ritchie


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Owfs-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/owfs-developers
Reply | Threaded
Open this post in threaded view
|

Re: Function OW_w_mem in OW_set_resolution not entered

Jan Kandziora
Am 26.01.2017 um 19:14 schrieb Ritchie:

>
> I also add debug code in the OW_w_mem() function to see the problem.
> Here the function :
>
> //write bytes[size] is now common for normal and eeprom
> static GOOD_OR_BAD OW_w_mem(BYTE * data, size_t size, off_t offset,
> struct parsedname * pn)
> {
> size_t remain = size ;
> off_t local_offset = 0 ;
> int retry=0; //retry at 32byte block level because it is sometime hard
> to have a scuccession of 16 successfull bloc writes
>
This is from owfs-code/module/owlib/src/ow_bae.c

You are editing the wrong file.

Kind regards

        Jan

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Owfs-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/owfs-developers
Reply | Threaded
Open this post in threaded view
|

DS2450 CRC16 Checksum calculation

Ritchie
Hi all,

I am trying to simulate a DS2450 and don't find the reason for the wrong
checksume calculation of the write command 0x55

A good data translation will show the following result:

2450 OW_w_mem Adr.: 8 data : 0
CRC16seeded 55 8 0 0 6f f1  CRC b001 == 0xB001  o.k.
CRC16seeded 8c 3e 5c  CRC b001 == 0xB001  o.k.

I will get for the simulated DS2450 instead for the same transmission

First block transmission with
<Command> = 0x55
<Address> = 0x0008
<Data>    = 0x00
<CRC>     = 0xf16f

CRC16seeded 55 8 0 0 6f f1  CRC b001 == 0xB001  o.k.
CRC16seeded is making a compare to 0xB001

Up to here fine!

Next Transmission
<Address>  =0x0009  (only used in the CRC, not part of the transmission)
<data>     =0x8c
<CRC>      =0x3aae
CRC16seeded 8c ae 3a  CRC 9aed != 0xB001 not o.k.


Always the next single transmission of the Write command failed, because
of wrong checksume.

In the datasheet is says, that the checksum is init with the address
value, which is 9 for the first single byte transmission.

Is this correct, that the checksum is started with the value of "address" ?


Thanks for any help.

Best regards
Ritchie





------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Owfs-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/owfs-developers
Reply | Threaded
Open this post in threaded view
|

Re: DS2450 CRC16 Checksum calculation

Jan Kandziora
Am 04.02.2017 um 20:42 schrieb Ritchie:
>
> Is this correct, that the checksum is started with the value of "address" ?
>
Please see module/owlib/src/c/ow_2450.c:392  -- OW_w_mem()

423: if ( CRC16seeded(buf, 3, offset + i) || (echo[0] != p[i]) ) {

So, it's indeed seeded with 8+1 == 9.


Kind regards

        Jan



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Owfs-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/owfs-developers
Reply | Threaded
Open this post in threaded view
|

Re: DS2450 CRC16 Checksum calculation

Ritchie
Can you explain, how it work, that the result of the Checksume is
always 0xB001, if it is good.


CRC16seeded
...
        if (sd == 0xB001) {
                ret = 0; /* good */
        } else {
                ret = -1; /* error */
                ++CRC16_errors; /* statistics */
        }
..

Best regards

Ritchie


> Am 04.02.2017 um 20:42 schrieb Ritchie:
>>
>> Is this correct, that the checksum is started with the value of "address" ?
>>
> Please see module/owlib/src/c/ow_2450.c:392  -- OW_w_mem()
>
> 423: if ( CRC16seeded(buf, 3, offset + i) || (echo[0] != p[i]) ) {
>
> So, it's indeed seeded with 8+1 == 9.
>
>
> Kind regards
>
> Jan
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Owfs-developers mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/owfs-developers
>


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Owfs-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/owfs-developers
Reply | Threaded
Open this post in threaded view
|

Re: DS2450 CRC16 Checksum calculation

Jan Kandziora
Am 05.02.2017 um 18:12 schrieb Ritchie:
> Can you explain, how it work, that the result of the Checksume is
> always 0xB001, if it is good.
>
Was genau ist dein Problem damit? Ich kann dir das Testen deines
DS2450-Klons nicht abnehmen, meist sind es Kleinigkeiten, die einem
einen CRC versauen. Der Startwert ist es zumindest schonmal nicht, aber
unter Umständen ist das bei dir big endian oder sonstwie verknautscht.

Mit freundlichem Gruß

        Jan

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Owfs-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/owfs-developers
Reply | Threaded
Open this post in threaded view
|

Re: DS2450 CRC16 Checksum calculation

Ritchie
In reply to this post by Ritchie
Hallo Jan,
vielen Dank für den Hinweis. Ich habe mir den Quellcode jetzt schon über Stunden angesehen und finde den Fehler einfach nicht. Ich lasse das jetzt mal kurz Ruhen und mache dann einen Neuanlauf. Hinweise hast Du schon zu genüge gegeben und das mit der Chechksumme schau ich mir jetzt mal auf Papier an. Das soll ja auch schmal helfe.
Vielen Dank 
Richard


-------- Ursprüngliche Nachricht --------
Von: Jan Kandziora
Datum:05.02.2017 21:12 (GMT+01:00)
An: "OWFS (One-wire file system) discussion and help"
Betreff: Re: [Owfs-developers] DS2450 CRC16 Checksum calculation

Am 05.02.2017 um 18:12 schrieb Ritchie:
> Can you explain, how it work, that the result of the Checksume is
> always 0xB001, if it is good.
>
Was genau ist dein Problem damit? Ich kann dir das Testen deines
DS2450-Klons nicht abnehmen, meist sind es Kleinigkeiten, die einem
einen CRC versauen. Der Startwert ist es zumindest schonmal nicht, aber
unter Umständen ist das bei dir big endian oder sonstwie verknautscht.

Mit freundlichem Gruß

Jan

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Owfs-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/owfs-developers

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Owfs-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/owfs-developers