You are here

Different between PSOC4 and PSOC5 in strtok? | Cypress Semiconductor

Different between PSOC4 and PSOC5 in strtok?

Summary: 7 Replies, Latest post by Bob Marlowe on 18 Sep 2016 11:57 PM PDT
Verified Answers: 2
Last post
Log in to post new comments.
cbelter_1781346's picture
User
4 posts

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?

user_1377889's picture
User
10699 posts

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

 

Bob

cbelter_1781346's picture
User
4 posts

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

arnold_1516101's picture
User
3 posts

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

    }

}

user_1377889's picture
User
10699 posts

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

arnold_1516101's picture
User
3 posts

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

}

 

arnold_1516101's picture
User
3 posts

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。

user_1377889's picture
User
10699 posts

You are always welcome!

 

Bob

Log in to post new comments.