3 Replies Latest reply on Feb 21, 2015 5:34 AM by user_1377889

    Infuriating mystery issue between creator 3 and 3.1

    nick.burns

      Hello,

         

      I have been using fopencookie to create custom streams in PSoC Creator 3.0 and just recently started a new, empty, project in Creator 3.1 for a different application. I duplicated my cookie code from the old project with copy/paste, and made a minimal startup design which routes stdout to the LCD (to allow printf, etc to work). After some time investigating, I found that setvbuf() was hanging the processor in the following function which is called directly from my main() after LCD_Start():

         

      void stdoutToLCD()
      {
          cookie_io_functions_t iofun;
          iofun.close = CookieClean;   //pointer to function that does nothing
          iofun.read = CookieRead;     //pointer to function that returns nothing
          iofun.seek = CookieSeek;     //pointer to function that does nothing
          iofun.write = CookieWrite;     //pointer to function that places chars on the LCD from the passed-in buffer
          stdout = fopencookie(NULL, "w", iofun);     //opens the LCD as a file for writing to and attaches to stdout

         


          setvbuf(stdout, NULL, _IONBF, 0);               //freezes here (setting stream to unbuffered)
      }
       

         

      I assumed I must be doing something wrong, because the old code created in Creator 3.0 still compiles and works fine on Creator 3.1 even after I allow the component update tool to update cyboot and all the other components in the design.

         

      To further test this mystery I rebooted into Windows XP, and created a minimal project in exactly the same way using Creator 3.0. It runs perfectly well. I rebooted to Win 8.1 to load the project into Creator 3.1 again, updated components and recompiled and it still runs perfectly well.

         

      My final test was to once again follow exactly the same copy-paste steps in Creator 3.1 in another empty project, just to verify that it indeed doesn't work in 3.1 (which it didn't!).

         

      Now I have looked through compiler options and made sure they are identical, I have also looked under every other menu I could find containing project settings, and I don't see any differences. Creator 3.0 is using GCC 4.7.3, while 3.1 is using 4.8.4, but this can't be the problem either as far as I know because the Creator 3.0 project compiles and works in Creator 3.1 no problem. I suspect I'm overlooking a setting, but I can't for the life of me figure out where it is!

         

      I've attached both projects in "PSoC Tests.zip" which contains "MadeInCreator3.1.zip" and "MadeInCreator3.zip".

         

      The "MadeInCreator3.zip" project has been updated when it was loadded into Creator 3.1, and re-saved, but still runs fine. The "MadeInCreator3.1.zip" project was built in Creator 3.1 using EXACTLY the same staps as I used in Creator 3.0, but it hangs in setvbuf(stdout, NULL, _IONBF, 0) as described above.

         

      Please, please please, can anyone see why?

         

      Thanks for your time :)