#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2008
    Posts
    54
    Rep Power
    7

    Bits Manipulation


    Code:
    int
    self_test_result(uint8_t *result)
    {
        uint8_t ret_result = 0;
        int rc = 0;
    
        rc = read_byte_result(handle,TEST_REG,&ret_result);
        *result = ret_result;
        return rc;
    }
    
    uint8_t result;
    self_test_result(&result);
    printf("Result = %02x\n", result);
    Output:
    Result = 80

    I thought it is supposed to be 0x00? How do I walk through the bit and verify the result is PASSED?
  2. #2
  3. Commie Mutant Traitor
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2004
    Location
    Alpharetta, GA
    Posts
    1,806
    Rep Power
    1570
    Insufficient data. What sort of device are you working with? What is read_byte_result(), and what is the test register it is reading from supposed to be? What operating system are you running under, and what sort of OS (if any) is the device running?
    Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
    #define KINSEY (rand() % 7) λ Scheme is the Red Pill
    Scheme in Short Understanding the C/C++ Preprocessor
    Taming Python A Highly Opinionated Review of Programming Languages for the Novice, v1.1

    FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov
  4. #3
  5. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,392
    Rep Power
    1871
    How about not ignoring the return result of the function?
    Code:
    int success = self_test_result(&result);
    printf("Success = %d, Result = %02x\n", success, result);
    Maybe the function failed, and you're trying to interpret garbage.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper

IMN logo majestic logo threadwatch logo seochat tools logo