This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ios app 如何调用NIRscan Nano的DLP Spectrum Library里面的API



想开发一款APP通过蓝牙读取DLP NIRscan Nano模块的光谱数据,并解析显示光谱,但发现获取模块光谱数据之后,需要对数据进行反序列化,需要调用DLP Spectrum Library里面的API,但不知道怎么用?

  • TI提供了一个iOS APP参考设计:

    iOS SDK: https://github.com/kstechnologies/NIRScanNano_iOS

    你在这个基础上修改即可的.里面有API的调用例子.

  • 非常感谢你!

  • 您好:

    想开发一款APP通过蓝牙读取DLP NIRscan Nano模块的光谱数据,并解析显示光谱,但发现获取模块光谱数据之后,需要对数据进行反序列化,需要调用DLP Spectrum Library里面的API,但不知道怎么用?

    这个问题我也在求解,不知能解决了吗?希望得到帮助,谢谢

    qq:423431943,

  • 提供邮件箱,发给你.

  • E-mail:chenz@ynxbst.com  Thanks

    现在能得到以下数据:

    0174706c00750c00005328756323636363636..............等等

    但是TI的官网只有如下解释:(如果能知道多少个字符代表什么或者能有具体代码那就好了)

    DLPSPEC_ERR_CODE dlpspec_scan_interpret const void *  pBuf,
    const size_t  bufSize,
    scanResults *  pResults 

  • 源代码在dlpspec_scan.c

    dlpspeclib

    http://www.ti.com/lit/zip/tidcc49

    DLPSPEC_ERR_CODE dlpspec_scan_interpret(const void *pBuf, const size_t bufSize, scanResults *pResults)
    /**
    * Function to interpret a serialized scan data blob into a results struct
    *
    * @param[in] pBuf Pointer to serialized scan data blob
    * @param[in] bufSize buffer size, in bytes
    * @param[out] pResults Pointer to scanResults struct
    *
    * @return Error code
    *
    */
    {
    scanData *pData;
    DLPSPEC_ERR_CODE ret_val = (DLPSPEC_PASS);

    if ((pBuf == NULL) || (pResults == NULL))
    return (ERR_DLPSPEC_NULL_POINTER);

  • 谢谢!给您发了邮件,请您解答一下

  • 参考:

     

    DLPSPEC_ERR_CODE dlpspec_scan_interpReference(const void *pRefCal, size_t calSize, const void *pMatrix, size_t matrixSize, const scanResults *pScanResults, scanResults *pRefResults)

    /**

     * Function to interpret reference scan data into what the reference scan would have been

     * if it were scanned with the configuration which @p pScanResults was scanned with.

     * This can be used to compute a reference for an arbitrary scan taken when a physical

     * reflective reference is not available to take a new reference measurement.

     *

     * @param[in]   pRefCal               Pointer to serialized reference calibration data

     * @param[in]   calSize         Size of reference calibration data blob

     * @param[in]   pMatrix         Pointer to serialized reference calibration matrix

     * @param[in]   matrixSize      Size of reference calibration matrix data blob

     * @param[in]   pScanResults    Scan results from sample scan data (output of dlpspec_scan_interpret function)

     * @param[out]  pRefResults     Reference scan data result

     *

     * @return      Error code

     *

     */

    {

        DLPSPEC_ERR_CODE ret_val = (DLPSPEC_PASS);

        scanData *pDesRefScanData = NULL;  //To hold deserialized reference scan data

        refCalMatrix *pDesRefCalMatrix = NULL; //To hold deserialized reference cal matrix data

        int i = 0;

     

        if ((pRefCal == NULL) || (pMatrix == NULL) || (pScanResults == NULL) || (pRefResults == NULL))

            return (ERR_DLPSPEC_NULL_POINTER);

       

        /* New error checking since SCAN_DATA_BLOB_SIZE and REF_CAL_MATRIX_BLOB_SIZE

        will vary based on compilation target with sizeof() call */

        if ((calSize == 0) || (matrixSize == 0))

            return (ERR_DLPSPEC_INVALID_INPUT);

       

        /* Previous error checking

        if ((calSize == 0) || (calSize > SCAN_DATA_BLOB_SIZE) ||

            (matrixSize == 0) || (matrixSize > REF_CAL_MATRIX_BLOB_SIZE))

            return (ERR_DLPSPEC_INVALID_INPUT);

        */

     

        // Make a local copy of the input data and deserialize them

        pDesRefScanData = (scanData *)malloc(calSize);

        if (pDesRefScanData == NULL)

            return (ERR_DLPSPEC_INSUFFICIENT_MEM);

        memcpy(pDesRefScanData,pRefCal, calSize);

     

        pDesRefCalMatrix = (refCalMatrix *)malloc(matrixSize);

        if (pDesRefCalMatrix == NULL)

                {

                            ret_val = ERR_DLPSPEC_INSUFFICIENT_MEM;

            goto cleanup_and_exit;

                }

     

        memcpy(pDesRefCalMatrix, pMatrix, matrixSize);

        ret_val = dlpspec_deserialize((void *)pDesRefCalMatrix, matrixSize, REF_CAL_MATRIX_TYPE);

        if (ret_val < 0)

        {

            goto cleanup_and_exit;

        }

     

        // Interpret reference scan data - creates scan results from reference scan data

        memset(pRefResults,0,sizeof(scanResults));

        ret_val = dlpspec_scan_interpret(pDesRefScanData, calSize, pRefResults);

        if (ret_val < 0)

        {

            goto cleanup_and_exit;

        }

     

        /*

         * Check for data integrity before interpolating wavelengths

         */

                for (i =0; i< pScanResults->length; i++)

                {

                            if (pScanResults->wavelength[i] == 0)

            {

                ret_val = (ERR_DLPSPEC_INVALID_INPUT);

                goto cleanup_and_exit;

            }

                }

     

                for (i =0; i< pRefResults->length; i++)

                {

                            if ((pRefResults->wavelength[i] == 0) || (pRefResults->intensity[i] == 0))

            {

                ret_val = (ERR_DLPSPEC_INVALID_INPUT);

                goto cleanup_and_exit;

            }

                }

     

        /*     Using wavelengths from pScanResults, wavelengths from pRefResults, and magnitudes of pRefResult

         *     modify refIntensity using piecewise linear interpolation at refNM wavelengths

         */

        ret_val = dlpspec_interpolate_int_wavelengths(pScanResults->wavelength,

                                                      pScanResults->length,

                                                      pRefResults->wavelength,

                                                      pRefResults->intensity,

                                                      pRefResults->length);

        if (ret_val < 0)

        {

            goto cleanup_and_exit;

        }

     

        // Populate data length - may be required by functions down stream

        pRefResults->length = pScanResults->length;

     

        /*     Transfer function from pRefResults at the scan configuration taken during reference

         *     calibration to the scan configuration used in pScanResults. Inputs will be: refIntensity, scanConfig,

         *     refWavelength, and the baked in model equation / coefficients. Primary drivers will be pattern width

         *     but there may be some differences between linescan and Hadamard also.

         */

        ret_val = dlpspec_scan_recomputeRefIntensities(pScanResults->cfg.width_px, pScanResults->pga, pRefResults, pDesRefCalMatrix);

        if (ret_val < 0)

        {

            goto cleanup_and_exit;

        }

     

        /*     TBD: Add transfer function from pRefResults at the environmental readings in pRefResults to what it would be

         *  in pScanResults with those environmental readings. Inputs will be: refIntensity, refEnvironment, and scanEnvironment

         *  and the baked in model equation / coefficients. Primary drivers will be humidity, detector photodiode, and detector temperature

         *  Timeline: v2.0

         */

     

        cleanup_and_exit:

        if (pDesRefScanData != NULL)

            free(pDesRefScanData);

        if (pDesRefCalMatrix != NULL)

            free(pDesRefCalMatrix);

     

        return (ret_val);

    }

     

     

    *pBuf结构:

     

    typedef struct

    {

        SCAN_DATA_VERSION

        SCAN_DATA_HEAD_NAME

        DATE_TIME_STRUCT

        SCAN_DATA_HEAD_BODY

        SCAN_CONFIG_HEAD

        SCAN_CONFIG_STUB

        int32_t             adc_data[ADC_DATA_LEN];

    } scanData;