getting rid of Strings

I have been warned away from strings or Strings, so I have revamped an old project to get rid of them, but I have to send data , which is now a mix of chars and integers, via a RS232 link to a PC for logging.

The user will be using an excel type program to display how they like, so I could send an integer and tell them how to interpret the data?

I can send all the headers fine via newsoftserial ( this project was done in v22 ) , and the Megunalink terminal displays all the headings i setup fine, but not the subsequent data. ( the monitor displays fine - I have reduced the number of prints for testing)

I have tried sending with the normal hardware serial but wasted many days trying, so now I am using the NSS version.

I have spent a lot of time sorting out other silly errors, and my brain hurts !

A bit of guidance will be appreciated....

(The part in setup logs fine, but not in the loop )


( in set up )


    Serial.print (clockyear); 
    Serial.print(","); 

    Serial.print(clockmonth);  
    Serial.print(",");
 
    Serial.print(clockday); 
    Serial.print(","); 
 
    Serial.print (clockhours); 
    Serial.print(",");

    Serial.print (clockmins); 
    Serial.print(",");
    if ( searching == HIGH ) { 
      Serial.print ("searching,"); 
    }
    else { 
      Serial.print ("locked,");
    }

    if ( queue == HIGH ) { 
      Serial.print ("NORMAL,"); 
    }
    else { 
      Serial.print ("EXPRESS,");
    }
    //  Serial.print("  TICKET NUMBER= ");
    Serial.print (number); 
    Serial.print(",");
    Serial.print ("PRINTING");
    Serial.println(",");
    
    
and in loop :-





   hardwired.print ( clockyear); 
    hardwired.print(","); 

    hardwired.print(clockmonth);  
    hardwired.print(",");
 
  
 
    hardwired.print(clockday); 
    hardwired.print(","); 

    hardwired.print (clockhours); 
    hardwired.print(",");

    hardwired.print (clockmins); 
    hardwired.print(",");
    if ( searching == HIGH ) { 
      hardwired.print ("searching,"); 
    }
    else { 
      hardwired.print ("locked,");
    }

    if ( queue == HIGH ) { 
      hardwired.print ("NORMAL,"); 
    }
    else { 
      hardwired.print ("EXPRESS,");
    }

    hardwired.print (number); 
    hardwired.print(",");
    hardwired.print ("PRINTING");
    hardwired.println(",");
   
  Serial.print (number); 
    Serial.print(",");
    Serial.print ("PRINTING");
    Serial.println(",");
   hardwired.print (char () clockyear); 
    hardwired.print(","); 
    hardwired.print(clockmonth);  
    hardwired.print(",");
    hardwired.print(clockday); 
    hardwired.print(","); 
    hardwired.print (clockhours); 
    hardwired.print(",");
    hardwired.print (clockmins); 
    hardwired.print(",");
    if ( searching == HIGH ) { 
      hardwired.print ("searching,"); 
    }
    else { 
      hardwired.print ("locked,");
    }

    if ( queue == HIGH ) { 
      hardwired.print ("NORMAL,"); 
    }
    else { 
      hardwired.print ("EXPRESS,");
    }

    hardwired.print (number); 
    hardwired.print(",");
    hardwired.print ("PRINTING");
    hardwired.println(",");

I have been warned away from strings or Strings

Strings, maybe. strings, no. strings are fine.

You need to post all of your code, not snippets.

I have tried sending with the normal hardware serial but wasted many days trying, so now I am using the NSS version.

Usually, HardwareSerial is easier to use, since those are the pins that are normally connected to the PC. It isn't clear what is connected to what, how, in your project.

I am still struggling with this logger. I have whittled down the code to test the receiving and logging of the data.

The code is attached , based onNick Gammons serial receive.There is still alot of extra stuff in setup not used in this test.

What I have done for testing, is linked the data in on the embedded pcb ( pin 14 hardwire NSS ) to pin 14 0n an arduino board, plus pin 1 RXD to pin 1 of the arduino ) I disconnect the link to the pin 1 of the Arduino board when testing the embedded board.

I can run the code below with the chip plugged into the Arduino board, and it works fine, sees all thecheckpoints, and logs the data ( to a Terminal display )

If I take out the chip and plug it into the embedded pcb,it logs the data headings in the setup routine, but doesnt get past the checking if serial available ( which is coming in on pin 14 )

The grounds are common .

Any ideas, I musthave done something stupid here ...

forumhelp.pde (5.39 KB)

I remember something about resistors on the TXd and RXd pins for barebones boards, but I checked it, and my pins are not floating, they go to a MAX232 chip to connect to the PC for logging.

double check tx on arduino goes to rx of target and visa versa. many seriall programs work to pc but they forget to cross them on hooking to real hardware.

I found the problem in the end, it was the receivers output to the chip was just under 3v pp, ( its running on the 3v3 line ) and the arduino spec for a 1 input is 3v.

I put a 2 transistor level shifter on it and it was OK.

I have used the direct input to the chip many times with no hassle.

It was confusing as it would work when I put the chip in the arduino borad, so I guess the USB 5v is marginally higher than the 5v from my regulator.

Glad you got it working