Announcement

Collapse
No announcement yet.

stops responding on reading some serial values

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

  • stops responding on reading some serial values

    I'm reading serial and randomly when the null hex value is sent [00] the display seems to stop responding.

    setbaud(BAUD_9600);

    var c;
    putstr("Type keys on terminal...");
    repeat
    if((c := serin()) > 0)
    print(c);
    print(",");
    endif
    forever
    endfunc

    I can write keyboard characters all day through the terminal.... but when sent from a parrallax uController it stops responding sporadically but always after a few 100 characters have been read. Then the display requires a power cycle. Any help would be great!

    these are the transmissions from the uController in HEX
    [40 6D 31 67 75 69 74 61 72 30 2E 62 6D 70 00 00 00 00 00 00 00 00 00] <Ack>
    [40 6D 31 67 75 69 74 61 72 31 2E 62 6D 70 00 00 00 00 00 00 00 00 00] <Ack>
    [40 6D 32 62 61 73 73 30 2E 62 6D 70 00 00 00 00 00 00 00 00 00] <Ack>

    Hardware: Picaso uOLED-32028
    written in workshop 4 and .4dg



    Last edited by hydronics; 18 November 2017, 10:28 AM.

  • #2
    This really seems like I'm writing over a buffer (in the serial?) and corrupting memory in a very consistent way.

    I added a SystemReset(); in the routine where it stops receiving serial and it resets but continues not receiving serial until I power cycle. I've never worked with these boards but it is really bizarre, eh?.

    I've tested this with qty(3) new 32028 in both workshop 3 and workshop 4. workshop 3 makes me load them as 32028_gfx where as I use 32028-P1 in workshop 4. I've also tried uploading to both flash and ram producing similar results. I hate to admit I really can never remember the difference between the two.
    Last edited by hydronics; 18 November 2017, 10:29 AM.

    Comment


    • #3
      Click image for larger version

Name:	IMG_20171117_173457.jpg
Views:	53
Size:	2.55 MB
ID:	60616Click image for larger version

Name:	IMG_20171117_174814.jpg
Views:	52
Size:	2.13 MB
ID:	60617
      four new displays with all the same results.

      Comment


      • #4
        Hello,

        Welcome to the forum.

        You could try initializing a serial buffer to see if that helps.

        var combuf[50];
        com_Init(combuf, 50, 0);

        I hope this helps

        Best regards

        Paul

        Comment


        • #5
          Hi,

          Thanks for the quick response. Yes I think I tried that.... I tried running the COMCHECK.4dg example...

          var combuf[100]; // buffer for up to 200 bytes

          func main()
          var n;
          gfx_Cls();

          com_Init(combuf, 10, '@' ); // set up a comms buffer, requires ':' qualifiere (lead in) character
          repeat

          but modified the qualifier and quantity above to better match the data coming in. Same deal. I can post my entire code later. It seems to stop after a few 100 characters received but stops sooner if I send data packets more quickly... like once every 100ms vs once every second. Each packet looks similar to this...
          [40 6D 32 62 61 73 73 30 2E 62 6D 70 00 00 00 00 00 00 00 00 00] <Ack>

          When I send hex values over the serial monitor it seems to work. Unfortunately I'm kinda stuck with the propeller uController right now and don't have the source code to simplify the packets for troubleshooting.

          I'm not sure how the original Picaso was set up either but it reads these packets coming in and shows 1 of 6 images. I've figured out how to recreate this in designer using image.dat but left all that stuff out right now to troubleshoot this serial thing. The original Picaso had an sd card with .bmp image files.

          Comment


          • #6
            You haven't shown much of your real code, but wouldn't com_Full() be getting set with what you have show us?
            Mark

            Comment


            • #7
              Here's the code adapted from COMCHECK.4dg. I also attached it. Thanks for checking out my code!

              Code:
              #platform "uOLED-32028-P1"
              
              #inherit "4DGL_16bitColours.fnc"
              
              #inherit "VisualConst.inc"
              
              var combuf[100];
              
              var countTimer;
              
              func main()
                  var n, ch;
                  setbaud(BAUD_9600);
                  countTimer := 0;
              repeat
                  gfx_Cls();
                  txt_MoveCursor(3,0);
                  putstr("Type characters, begin with '@' ...");
              
                  com_Init(combuf, 10, '@' );
                  repeat
                      countTimer := countTimer + 1;
                      if(countTimer == 5000)
                          print("countTimer counted to 5000");
                          //we've been here awhile.. let's reset
                          SystemReset(); //after reset still does not receive.. picaso needs power cycling.
                      endif
                      if (com_Sync())                                 // we have qualifier, now receiving
                          putstr("QUALIFIED");
                      endif
                      txt_MoveCursor(0,1);                            // reset cursor to line 3, column 2
                      print("Buffered ", ( com_Count() ));            // show count of chars in buffer
                  until(com_Full());                                  // loop until buffer fills - lead in + 12 chars
              
                  txt_MoveCursor(3,1);                        // reset cursor to line 3, column 2
              
                  print ("packet");
                  print("@-");
              
                  n := 10;                                 // (or set to 20 so we try to 'over-read' which wont happen)
                  while(n--)
                      if( (ch := serin()) < 0) ch := '.';     // print the chars we received, substitute a period if 'over-reading'
                      putch(ch);
                  wend
                  com_Reset();                // note that any pending characters are ignored until after the reset
              
                  pause(3000); //to read what we received...
                  gfx_Cls();
              forever
              
              endfunc

              I usually receive a full packet of 10 characters before it stops receiving.

              Here's roughly what is sent:

              Code:
              [40 6D 31 67 75 69 74 61 72 31 2E 62 6D 70 00 00 00 00 00 00 00 00 00] <Ack> //1guitar1.bmp
              [40 6D 32 62 61 73 73 30 2E 62 6D 70 00 00 00 00 00 00 00 00 00] <Ack>       //2bass0.bmp
              [40 6D 33 76 69 6F 6C 69 6E 31 2E 62 6D 70 00 00 00 00 00 00 00 00 00] <Ack> //3violin1.bmp
              Here's roughly what is printed:

              Code:
              m1guitar0.
              m2bass0.bm
              m3violin0.

              Comment


              • #8
                Code:
                com_Reset();
                As the manual says, "Resets the serial communications buffered service and returns it to the default polled mode."

                But, still, what's wrong with what's being printed? It seems to be the first 10 characters of each buffer, as the code says to print.
                Mark

                Comment

                Working...
                X