Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log Names #160

Closed
Knoodle3 opened this issue Oct 1, 2013 · 9 comments
Closed

Log Names #160

Knoodle3 opened this issue Oct 1, 2013 · 9 comments

Comments

@Knoodle3
Copy link

Knoodle3 commented Oct 1, 2013

OpenLog creates a new log file each time it powers up. It will use the next sequential number so you have LOG00008.TXT then LOG00009.TXT if you don't erase anything.

I find that if you erase the log files with a computer and then put the chip back into OpenLog it will start with the last number (00009) instead of moving on to the next (00010). Now if I move the newly created logs to my computer I will have two 00009 logs. Then all of the logs need to be renumbered. You can cycle the power once to create a fake log that can be tossed (until someone forgets). You could also leave a copy of the last log on the chip (waste of space) or create a blank one (waste of time).

I am not touching the config file (57600,36,3,0,1,1,0) or anything, just - creating a few logs by cycling the power, moving the chip to a computer, erasing the logs, moving the chip back to OpenLog, creating a few more logs.

@dlkeng
Copy link

dlkeng commented Oct 26, 2013

Actually, the change in behavior you're requesting is quite easy to make. In the newlog() function, a minor rearrangement of the code in lines 428 through 454 (from v3.21) would give you the desired operation, as follows:

static char new_file_name[13];
sprintf_P(new_file_name, PSTR("LOG%05d.TXT"), new_file_number); //Splice the last file number into this file name
//Try to open file and see if it is empty. If so, use it.
if (newFile.open(&currentDirectory, new_file_name, O_READ))
{
  if (newFile.fileSize() == 0)
  {
    newFile.close();        // Close this existing empty file we just opened.
    return(new_file_name);  // Use existing empty file.
  }
  newFile.close(); // Close this used existing file we just opened.
}
while (1)
{
  //Try the next number
  new_file_number++;
  if (new_file_number > 65533) //There is a max of 65534 logs
  {
    NewSerial.print(F("!Too many logs:2!"));
    return(0); //Bail!
  }
  sprintf_P(new_file_name, PSTR("LOG%05d.TXT"), new_file_number); //Splice the new file number into this file name
  //Try to create file, if success (file did not exist), then break
  if (newFile.open(&currentDirectory, new_file_name, O_CREAT | O_EXCL | O_WRITE))
  {
    break;
  }
}

The only side-effect is that the first log file generated on a new OpenLog unit off the production line would be "LOG00001.TXT" instead of "LOG00000.TXT". The user would never notice this, but this might cause a minor problem with production testing.

@Knoodle3
Copy link
Author

Thanks for the reply. I have not been able to locate the source code. Can
you send it to me?

Dave

On Fri, Oct 25, 2013 at 5:52 PM, dlkeng [email protected] wrote:

Actually, the change in behavior you're requesting is quite easy to make.
In the newlog() function, a minor rearrangement of the code in lines
428 through 454 (from v3.21) would give you the desired operation, as
follows:

static char new_file_name[13];
sprintf_P(new_file_name, PSTR("LOG%05d.TXT"), new_file_number); //Splice the last file number into this file name
//Try to open file and see if it is empty. If so, use it.
if (newFile.open(&currentDirectory, new_file_name, O_READ))
{
if (newFile.fileSize() == 0)
{
newFile.close(); // Close this existing empty file we just opened.
return(new_file_name); // Use existing empty file.
}
newFile.close(); // Close this used existing file we just opened.
}
while (1)
{
//Try the next number
new_file_number++;
if (new_file_number > 65533) //There is a max of 65534 logs
{
NewSerial.print(F("!Too many logs:2!"));
return(0); //Bail!
}
sprintf_P(new_file_name, PSTR("LOG%05d.TXT"), new_file_number); //Splice the new file number into this file name
//Try to create file, if success (file did not exist), then break
if (newFile.open(&currentDirectory, new_file_name, O_CREAT | O_EXCL | O_WRITE))
{
break;
}
}

The only side-effect is that the first log file generated on a new OpenLog
unit off the production line would be "LOG00001.TXT" instead of
"LOG00000.TXT". The user would never notice this, but this might cause
a minor problem with production testing.


Reply to this email directly or view it on GitHubhttps://github.com//issues/160#issuecomment-27135835
.

Dave Newland
NavSim Technology Inc.
www.navsim.com

@dlkeng
Copy link

dlkeng commented Oct 26, 2013

Go to https://github.com/sparkfun/OpenLog

On the right side of the screen is a column of items. The bottom item is a button labeled Download ZIP.
Click that to download it and in that zip file is the source file: OpenLog_v3.ino

@nseidle
Copy link
Member

nseidle commented Oct 30, 2013

This is a simple enough change to make. I'll try to roll it into the next version.

@dlkeng
Copy link

dlkeng commented Oct 30, 2013

Another side-effect of the suggested changes, that the user might notice, is item # 4 on the "set" submenu: "Reset new file number". When this is done with the above suggested changes in place, the response "New file number reset to zero" is not true anymore - it will be reset to one (unless an empty file with the name of "LOG00000.TXT" exists on the SD card, in which case it will be reused).

@Knoodle3
Copy link
Author

I have another suggestion or two.

The documentation doesn't seem to mention the maximum number allowed for
escape characters or what happens if you put in a higher number. From
testing it seems that 10 is the most that will work.

I was hoping that zero would disable the escape to command mode feature. It
does not. When logging raw binary data from GPS units we are getting lots
of tripple characters of every type. I don't know what the worst case is so
I would like to turn off the escape feature.

Thanks,
Dave

On Fri, Oct 25, 2013 at 5:52 PM, dlkeng [email protected] wrote:

Actually, the change in behavior you're requesting is quite easy to make.
In the newlog() function, a minor rearrangement of the code in lines
428 through 454 (from v3.21) would give you the desired operation, as
follows:

static char new_file_name[13];
sprintf_P(new_file_name, PSTR("LOG%05d.TXT"), new_file_number); //Splice the last file number into this file name
//Try to open file and see if it is empty. If so, use it.
if (newFile.open(&currentDirectory, new_file_name, O_READ))
{
if (newFile.fileSize() == 0)
{
newFile.close(); // Close this existing empty file we just opened.
return(new_file_name); // Use existing empty file.
}
newFile.close(); // Close this used existing file we just opened.
}
while (1)
{
//Try the next number
new_file_number++;
if (new_file_number > 65533) //There is a max of 65534 logs
{
NewSerial.print(F("!Too many logs:2!"));
return(0); //Bail!
}
sprintf_P(new_file_name, PSTR("LOG%05d.TXT"), new_file_number); //Splice the new file number into this file name
//Try to create file, if success (file did not exist), then break
if (newFile.open(&currentDirectory, new_file_name, O_CREAT | O_EXCL | O_WRITE))
{
break;
}
}

The only side-effect is that the first log file generated on a new OpenLog
unit off the production line would be "LOG00001.TXT" instead of
"LOG00000.TXT". The user would never notice this, but this might cause
a minor problem with production testing.


Reply to this email directly or view it on GitHubhttps://github.com//issues/160#issuecomment-27135835
.

Dave Newland
NavSim Technology Inc.
www.navsim.com

@dlkeng
Copy link

dlkeng commented Nov 10, 2013

It looks like it is hard-coded from 1 to 9 escape characters. See lines 2061 to 2068:

  while(choice > 9 || choice < 1)
  {
    NewSerial.print(F("\n\rEnter number of escape characters to look for (1 to 9): "));
    while(!NewSerial.available()); //Wait for user to hit character
    choice = NewSerial.read() - '0';
  }

  setting_max_escape_character = choice;

It is stored in a byte variable, so this code could be changed to support a larger value up to about 254.

@nseidle
Copy link
Member

nseidle commented Dec 14, 2013

To address the log name issue, I moved

new_file_number++;

towards the end of newlog()

    if(new_file_number > 65533) //There is a max of 65534 logs
    {
      NewSerial.print(F("!Too many logs:2!"));
      return(0); //Bail!
    }
}
newFile.close(); //Close this new file we just opened

new_file_number++; //Increment so the next power up uses the next file #

//Record new_file number to EEPROM
lsb = (byte)(new_file_number & 0x00FF);
msb = (byte)((new_file_number & 0xFF00) >> 8);

EEPROM.write(LOCATION_FILE_NUMBER_LSB, lsb); // LSB

This works and only adds one variable increment which takes 6 bytes. This fix also starts the logs at 0. dlk's solution adds an sprintf() which takes 80 bytes. Double check me but I think this will work. Will go into v3.3.

@nseidle
Copy link
Member

nseidle commented Dec 14, 2013

Log file name increments correctly in v3.3.

@nseidle nseidle closed this as completed Dec 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants