locked
What's the difference the next definitions RRS feed

  • Question

  • It should be a eazy problem,but it confused me such a long time and don't know how to resolve it. Could you kindly give me a favour? I would appreciate it so much.

    In sora ,we can see such definition as

    I think it is different from our definition such as "#define CHANNEL_FACTOR_SIZE         (64 * 2) ","#defie DbgPrint   printf".

    Also,we can see the following words:

    hr == __BB11A_RX_MODE_SWITCH

    hr == BB11A_OK_FRAME

    hr == BB11A_E_CRC32

    hr = BB11A_E_FORCE_STOP

    SUCCEEDED(hr)........................................

    Evidently ,they are used as judges .But I just don't know how to judge hr to be right or fault?

    Waiting for your answer .Thanks a lot!

    Sunday, March 10, 2013 12:44 PM

Answers

  • I see your question now. If you check the definition:
    #define SUCCEEDED(hr)   (((HRESULT)(hr)) >= 0)
    #define FAILED(hr)      (((HRESULT)(hr)) < 0)

    It converts hr to signed long type, and the positive indicates 'SUCCEEDED'. So from the code snippet in your first question, BB11A_E_* are 'FAILED', others are 'SUCCEEDED'.
    • Proposed as answer by Qi LuoEditor Monday, March 11, 2013 5:46 AM
    • Marked as answer by buptboy Monday, March 11, 2013 12:01 PM
    Monday, March 11, 2013 5:46 AM
    Answerer

All replies

  • Hi buptboy,
    All the HRESULT macro constants can be used with SUCCEEDED(hr) or FAILED(hr), showing whether it is expected result or something bad happens.

    What do you mean by right or fault exactly? What do you really want to do? If I did not answer your question, please give some explanation, background or examples in your use case, it will help us better understand your question. Thanks!
    -Qi

    • Edited by Qi LuoEditor Sunday, March 10, 2013 4:08 PM
    • Marked as answer by Qi LuoEditor Sunday, March 10, 2013 4:09 PM
    • Unmarked as answer by Qi LuoEditor Sunday, March 10, 2013 4:09 PM
    • Proposed as answer by Qi LuoEditor Sunday, March 10, 2013 4:09 PM
    Sunday, March 10, 2013 4:06 PM
    Answerer
  • Hi buptboy,
    All the HRESULT macro constants can be used with SUCCEEDED(hr) or FAILED(hr), showing whether it is expected result or something bad happens.

    What do you mean by right or fault exactly? What do you really want to do? If I did not answer your question, please give some explanation, background or examples in your use case, it will help us better understand your question. Thanks!
    -Qi

    Thank you for your quick answer.

    In the function of BB11ARxFrameDemod of the file  arx_fd.c ,we can see the sentence "do ......while(SUCCEEDED(hr))",and in the process of the loop the value of hr could be BB11A_OK_FRAME, BB11A_E_CRC32, BB11A_E_FORCE_STOP ,BB11A_E_SYNC_FAIL and so on.So I'd like to know when the (SUCCEEDED(hr) equals to 1,thus the loop could go on.

    Monday, March 11, 2013 12:44 AM
  • I see your question now. If you check the definition:
    #define SUCCEEDED(hr)   (((HRESULT)(hr)) >= 0)
    #define FAILED(hr)      (((HRESULT)(hr)) < 0)

    It converts hr to signed long type, and the positive indicates 'SUCCEEDED'. So from the code snippet in your first question, BB11A_E_* are 'FAILED', others are 'SUCCEEDED'.
    • Proposed as answer by Qi LuoEditor Monday, March 11, 2013 5:46 AM
    • Marked as answer by buptboy Monday, March 11, 2013 12:01 PM
    Monday, March 11, 2013 5:46 AM
    Answerer
  • Thank you for your help!
    Monday, March 11, 2013 12:01 PM