Different between PSOC4 and PSOC5 in strtok?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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?

0 Likes
1 Solution
Anonymous
Not applicable

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

View solution in original post

0 Likes
7 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

   

 

   

Bob

0 Likes
Anonymous
Not applicable

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

0 Likes
lock attach
Attachments are accessible only for community members.
arla_1516101
Level 1
Level 1
First like received

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. */

   

    }

   

}

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes
arla_1516101
Level 1
Level 1
First like received

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);

   

}

0 Likes
arla_1516101
Level 1
Level 1
First like received

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。

Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You are always welcome!

   

 

   

Bob

0 Likes