Skip to content

Add a method to get _ts.tv_nsec (nanoseconds) output #38

Open
@Engineero

Description

@Engineero

minmea appears to read milliseconds from the GPS (stored as nanoseconds in _ts.tv_nsec), but the getTime method only outputs full seconds (_ts.tv_sec). It's not clear to me whether the GPS chip itself actually registers milliseconds, but either adding the nanoseconds to getTime or adding a new method to return just the nanoseconds value would help get more precise timing information to downstream applications.

I've messed with this on my own, but my CPP is weak and I don't think I'm compiling the library right to use my updates. I've added the following to GPS.cpp with signature in GPS.h.

unsigned long GPSClass::getTimeNs()
{
  return _ts.tv_nsec;
}

I think some discussion is merited on whether it makes sense to do it this way or add something to return a floating-point time value from getTime, something like:

unsigned long GPSClass::getTime()
{
  return _ts.tv_sec + _ts.tv_nsec * 1e-9;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: codeRelated to content of the project itselftype: enhancementProposed improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions