Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7893355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:06:44+00:00 2026-06-03T07:06:44+00:00

I have inherited a project that logs data from a single board computer to

  • 0

I have inherited a project that logs data from a single board computer to a usb flash drive. The code that does this is written in C. The old code is:

  //Get the Start time
  sttime = localtime(&starttime);

  //Get the name of the drive
  sprintf(fname,"/mnt/SJ-HMIData%.4i%.2i%.2i%.2i%.2i%.2i.sjrd",(*sttime).tm_year+1900,(*sttime).tm_mon+1,(*sttime).tm_mday,(*sttime).tm_hour,(*sttime).tm_min,(*sttime).tm_sec);

  //Open an IO port with read only
  UsbFile = open(fname, O_CREAT|O_WRONLY|O_TRUNC);//Open csv on flash drive to be appended

My problem is that this relies on the time I insert the flash drive, as being the time that this program runs. How can I make it so that I don’t need the time to open the device?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:06:45+00:00Added an answer on June 3, 2026 at 7:06 am

    I suspect the date/time have nothing to do with the mounting. Most likely the flash drive is being mounted at /mnt

    The date and time is being used to assemble the name for a file to write on the mounted filesystem. If you do this periodically, it’s actually pretty common practice to put some sort of timestamp in the file name – it’s more convenient to see, and more reliable than the filesystem date fields which might be accidentally lost or if the file is moved to another system or storage medium before being analyzed.

    It doesn’t actually seem like you should be having a problem here. If you want to make a file in that style, go with the current code (it would be good to at least update the comments to what it does now, which looks to be different than what it did in the version where they were written). If you want to make a file by a different time-invariant name, then do so.

    Perhaps your flash drive is not getting automatically mounted (perhaps it doesn’t have the expected filesystem on it, or some daemon that was supposed to handle this isn’t working). That could well be the case, but the code you have posted is not involved in the mounting or failure to mount. Instead, it’s code that attempts to write to what is presumably an already mounted filesystem, or failing that, into the directory of the parent filesystem that was supposed to be used as a mount point…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have inherited a project that uses the following pattern for passing parameters from
I have a static library project that I inherited from another developer. I added
I have inherited a project from a previous developer. All the ASP .NET code
I have inherited a WiX project from a contractor that recently left. When I
I have inherited a project that uses LLBLGen Pro for the DB layer. The
I have inherited a project that has class libraries written in VB.NET, some of
I have inherited a web project that is perl based and I'm attempting to
I have inherited a web site project that makes use of a number of
I have inherited a project, that provides an order form to a customer. The
I have a few classes in a project that I inherited that are really

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.