Announcement

Collapse
No announcement yet.

to(outstream) issues

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

  • to(outstream) issues

    All, my setup:
    uLCD-43DT
    IDE 4.3.0.8
    WIN10 PRO

    My to() function seems to not work like I would think:

    Code:
      
    var TX_buffer[200];
    var crc;
    
        to(TX_buffer); print("123456789");
        crc := crc_CSUM_8(TX_buffer, sizeof(TX_buffer));
    
        to(COM0); print("123456789");
        serout(crc); // send CRC out COMM port
    What I would expect is the TX_buffer gets stuffed with "123456789", which it does because the CRC ends up being the "text book example" 0x0023, or 35 decimal.

    Then when I use the terminal I receive:

    00 31 32 33 34 35 36 37 38 39 00 00 00 ......... lots of nulls here then....... 31 32 33 34 35 36 37 38 39 23

    why is it twice??

    Then this configuration.... changing the 2 different to() functions around;
    Code:
      
    var TX_buffer[200];
    var crc;
    
        to(COM0); print("123456789");
    
        to(TX_buffer); print("123456789");
        crc := crc_CSUM_8(TX_buffer, sizeof(TX_buffer));
        serout(crc); // send CRC out COMM port
    I receive this on the terminal:
    31 32 33 34 35 36 37 38 39 00 31 32 33 34 35 36 37 38 39 00 00 00 00 00 00 00 ...... lots of nulls here then ..... 23


    EDITED:
    Also, interesting note:
    Code:
      
    var TX_buffer[200];
    var crc;
    
        to(TX_buffer); print("123456789");
        crc := crc_CSUM_8(TX_buffer, sizeof(TX_buffer));
        serout(crc); // send CRC out COMM port
    This code will also send out a complete stream to the COM port:
    00 31 32 33 34 35 36 37 38 39 00 00 00 00 00 00 00 ...... lots of nulls here then ..... 23

    So maybe my issue is my serout() command???

    Why is my TX_buffer also getting added into my COM0 outstream?

    What I would like to accomplish is:
    calculate CSUM
    send String to COMM port
    send CRC to COMM port


    Thanks,
    Keith

    Last edited by ch701builder; 14th February 2017, 05:29 AM.

  • #2
    Hi ch701builder,

    Have you tried or able in your setup to send the string and crc through COM1?

    Code:
    var TX_buffer[200];
    var buffer[10];
    var crc;
    
    //---
    
       COM1_RX_pin(PA2);
       COM1_TX_pin(PA3);
       com_SetBaud(COM1, 960);
       com1_Init(buffer, 20, 0 );
    
        to(TX_buffer); print("123456789");
        crc := crc_CSUM_8(str_Ptr(TX_buffer), sizeof(TX_buffer));
    
        to(COM1); print("123456789");
        to(COM1); putch(crc);
        to(COM1); putch('\n');
    The serial example might interest you as well. 'File' - 'Samples' - 'Picaso Designer' - 'BUFFEREDTX'.

    Hope this helps,
    Last edited by Joseph Herrera; 14th February 2017, 06:02 PM.

    Comment


    • #3
      Joseph,
      I haven't tried re-configuring my system for the different COM port yet, but it still doesn't explain why the following code:

      Code:
        
      var TX_buffer[200];
      var crc;
      
          to(TX_buffer); print("123456789");
          crc := crc_CSUM_8(TX_buffer, sizeof(TX_buffer));
          to(COM0); print([CHR]crc);
      has a result of:
      00 31 32 33 34 35 36 37 38 39 00 00 00 00 00 00 00 00 .................................................... 00 00 00 00 23

      isn't the to(outstream) only supposed to print out the CRC, and then after the print() is done, it defaults back to TEXT to screen? the append() is supposed to takeup where the to() left off.
      Also, why is my whole TX_buffer[200] being sent to the COM port when only the CRC is supposed to be sent?


      Here is another interesting example just to see if both, buffer, and to(outstream) get sent:
      Code:
        
      
      var TX_buffer[200];
      var crc;
      
          to(TX_buffer); print("123456789");
          crc := crc_CSUM_8(TX_buffer, sizeof(TX_buffer));
      
          to(COM0); print("$CPYMAIN_DIR.TXT");
          to(COM0); print([CHR]crc);
      Here is the result from the 4D built in Tools Terminal 9600
      00 31 32 33 34 35 36 37 38 39 00 00 00 00 00 00 00 00 00 00 .................... 00 00 00 00 00 00 24 43 50 59 4D 41 49 4E 5F 44 49 52 2E 54 58 54 23

      The TX_buffer 123456789 is first??? then there are numerous NULLS, then followed with the $CPYMAIN_DIR.TXT which I expected to be first... followed by the CRC which is correct for the TX_buffer of "123456789"........

      All tests are with the built-in >Tools>Terminal 9600 program.
      EDITED----
      I also tried Hyperterminal and I get the same results.. so it isn't a Terminal issue...
      EDITED---
      I just tried sending the COM to Arduino Mega2560 and using its built in Terminal..... same thing.....


      Keith





      Last edited by ch701builder; 15th February 2017, 02:05 AM.

      Comment


      • #4
        All, My workaround.

        First
        sizeof()
        doesn't look for the first NULL character. It returns the complete buffer, so in my example it would return 200 since my TX_buffer was 200.
        I used str_Length() instead.
        p := str_Ptr(TX_buffer); // p = pointer to TX_buffer
        len := str_Length(p); // len = length of TX_buffer text

        Then I used this value into the crc_CSUM_8() as the length.

        Then I created a loop to send out my TX_buffer using
        str_ByteMove(p + i, dest, 1);
        to(COM0); print([CHR]dest);

        Then I followed up with
        to(COM0); print([CHR]crc); // send CRC CheckSum
        to send my crc value.

        seems to be working, but not understanding why my TX_buffer was always being sent out the COM even though I never issued a command (that I can tell) to send it.

        Have a good day everybody!!!

        Keith


        Comment


        • #5
          Hi Keith,

          Currently, the command 'crc_CSUM_8(buf, count)' uses the COM0, so it might be the reason it is being seen in COM0.

          This will be fixed in the next PmmC Release. Thank You.

          'str_Length()' returns the length of a byte aligned string excluding terminator.
          While 'sizeof()' returns the size of the buffer.

          Thank you and Regards,

          Comment

          Working...
          X