2 Replies Latest reply on Jul 2, 2017 11:18 AM by user_151510080

    char comparition on if Imagecraft

    user_151510080

      Hi,

         

      I'm developing some UART communication with PSoC 1 and I'm getting this error:

         

      type error in argument 2 to `strstr'; found `pointer to __flash char' expected `pointer to char'

         

      Code is as simple as this:

         

      if (strstr(rx_buff,"OK") != NULL)
                  {
                     LED_On();
                  }

         

      Am I missing something? this "__flash" thing it's new to me on C.

         

      also apears when I try to compare some char on an IF.

         

      char test[3] = "OK"

         

      if ( test == "OK") ---> this lines gives again __flash error.

         

      Have been trying and reading texts but I don't get it, any documentation on __flash or an advice?

         

      Thank you in advance.

        • 1. Re: char comparition on if Imagecraft
          user_1377889

          You are here on a von Neumann machine which has different instructions when accessing data in flash ("OK") and data in sram (rx_buff). For some library routines there were replacements which took that into account. They would be named cstrstr() or strcstr(), but I do not know whether they have been implemented for PSoC1.

             

          A good tip for you is really: get a CY8CKIT-043 and switch to a modern ARM CPU.

             

           

             

          Bob

          • 2. Re: char comparition on if Imagecraft
            user_151510080

            Thank you, Bob!! Yeah, I have been developing on PSoC 5LP (CY8CKIT-059) and when some partner asked me to develop on PSoC 1 it was a huge change, and yes, switching to a modern ARM CPU it's a great tip. Again, thank you for your answer and time.