[Solved] I need Time.timeStr without line feed

Im trying to make my log file a bit neater and the Time.timeStr() is messing it up!

Its adding a 0x0a new line to the end of the time string. Ive tried going through everything in netbeans to find where it comes from… but really its over my head and i have no idea where it comes from.

this is how i use it

dbFile.print(Time.timeStr());

it doesn’t add a carriage return just a new line, which displays OK if i open the log in notepad but not when i print the log in a serial terminal.

Try dbFile.print("1234567890");

Does it put 0x0a at the end still?

Nope, that works normal with no line feed… i think its a leftover from the unix time but im not sure… had a dig around and couldnt find it being added but maybe its added by the server so the spark knows the end of the array? i thought unix time was a standard 32bytes so it shouldnt need and ending?

As a work around i made this in my spark_wiring_print.cpp

size_t Print::printUntil(const String &s , uint8_t terminator)
{
  size_t n = 0;
  for (uint16_t i = 0; i < s.length(); i++) {
    if (s[i] != terminator) n += write(s[i]);
    else break;
  }
  return n;
}

and this in spark_wiring_print.h

size_t printUntil(const String & , uint8_t terminator); //workaround for timeStr linefeed

and i use this to print the time string without the linefeed

dbFile.printUntil(Time.timeStr(), 0x0a);

Hope someone else will find this helpful… its really a modified cut and paste job from the readStringUntil :slight_smile:

Oh yeah, its looking good now…

>Clock Not Set - *** Spark Core Booted up ***
>Sun Jun 22 20:54:55 2014 - Entered Program Mode
>Sun Jun 22 20:55:13 2014 - New database created
>Sun Jun 22 20:56:14 2014 - Added - User Number: 1 - Joe Bloggs
>Sun Jun 22 20:56:51 2014 - Added - User Number: 2 - Mary Jane
>Sun Jun 22 20:57:30 2014 - Added - User Number: 3 - Barry Biggs
>Sun Jun 22 20:58:03 2014 - Added - RFID to User number: 1
>Sun Jun 22 20:58:18 2014 - Added - RFID to User number: 2
>Sun Jun 22 20:58:31 2014 - Added - RFID to User number: 3
>Sun Jun 22 20:59:12 2014 - Added - Fingerprint to User number: 1, Address: 1
>Sun Jun 22 20:59:34 2014 - Added - Fingerprint to User number: 1, Address: 2
>Sun Jun 22 20:59:49 2014 - Added - Fingerprint to User number: 2, Address: 3
>Sun Jun 22 21:00:11 2014 - Added - Fingerprint to User number: 2, Address: 4
>Sun Jun 22 21:00:30 2014 - Added - Fingerprint to User number: 3, Address: 5
>Sun Jun 22 21:00:48 2014 - Added - Fingerprint to User number: 3, Address: 6
>Sun Jun 22 21:01:01 2014 - Master Fingerprint added
>Sun Jun 22 21:01:17 2014 - Exit Program Mode
>Sun Jun 22 21:01:28 2014 - Access Granted - User Number: 1 - Joe Bloggs
>Sun Jun 22 21:01:32 2014 - Access Granted - User Number: 1 - Joe Bloggs
>Sun Jun 22 21:01:36 2014 - Access Granted - User Number: 2 - Mary Jane
>Sun Jun 22 21:01:40 2014 - Access Granted - User Number: 2 - Mary Jane
>Sun Jun 22 21:01:45 2014 - Access Granted - User Number: 3 - Barry Biggs
>Sun Jun 22 21:01:49 2014 - Access Granted - User Number: 3 - Barry Biggs
>Sun Jun 22 21:01:54 2014 - Denied fingerprint Access - Unknown Finger
>Sun Jun 22 21:01:56 2014 - Denied fingerprint Access - Unknown Finger
>Sun Jun 22 21:01:59 2014 - Denied fingerprint Access - Unknown Finger
>Sun Jun 22 21:02:02 2014 - Denied fingerprint Access - Unknown Finger
>Sun Jun 22 21:02:27 2014 - Entered Program Mode
>Sun Jun 22 21:04:28 2014 - Updated - User Number: 1 - Joe Bloggs
>Sun Jun 22 21:05:03 2014 - Doorbell Pressed
>Sun Jun 22 21:05:55 2014 - Denied fingerprint Access - Unknown Finger
>Sun Jun 22 21:06:02 2014 - Denied fingerprint Access - Unknown Finger
>Sun Jun 22 21:06:10 2014 - Access Granted - User Number: 2 - Mary Jane
2 Likes

Don’t mean to dig up an old thread, this was issue was raised again recently in https://github.com/spark/firmware/issues/336.

That’s great to know it wasn’t just me :slight_smile:

i was planning on coming back to this project soon so good timing really :smile:

1 Like

Hello,

I am very new to this community so first off all my apologies for bumping this topic back to the top. I have recently, last night actually, run into the new line issue while creating a log file. It looks fine in notepad but rears it’s ugly head when importing to Excel for example.

It appears there was some attempt to fix this. Did it get fixed and then got broken again? Is it still waiting to included in some upcoming update? Am I using old files?

I am using the Web IDE, I guess I should also mention I am using the Core, anxiously awaiting the arrival of my Photon. :smile:

Thanks for any help in advance,

Hi @Jseiler! This problem has been fixed in the code, but isn’t yet available for the core. The release for the Core will be later this month.

Thank you very much. I will look forward to this update. In the mean time I’ve figured out a work around.

1 Like