CoolTerm timestamp affecting formatting

If you have specific questions or problems with any of my Freeware applications, post them here.
Post Reply
SemiLucid
Posts: 3
Joined: Sat Jan 05, 2013 7:29 pm

CoolTerm timestamp affecting formatting

Post by SemiLucid »

Hi I was wondering if anyone could tell me why the serial received from my Arduino gets messed up when I apply a time stamp? You can see below that the formatting goes out of alignment.

Code: Select all

H,Source Temp: 24, Sink Temp: 33,
H,Source Temp: 24, Sink Temp: 33,
H,Source Temp: 24, Sink Temp: 33,
H,Source Temp: 24, Sink Temp: 33,
H,Source Temp: 24, Sink Temp: 33,
H,Source Temp: 24, Sink Temp: 33,
2013-01-06 15:18:22:261	H,Source Temp: 24, Sink Temp: 33,
2013-01-06 15:18:22:261	
2013-01-06 15:18:24:233	H,Source Temp: 24, Sink Temp: 33
2013-01-06 15:18:24:336	,
2013-01-06 15:18:24:336	
2013-01-06 15:18:26:301	H,Source Temp: 24, Sink Temp: 33,
2013-01-06 15:18:26:301	
2013-01-06 15:18:28:267	H,Source Temp: 24, Sink Temp: 33,
2013-01-06 15:18:28:267	
2013-01-06 15:18:30:239	H,Source Temp: 24, Sink Temp: 3
2013-01-06 15:18:30:342	3,
2013-01-06 15:18:30:342	
User avatar
roger
Site Admin
Posts: 566
Joined: Fri Apr 24, 2009 12:41 am
Contact:

Re: CoolTerm timestamp affecting formatting

Post by roger »

CoolTerm generates a time stamp whenever the serial port API generates an event to indicate that data was received as well as after newline and/or carriage return characters. In your case it appears that it generates two such events when your Arduino sends data. How are you sending your data? Are you sending each line in multiple chunks or all at once? Sending the whole line at once (including the CR or LF), I.e. with a single serial.write command, can possibly minimize this issue.

CoolTerm was designed such that its function is not dependent on the use case. E.g. the timestamp functionality was implemented such that the received data does not require a particular termination character at the end of a line in order for the data to get logged. However, it appears that in this case an exception could be made. I will look into the possibility to add an option to the time stamp setting to not log data with a time stamp until a specific character (e.g. CR) is received. This would mitigate this issue but would also mean that CoolTerm will no log any data if the specified termination character is not received.
SemiLucid
Posts: 3
Joined: Sat Jan 05, 2013 7:29 pm

Re: CoolTerm timestamp affecting formatting

Post by SemiLucid »

Hi Roger and sorry for the lateness of my reply. You are right, I am sending each line in chunks as I was having difficulty including the text string and a variable in one print statement. Not sure if this is a limitation of the arduino or my lack of programming knowledge.

Code: Select all

Serial.print('H'); // unique header to identify start of message
  Serial.print(",");
  Serial.print("Source Temp: ");
  Serial.print(Ssensor);
  Serial.print(", ");
  Serial.print("Sink Temp: ");
  Serial.print(Tsensor);
  Serial.print(","); // note that a comma is sent after the last field
  Serial.println(); // send a carriage return and line feed
  delay(1000);
User avatar
roger
Site Admin
Posts: 566
Joined: Fri Apr 24, 2009 12:41 am
Contact:

Re: CoolTerm timestamp affecting formatting

Post by roger »

There is a way to assemble all your information into one string, and then send that string with a single Serial.println statement. This might solve your problem.
Check out the documentation on adding strings here:
http://arduino.cc/en/Tutorial/StringAdditionOperator

I hope this helps.

Roger
SemiLucid
Posts: 3
Joined: Sat Jan 05, 2013 7:29 pm

Re: CoolTerm timestamp affecting formatting

Post by SemiLucid »

Many thanks, I will be giving this a go later.
Post Reply