Announcement

Collapse
No announcement yet.

ledDigitDisplay crashes the program, how to debug

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

  • kayven@4d
    replied
    Hi,

    Thank you for your findings.

    You manage your problem well.

    If you have time, you could try to store the value of your variable "value" to another variable, then use this variable in your ledDigit function.


    Best regards,
    Kayven.

    Leave a comment:


  • Thieso
    replied
    Hi Kayven,

    thanks for your response and the suggestion for debugging. I tried around a bit on my own and figured out where the problem lies. If I reset the array (reinitialize) after every time I read in 4 chars then the problem is solved. So I basically just added
    Code:
    pchTextBuffer = str_Ptr(pchTextBuffer);
    before the
    Code:
    counter := 0;
    line and that solved the problem. What baffles me about this is that the ledDigitsDisplay() method does not even interact with the buffer but if I comment it out everything works fine.
    So I have no clue what causes this weird behaviour but maybe this helps you or future people with this problem to resolve it

    Best regards
    Thies

    Leave a comment:


  • kayven@4d
    replied
    Hi,

    If you are in serial UART protocol, the bad connection will result in misreading the values ​​over the serial.
    And also stable parsing of data over serial is very important.

    First of all, you need a way of debugging.
    So, you can use Terminal in the Tool menu. This will help you observe the receiving of data over serial:

    Here is the code for debugging;

    Code:
    var receive_data;
    
    func main()
          com_SetBaud(COM0,960);    // initialize com port 0
    
          repeat
              receive_data : = serin();      // store unsigned 16bit data from com0
    
              if(receive_data  >  0)          
                  to(COM0);                        // show the values in the terminal
                  serout(receive_data);
              endif
          forever
    
    endfunc

    And parse it one by one especially the value required for the LedDigit function is an unsigned 16bit integer.

    Right now, we'll try to figure out what we can do about your concern and we'll post it here as soon as possible.



    Best regards,
    Kayven

    Leave a comment:


  • Thieso
    replied
    Hi Kevin,

    Do you have any Idea on how to fix this? I am still struggling with this.

    Thanks
    Thies

    Leave a comment:


  • Thieso
    replied
    Hi Kevin,

    Yes as far as I know the value parameter is an integer.
    So I send for example the string "S1234" over serial. Then the typeS parameter gets the value "S" and the value parameter gets the value "1234". That works for my code since when I print them it shows the correct values.
    I don't know how to explicitly tell the program that value is an integer.

    Thanks for your help

    Best regards
    Thies

    Leave a comment:


  • John Kevin
    replied
    Hi,

    Are you passing an integer value on the 'LedDigit' widget?
    Can you please explain how the values are passed into the Serial? This can help us to further understand your program.

    Best regards,
    Kevin

    Leave a comment:


  • Thieso
    started a topic ledDigitDisplay crashes the program, how to debug

    ledDigitDisplay crashes the program, how to debug

    Hello,

    I wrote a program to display LEDDigits and update them once every few seconds. I use the function ledDigitsDisplay() for that and let the IDE create the code for that (using the paste code button). I use this inside a loop which also reads data over serial.
    The problem is that the ledDigitsDisplay() method seems to crash the program. When I write a simple program which only shows increasing numbers it works fine but in my program after updating the numbers 3 times it crashes (display goes blank and unresponsive).
    If I change the number I send over serial the number of times it works changes (for example to 5). So I think there is some overflow or something like that going on. But I can find it and I don't know how to debug it in a way to find it.

    Below you find my code

    Code:
    counter := 0;
        value := 0;
        repeat
            chReceived := serin1();
            if (chReceived > 0)
                // Store character in the buffer
                str_PutByte(pchTextBuffer + counter, chReceived);
                counter += 1;
                if (counter >= messageSize)
                    //str_Printf(&pchTextBuffer, "%2s");
                    //putstr(pchTextBuffer);
                    //putstr("hallo");
                    str_GetC(&pchTextBuffer, &typeS);
                    if (str_FindI(&typeS, "S"))
                        print("jöasdf");
                    endif
                    //putch(typeS);
                    str_GetD(&pchTextBuffer, &value);
                    print(value, "\n");
                    // Speed 1.0 generated 5/14/2019 2:08:39 AM
                    ledDigitsDisplay(value, iRPM+1, 176, 4, 1, 33, 1);
                    //ledDigitsDisplay(value, iSpeed+1, 0, 3, 1, 59, 1);
                    counter := 0;
                endif
            endif
        until (com_Error());
Working...
X