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.

CC3235S: 关于out of box例程,该例程中为什么读出的加速度x轴数据、加速度y轴数据、加速度z轴数据都是-1呢?

Part Number: CC3235S

尊敬的TI工程师您好

我是LAUNCHXL-CC3235S,我烧录的使out of box 例程,我在代码中设置了断点,经编译查看,读出的加速度x轴数据、加速度y轴数据、加速度z轴数据为什么都是-1呢?

  • 您好,

    您SDK版本是多少?

  • simplelink_cc32xx_sdk_5_20_00_06。 我是想在linklocalTask的线程中,通过串口打印的形式把加速度数据和温度数据打印出来, 刚才试了试,串口打印出来的加速度数据不管是x轴、y轴、z轴都是-1,温度数据都是0。 我也不确定问题出在哪里?

  • 您好,

    能把你相应修改部分的程序发过来我们测试一下吗(编辑栏插入—代码)?

  • 我只是把out of box例程的link_local_task.c文件有调整。

    调整的地方有:

    void * linkLocalTask(void *pvParameters)
    {
        mq_attr attr;
        int32_t msgqRetVal;
        I2C_Params i2cParams;
    
        uint8_t  abb;
    
        uint8_t  abc;
    
        char tempStr[8];
        char tempStre[8];
    
        int8_t xValRead, yValRead, zValRead;
    
        int16_t value = 0;
    
        int16_t valueee = 0;
    
        float fTempRead;
    
    
        /* initializes I2C */
        I2C_Params_init(&i2cParams);
        i2cParams.bitRate = I2C_400kHz;
        i2cHandle = I2C_open(CONFIG_I2C_0, &i2cParams);
        if(i2cHandle == NULL)
        {
            UART_PRINT("[Link local task] Error Initializing I2C\n\r");
        }
    
        /* Setup mutex operations for sensors reading */
        sensorLockObj = malloc(sizeof(pthread_mutex_t));
        if(sensorLockObj == NULL)
        {
            UART_PRINT("[Link local task] could not Setup mutex operations for sensors reading\n\r");
            while(1)
            {
                ;
            }
        }
        pthread_mutex_init(sensorLockObj, (pthread_mutexattr_t*)NULL);
    
    
    
    
           UART_PRINT("aaaaaaaaaaaaaa\n\r");
    
           abb=accelarometerReading();
    
    
                   if(abb != 0)     /* leave previous values */
                   {
                       UART_PRINT("nnnnnnnnnnnnnnnnn\n\r");
                   }
                   else
                   {
                       value =yValRead ;
                       itoa(yValRead, tempStr);         //把整形转字符型函数
    
                       UART_PRINT(tempStr,8);     //打印字符函数
                   }
    
    
    #if 0
                  abc=  temperatureReading();
    
                            if(abc != 0)     /* leave previous values */
                                {
                                    UART_PRINT("nnnnnnnnnnnnnnnnnnnnnnnnnnn\n\r");
                                }
                                else
                                {
                                    valueee =(int)fTempRead ;
                                    itoa((int)fTempRead, tempStre);         //把整形转字符型函数
    
                                    UART_PRINT(tempStre,8);     //打印字符函数
                                }
    #endif
        /* initializes mailbox for http messages */
        attr.mq_maxmsg = 10;         /* queue size */
        attr.mq_msgsize = sizeof(SlNetAppRequest_t*);        /* Size of message */
        linkLocalMQueue = mq_open("linklocal msg q", O_CREAT, 0, &attr);
        if(((int)linkLocalMQueue) <= 0)
        {
            UART_PRINT("[Link local task] could not create msg queue\n\r");
            while(1)
            {
                ;
            }
        }
    
        initLinkLocalDB();
    
        /* waits for valid local connection - via provisioning task  */
        sem_wait(&Provisioning_ControlBlock.provisioningDoneSignal);
    
        while(1)
        {
            SlNetAppRequest_t *netAppRequest;
    
            msgqRetVal =
                mq_receive(linkLocalMQueue, (char *)&netAppRequest,
                           sizeof(SlNetAppRequest_t*), NULL);
            if(msgqRetVal < 0)
            {
                UART_PRINT(
                    "[Link local task] could not receive element from msg \
                    queue\n\r");
                while(1)
                {
                    ;
                }
            }
    
            INFO_PRINT(
                "[Link local task] NetApp Request Received - handle from main "
                "context AppId = %d, Type = %d, Handle = %d\n\r",
                netAppRequest->AppId, netAppRequest->Type, netAppRequest->Handle);
    
            INFO_PRINT("[Link local task] Metadata len = %d\n\r",
                       netAppRequest->requestData.MetadataLen);
    
            if((netAppRequest->Type == SL_NETAPP_REQUEST_HTTP_GET) ||
               (netAppRequest->Type == SL_NETAPP_REQUEST_HTTP_DELETE))
            {
                if(netAppRequest->Type == SL_NETAPP_REQUEST_HTTP_GET)
                {
                    UART_PRINT("[Link local task] HTTP GET Request\n\r");
                }
                else
                {
                    UART_PRINT("[Link local task] HTTP DELETE Request\n\r");
                }
    
                httpGetHandler(netAppRequest);
            }
            else if((netAppRequest->Type == SL_NETAPP_REQUEST_HTTP_POST) ||
                    (netAppRequest->Type == SL_NETAPP_REQUEST_HTTP_PUT))
            {
                if(netAppRequest->Type == SL_NETAPP_REQUEST_HTTP_POST)
                {
                    UART_PRINT("[Link local task] HTTP POST Request\n\r");
                }
                else
                {
                    UART_PRINT("[Link local task] HTTP PUT Request\n\r");
                }
    
                INFO_PRINT(
                    "[Link local task] Data received, len = %d, flags= %x\n\r",
                    netAppRequest->requestData.PayloadLen,
                    netAppRequest->requestData.Flags);
    
                httpPostHandler(netAppRequest);
            }
    
            if(netAppRequest->requestData.MetadataLen > 0)
            {
                free (netAppRequest->requestData.pMetadata);
            }
            if(netAppRequest->requestData.PayloadLen > 0)
            {
                free (netAppRequest->requestData.pPayload);
            }
    
            free (netAppRequest);
        }
    }
    
    
    
    static void reverse(char s[])
    {
        int i, j;
        char c;
    
        for (i = 0, j = strlen(s)-1; i<j; i++, j--) {
            c = s[i];
            s[i] = s[j];
            s[j] = c;
        }
    }
    
    
    
    static void itoa(int n, char s[])
    {
        int i, sign;
    
        if ((sign = n) < 0)  /* record sign */
            n = -n;          /* make n positive */
        i = 0;
        do {       /* generate digits in reverse order */
            s[i++] = n % 10 + '0';   /* get next digit */
        } while ((n /= 10) > 0);     /* delete it */
        if (sign < 0)
             s[i++] = '-';
        s[i] = '\0';
        reverse(s);
    }
    
    
    

    注意,在link_local_task.c文件的前面要对两个函数定义下:

    static void itoa(int n,char s[]);
    static void reverse(char s[]);
    

    程序烧进去后,某一个姿态数据 和 温度分别为 -1、 0,不知道问题出在哪里?

  • 您好,

    感谢您的对TI产品的关注!为更加有效地解决您的问题,我需要多一些时间查看这个问题,稍后会为您解答。

  • 您好,

    您的加速度计的值-1在移动设备的时候会改变吗?

    您可以参考如下帖子可能会有所帮助:链接

  • Nick您好,

    我也移动了开发板,同时也用手捂住了温度传感器,串口打印出来的加速度值还是-1、温度值还是0,

    在void * linkLocalTask(void *pvParameters)函数中,

    我明明调用了abb=accelarometerReading();

     和abc=  temperatureReading();

    并立马串口打印,打印出来的值分别是 -1  和 0,

    我在找找原因。 

    同时我研究研究这个链接,多谢啦

  • 您好,

    我们会持续跟进您的问题,请和我们告知您的进度。

    感谢您的支持。