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:为什么加速度 x 轴、y 轴和 z 轴的数据全部读取为-1、并提供修改后的开箱即用示例?

Guru**** 2539400 points
Other Parts Discussed in Thread: LAUNCHXL-CC3235S

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/wi-fi-group/wifi/f/wi-fi-forum/1167516/cc3235s-why-are-the-datas-of-acceleration-x-axis-y-axis-and-z-axis-read-out-all--1-with-a-modified-out-of-box-example

器件型号:CC3235S

大家好、

这是客户提出的问题、希望能得到解决:

SDK 是 simplelink_cc32xx_sdk_5_20_00_06。  使用 带有 修改后的开箱即用示例的 LAUNCHXL-CC3235S、为什么加速度 x 轴、y 轴和 z 轴的数据读取全部为-1?

他在代码中设置断点并发现问题。 他刚刚修改了 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);
}

此外、还有两个函数在前面被定义:

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

您能帮我解决这个问题吗?

谢谢、此致、

Nick