7 Replies Latest reply on Sep 18, 2016 11:57 PM by user_1377889

    Different between PSOC4 and PSOC5 in strtok?

    cbelter_1781346

      I have a problem with strtok. I use it to part command and value or only command.

         

      In PSOC4 it works with the CY8CKIT_049. In PSOC5 it don't work with CY8CKIT_059.

         

      In PSOC4 it retun on an empty string NULL and in PSOC5 other than NULL.

         

      What is the different?

        • 1. Re: Different between PSOC4 and PSOC5 in strtok?
          user_1377889

          Both CPUs use the same compiler and probably the same library. Can you please create a workspace with the two examples to check?

             

           

             

          Bob

          • 2. Re: Different between PSOC4 and PSOC5 in strtok?
            cbelter_1781346

            I have found the error. It was an Compiler-error. I have in Building Settings at Compiler->Optimization Level set from "Size" to "Minimal".

            • 3. Re: Different between PSOC4 and PSOC5 in strtok?
              arnold_1516101

              I have a problem with strtok,I'm try to solve the problem, I found key word  "printf" then run  "strtok" ,it will hung up

                 

               

                 

              int main()

                 

              {

                 

                  CyGlobalIntEnable; /* Enable global interrupts. */

                 

               

                 

                  /* Place your initialization/startup code here (e.g. MyInst_Start()) */

                 

               

                 

                  char buffRx[] =  "GET / HTTP/1.1";  

                 

                  

                 

                  char * nexttok;

                 

               

                 

                  printf("Hello");

                 

                  

                 

                  nexttok = strtok(buffRx," ");     // nexttok = strtok((char*)buf," ");

                 

                  

                 

                  printf("Strtok test :\%s", nexttok);  

                 

                  

                 

                  

                 

                  for(;;)

                 

                  {

                 

                      /* Place your application code here. */

                 

                  }

                 

              }

              • 4. Re: Different between PSOC4 and PSOC5 in strtok?
                user_1377889

                Welcome in the forum, Arnold.

                   

                Tell us Which board you are using (Name starts with CY8CKIT-,,,,,)

                   

                The PSoC has not got an OS, so how should it know where to send the data to.

                   

                At first #include <stdio.h>

                   

                Then put an UART component onto your topdesign page. The Rx and Tx pins must be connected to the UART - USB bridge of your Kit board. See schematic of the board.

                   

                Then you can use a terminal emulation program as PuTTY to display ASCII data using an emulated COM: port.

                   

                Use sprintf() and UART_PutString() to send data to the PC

                   

                 

                   

                Bob

                • 5. Re: Different between PSOC4 and PSOC5 in strtok?
                  arnold_1516101

                  Hi Bob

                     

                  My test board is CY8CKIT-042-BLE,I'm try add UART component, PuTTY's screen display the "Hello",but same hung up at "strsok" function。

                     

                  I don't know how to solve the problem, I am new here,Thanks for Bob help。

                     

                  #include <project.h>

                     

                  #include <string.h>

                     

                  #include <stdio.h>

                     

                   

                     

                  int main()

                     

                  {

                     

                      CyGlobalIntEnable; /* Enable global interrupts. */

                     

                   

                     

                      /* Place your initialization/startup code here (e.g. MyInst_Start()) */

                     

                      

                     

                      UARTprint_Start();

                     

                   

                     

                      char buffRx[] =  "GET / HTTP/1.1";  

                     

                      

                     

                      char * nexttok;

                     

                   

                     

                      printf("Hello");

                     

                      

                     

                      nexttok = strtok(buffRx," ");     // nexttok = strtok((char*)buf," ");

                     

                      

                     

                      printf("Strtok test :\%s", nexttok);  

                     

                      

                     

                      

                     

                      for(;;)

                     

                      {

                     

                          /* Place your application code here. */

                     

                      }

                     

                  }

                     

                   

                     

                  int _write(int file, char *ptr, int len)

                     

                  {

                     

                      int i;

                     

                      file = file;

                     

                      for (i = 0; i < len; i++)

                     

                      {

                     

                          UARTprint_UartPutChar(*ptr++);

                     

                      }

                     

                      return(len);

                     

                  }

                  • 6. Re: Different between PSOC4 and PSOC5 in strtok?
                    arnold_1516101

                    Hi Bob

                       

                    I solved the problem,I adjust Heap Size from 0x200 to 0x400。Now Heap Size set to 0x800,My project can contium debug...... 

                       

                    Thanks again Bob。

                    1 of 1 people found this helpful
                    • 7. Re: Different between PSOC4 and PSOC5 in strtok?
                      user_1377889

                      You are always welcome!

                         

                       

                         

                      Bob