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.

LAUNCHXL-CC2650: OSAL READ TO UART

Part Number: LAUNCHXL-CC2650

Hello ,

I'm currently trying to save some data (string) using osal_write() and then read the same value and show the read value via putty (UART) and I have a problem using these function and I'm not sure what I'm missing here

do I need to use I call function in my function in order to use these function ?

how can i check if I mange to read and write successfully?

how can I pass the read value to putty through UART

I use write_uart () to show and it works fine if I use it before osal_snv_XXXX()

but if i use it after it dosen't work at all

ICall_registerApp(&testEntity, &testsem);

    unit8 x[20] ="000000000000000000000";



         status =  osal_snv_write(0x80, 20, x );

unit8 d[20]= "Baaaaaa\r\n";

unit8 c[20];
       memset (c, '\0', sizeof(c));
strcpy (c,d);

         status =  osal_snv_write(0x80, 20, c );

         status = osal_snv_read( 0x80, 20, c);
 UART_write(uart, c, sizeof(c));

I'm using ble_sdk_2_02_02_25

thank you so much for any help

Best regards

Bassel

  • Hi Bassel,

    Since you're using a BLE SDK, I've moved your post to the Bluetooth forum.

    I am working to find the appropriate expert to help you. This may take some time to reach the right person depending on availability. Please expect an update within 2 weeks. I appreciate your patience.



    Regards,
    Toby
  • I add the following codes in red to test write/read snv and output to UART in simple_peripheral example. I works well on my LAUNCHXL-CC2650.

    #include <ti/drivers/uart/UARTCC26XX.h>
    #include <stdio.h>

    UART_Handle uart;
    UART_Params uartParams;
    char echoPrompt[] = "\fEchoing characters:\r\n";

    uint8 status_snv;
    uint8 write_buffer[10];
    uint8 read_buffer[10];

    static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1)
    {
      // Initialize application
      SimpleBLEPeripheral_init();
      Util_startClock(&periodicClock);
      /* Create a UART with data processing off. */
      UART_Params_init(&uartParams);
      uartParams.writeDataMode = UART_DATA_BINARY;
      uartParams.readDataMode = UART_DATA_BINARY;
      uartParams.readReturnMode = UART_RETURN_FULL;
      uartParams.readEcho = UART_ECHO_OFF;
      uartParams.baudRate = 115200;
      uart = UART_open(Board_UART0, &uartParams);

      if (uart == NULL) {
          return;
      }

      UART_write(uart, echoPrompt, sizeof(echoPrompt));

      // Application main loop
      for (;;)
      {
        // Waits for a signal to the semaphore associated with the calling thread.
        // Note that the semaphore associated with a thread is signaled when a
        // message is queued to the message receive queue of the thread or when
        // ICall_signal() function is called onto the semaphore.
        ICall_Errno errno = ICall_wait(ICALL_TIMEOUT_FOREVER);

        if (errno == ICALL_ERRNO_SUCCESS)
        {
          ICall_EntityID dest;
          ICall_ServiceEnum src;
          ICall_HciExtEvt *pMsg = NULL;

          if (ICall_fetchServiceMsg(&src, &dest,
                                    (void **)&pMsg) == ICALL_ERRNO_SUCCESS)
          {
            uint8 safeToDealloc = TRUE;

            if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == selfEntity))
            {
              ICall_Stack_Event *pEvt = (ICall_Stack_Event *)pMsg;

              // Check for BLE stack events first
              if (pEvt->signature == 0xffff)
              {
                if (pEvt->event_flag & SBP_CONN_EVT_END_EVT)
                {
                  // Try to retransmit pending ATT Response (if any)
                  SimpleBLEPeripheral_sendAttRsp();
                }
              }
              else
              {
                // Process inter-task message
                safeToDealloc = SimpleBLEPeripheral_processStackMsg((ICall_Hdr *)pMsg);
              }
            }

            if (pMsg && safeToDealloc)
            {
              ICall_freeMsg(pMsg);
            }
          }

          // If RTOS queue is not empty, process app message.
          while (!Queue_empty(appMsgQueue))
          {
            sbpEvt_t *pMsg = (sbpEvt_t *)Util_dequeueMsg(appMsgQueue);
            if (pMsg)
            {
              // Process message.
              SimpleBLEPeripheral_processAppMsg(pMsg);

              // Free the space from the message.
              ICall_free(pMsg);
            }
          }
        }

        if (events & SBP_PERIODIC_EVT)
        {
          events &= ~SBP_PERIODIC_EVT;
          write_buffer[0] += 0x1;
          write_buffer[1] += 0x1;
          write_buffer[2] += 0x1;
          write_buffer[3] += 0x1;

          status_snv = osal_snv_write(0x80,10, (uint8_t *)write_buffer );

          //Do ADC Polling and Data processing
          read_buffer[0] = 0x0;
          read_buffer[1] = 0x0;
          read_buffer[2] = 0x0;
          read_buffer[3] = 0x0;

          status_snv = osal_snv_read(0x80,10, (uint8_t *)read_buffer );
          sprintf(echoPrompt,"%x%x%x%x\r\n",read_buffer[0],read_buffer[1],read_buffer[2],read_buffer[3]);
          UART_write(uart, echoPrompt, 10);

          Util_startClock(&periodicClock);

          // Perform periodic application task
          SimpleBLEPeripheral_performPeriodicTask();
        }

    #ifdef FEATURE_OAD
        while (!Queue_empty(hOadQ))
        {
          oadTargetWrite_t *oadWriteEvt = Queue_get(hOadQ);

          // Identify new image.
          if (oadWriteEvt->event == OAD_WRITE_IDENTIFY_REQ)
          {
            OAD_imgIdentifyWrite(oadWriteEvt->connHandle, oadWriteEvt->pData);
          }
          // Write a next block request.
          else if (oadWriteEvt->event == OAD_WRITE_BLOCK_REQ)
          {
            OAD_imgBlockWrite(oadWriteEvt->connHandle, oadWriteEvt->pData);
          }

          // Free buffer.
          ICall_free(oadWriteEvt);
        }
    #endif //FEATURE_OAD
      }
    }

  • Hello YiKai Chen ,
    I have tried to add these lines and the program and it works beautifully !!
    it seems that my mistake was using Icall functions wrongfully
    so I changed the whole function and the result is awesome
    thank you so much for your help that was really helpful I appreciate it so much
    Best regards
    Bassel