Announcement

Collapse
No announcement yet.

Command to clear buffer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Command to clear buffer

    what command should I use to clear out buffer variables.

    I have been trying to display commands sent through the serial port, I use a carriage retun to detect the end of each command.

    So, basically I have a loop that concatenates characters I type in and look for the carriage return.

    I'm running into issues displaying what I want.. each new command shows part of previous commands ... as if I'm not clearing my buffer properly.

    example:

    command1: display help

    command2: Play demo





    my output would show:

    display help

    display emo







    any ideas?

    Thank you all.

    -Halim

  • #2


    If you post your code, it will be much easier to help....
    _______________
    Best Regards,
    Howard

    Comment


    • #3
      Here is my code:

      func main()
      var mainbuf[50];
      var ch;

      com_Init(mainbuf, 50, 0);

      repeat
      ch := serin();
      if(ch != -1)
      str_Cat(str_Ptr(mainbuf), ch);
      endif
      if(ch == 13)
      print("\nCommand received1:",[STR] mainbuf);
      com_Init(mainbuf, 50, 0);\
      endif
      forever
      endfunc


      Comment


      • #4


        You are using mainbuf for two purposes. Comms is automatically filling mainbuff for you, plus you are using it as string storage.

        Use two separate arrays, or use mainbuf more optimally, eg use the qualifier character and wait until it is received before printing and reinitializing it. Whether this can be done effectively will depend upong what you code is ultimately trying to achieve.
        Mark

        Comment

        Working...
        X