sending ascii prop to prop

hi everyone, quick question. i am sending 16 variable length names from one prop to another in "C" and here is a snipit of the code im using for each name. is there a faster or cleaner way to capture the incoming letters? thanks.

rxchark = 0; p = 0;             
            while(rxchark != '\r' && rxchark != '\n') { // no CR or LF
               rxchark = fdserial_rxChar(transceiver);         // get the name of the button to save
              button1[p] = rxchark;                     // append char
            button1[p] = '\0';                         // append NULL


  • FTR... I only program the Propeller in Spin and PASM, but I do use C a bit at work with other processors. If you have control of both sides of the process, it doesn't seem necessary to filter for newline or return characters on the receive side because your transmitter could replace either of those characters with a NULL and stop transmitting. So, this becomes a slightly tightened version of what you're doing.
      idx = 0;
      while (1==1) {
        charIn = fdserial_rxChar(transceiver);
        strName[idx++] = charIn;
        if (charIn == '\0')
  • Thanks JonnyMac, im trying that now and using
    print("name = %s \n", strName);
    to try and display it but my terminal is having problems.

    im sending
    dprint(receive, "%s%c",button0, 0x00);    //change text

    button0 contains "low beams"

  • JonnyMacJonnyMac Posts: 6,381
    edited 2019-06-25 - 16:15:05
    If I were in your shoes I would write a simple bit of loop code that displays anything that comes in -- this will let you see what dprint() actually doing. You'll probably need a case statement to handle special characters and debugging their output.

    Have you tried this?:
      dprint(receive, "%s%c",button0, '\0');    //change text
  • in a loop i receive everything except a "decimal 0" no matter what i try to send %d 0 %x 0x00 %c '\0' all i get on the receiving side is "low beams"

    it may be somthing weird with the transceivers im using. can i connect the TX from one prop directly to the RX of another? to se if i can then receive a zero?
  • fdserial_txChar lets me send a zero, so i believe the problem is with sending a string using dprint.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 22,521
    edited 2019-06-25 - 18:32:12
    If C is like Spin in this regard, strings are terminated with a zero, so you can't have or send a string containing a zero. (In some languages, strings are prepended with a character count. This has the advantage of allowing anything in the string; but the disadvantage is that it limits the length of the string, depending upon the byte-width of the character count.)

  • bnikkel wrote: »
    fdserial_txChar lets me send a zero, so i believe the problem is with sending a string using dprint.

    I think you're probably right.
  • ok so this now works.

    dprint(receive, "%s",button0);    //change text  
     fdserial_txChar(receive,   '\0');

    JonnyMac i adjusted your suggestion a little.

    #include "simpletext.h"
    #include "simpletools.h"                      // Include simple tools
    #include "fdserial.h" 
    fdserial *transceiver; //HS-LC12S transceiver
     char button0[19];   //
     char button1[19];   //
     char button2[19];   //
     char button3[19];   //
     char button4[19];   //
     char button5[19];   //
     char button6[19];   //
     char button7[19];   //
     char button8[19];   //
     char button9[19];   //
     char button10[19];   //
     char button11[19];   //
     char button12[19];   //
     char button13[19];   //
     char button14[19];   //
     char button15[19];   //
    int main()
        high(10);//LC12S SET pin 
                                // RX-TX  
       transceiver = fdserial_open(0, 1, 0, 9600);     // p0-p1  transmit to receiver
    char charIn = 1;
    char strName[19];
     int idx = 0;
    fdserial_rxFlush(transceiver); // flush rx buffer 
      while (charIn != '\0') {
        charIn = fdserial_rxChar(transceiver);
        strName[idx] = charIn;
        //if (charIn == '\0')
       //   break;
                 printi("strName = %s \n", strName);    
               print("%c", CLS);

    but now how to i get whats stored in strName[19] into button0[19]? button0 = strName; dosent seem to work.
Sign In or Register to comment.