Menu

#21 DS1991 Writing Problems

v1.0_(example)
open
nobody
None
1
2015-01-23
2015-01-16
Anonymous
No

We are using Owfs in Linux to access a DS1991 and DS1995 through the USB DS9490R reader.
Every thing is ok for DS1995.
For DS1991 we are not able to make it work. Maybe we are doing something wrong.
We know the password of the 3 pages of the iButton because we can set it with another tool in Windows.

With OWFS in Linux we try this steps, by code or by hand or with the owfshttp:
Open pages/password.0
Write 8 bytes to pages/password.0
Close pages/password.0
Open pages/page.0
Read all 64 byte
Close the file
Dump the content.

The content of the page file is always 0x00!
Is the same with page 0 1 and 2.

Can you help us please?
Do you need some more informations?
Thank you very much.

Discussion

  • Anonymous

    Anonymous - 2015-01-16

    Are you sure the password bytes aren't mangled? Both the DS1991 and the owlib core expect them to be plain bytes, and some of the language bindings or your web browser may apply an encoding to them or add CR+LF. Please create a 8-byte file with the password, check the content with a hex editor, then push the content into the owfs pages/password.0 node with a simple tool like "cat".

     
    • Anonymous

      Anonymous - 2015-01-19

      I'm going to try thank you. I'll let you know the result.

       
  • Anonymous

    Anonymous - 2015-01-19

    Hello and thank you. Yes I'm sure. I made a test now directly in c code.
    I'm also sure that the pwd is right, I checked it with another tool in windows.

    Here is the sample:

    unsigned char pwd[8];
    
    pwd[0] = 0x31;
    pwd[1] = 0x32;
    pwd[2] = 0x33;
    pwd[3] = 0x34;
    pwd[4] = 0x35;
    pwd[5] = 0x36;
    pwd[6] = 0x37;
    pwd[7] = 0x38;
    
    unsigned char data[64];
    
        for (i=0; i<64; i++) data[i] = 0x00;
    
        oIBtnHALOwfs.readSubkey(1,data,1,pwd);
    

    THE READ SUBKEY CODE:

        // PREPARE FILE NAMES...
        // .......
        // FILES ARE CORRECT I'M SURE
    DebugMsg(AT, "1991 FULL PATH %s", acFullFolder);
    DebugMsg(AT, "1991 PWD FILE %s", acPwFile);
    DebugMsg(AT, "1991 PAGE FILE %s", acPageFile);
    DebugMsg(AT, "1991 IDENT FILE %s", acIdentFile);
    
    FILE *pfPwFile=fopen(acPwFile,"w+");
    
    if (pfPwFile==NULL)
    {
        DebugMsg(AT, "1991 cannot open PWD FILE");
        return 0;
    }
    
    for (int i=0; i<8; i++)
    {
        DebugMsg(AT,"PWD[%d]=%x", i, passwd[i]);
    }
    
    fwrite(pwd,sizeof(uchar), 8, pfPwFile);
    fflush(pfPwFile);
    fclose(pfPwFile);
    
    FILE *pfIdentFile = fopen(acIdentFile,"r");
    
    if (pfIdentFile==NULL)
    {
        DebugMsg(AT, "1991 cannot open IDENT FILE");
        return 0;
    }
    
    fread(data,sizeof(uchar),8, pfIdentFile);
    fclose(pfIdentFile);
    
        //IDENT FILE READS OK
    int iBytes=0;
    
        // HERE I PUT THE PWD ONLY FOR OUTPUT
    for (iBytes=0; iBytes<8; iBytes++)
    {
        data[iBytes+8] = pwd[iBytes];
    }
    
    FILE *pfPageFile = fopen(acPageFile,"r");
    
    if (pfPageFile==NULL)
    {
        DebugMsg(AT, "1991 cannot open PAGE FILE");
        return 0;
    }
    
        // HERE I READ ONLY 48 BYTE OF PAGE FILE
    fread(data+16,sizeof(uchar),48, pfPageFile);
    fclose(pfPageFile);
    
    for (iBytes=0; iBytes<64; iBytes++)
    {
        DebugMsg(AT, "data[%d] = 0x%x", iBytes, data[iBytes]);
    }
    

    Thank you very much.

     
  • Jan Kandziora

    Jan Kandziora - 2015-01-19

    Have you tried with a password file and cat? Important to eliminate any bug within your code. Using C-stlye buffered I/O with anything else but real files can be tricky.

     
  • Anonymous

    Anonymous - 2015-01-19

    Yes we made the requested test with Linux cat tool.
    1) Create a pwd.hex file with (in hex) 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38
    2) Check the file with hexedit in windows
    3) Chech the file with hexdump in Linux
    4) cat ./pwd.hex > /disk/1wire/02.12B0CE000000/pages/password.0
    5) hexdump -Cv /disk/1wire/02.12B0CE000000/pages/page.0

    Result is always all zeroes.

    Also strange that is always 0x00 the result: the manual talks about random data but we receive always 0x00.

    Maybe is still our error but we made test with:
    Web tool: no way
    Linux tools: no way
    Our C code: no way

    If there is an error of us I suppose it should be on the procedure...

    Can you help us?
    Are you able to read DS1991?

    Thank you again.

     
    • Jan Kandziora

      Jan Kandziora - 2015-01-19

      Please read /disk/1wire/uncached/02.12B0CE000000/pages/page.0 instead. Chances are the cache isn't invalidated when the password is changed.

       

      Last edit: Jan Kandziora 2015-01-19
  • Anonymous

    Anonymous - 2015-01-20

    I made the test in uncached with the web server with no success.
    We made also a test starting the service setting "no cache" with same result.
    I'm going to try with the linux tools as soon as possible.
    Thank you.

     
  • Anonymous

    Anonymous - 2015-01-23

    We made the requested test with no result.
    In attach the print screen:

    test1: write pw in uncached and read page in uncached: no result
    test2: write pw in uncached and read page "normal": all 0x00

    Can you please exlpicit tell me if DS1991 is working for you?
    Have you seen it working?

    Thank you very much
    Best regards
    Paolo