1 Reply Latest reply on Dec 3, 2019 11:20 PM by JayakrishnaT_76

    FX3 - How to use sprintf function?

    HuYa_4249091

      Hi all:

       

      I want to use sprintf() in EZ USB Suite - FX3 FW, but it met compiler fail.

      I've added "#include <stdio.h>", but it still fail...

      error.jpg

       

      Hope someone could provide any suggestion.

      Thanks a lot!

       

      Hughes

        • 1. Re: FX3 - How to use sprintf function?
          JayakrishnaT_76

          Hello,

           

          Please use the API CyU3PDebugStringPrint(); for implementing snprintf();. This API make use of following parameters as shown in its definition.

           

          extern CyU3PReturnStatus_t

          CyU3PDebugStringPrint (

                  uint8_t *buffer,                          /**< Buffer into which the data is to be printed. */

                  uint16_t maxLength,                /**< Buffer size. */

                  char    *fmt,                              /**< Format specifier string. */

                  ...                                             /**< Variable argument list. */

                  );

           

          I have implemented your requirement as shown below.

           

          char c1[20];

          uint8_t n =5;

          CyU3PDebugStringPrint ((uint8_t*)c1, 20, "He has %d books.\n", n);

          CyU3PDebugPrint(4,c1);

           

          I got the following output in teraterm.

           

          Best Regards,

          Jayakrishna

          1 of 1 people found this helpful