-
Couldn't load subscription status.
- Fork 605
Add kernel timestamp support #2412
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
Open
michael-betz
wants to merge
4
commits into
dotnet:main
Choose a base branch
from
michael-betz:timestamp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b73258e
Interop.cs: add GetLastTimeStamp()
michael-betz fd3f9e2
CanRaw.cs: add public GetLastTimeStamp()
michael-betz f82e5df
CanRaw: provide timestamp in overload of TryReadFrame()
michael-betz 5fd09b6
TryReadFrame(): output timestamp as DateTime instead of long
michael-betz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should be a comment that
longis correct type only because we're using this in conjunction with latest kernel. Please double check this actually works with 32-bit OS-es (if not then please make sure to display correct error message)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note, you don't need to test it - just double check what type is defined in the latest kernel's .h file, if it's
int64_tor equivalent we're good if it's platform specific likeintthen likely notThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I did some digging. In C, the ioctl call returns:
time_tcan be a signed integer of 32 bit or 64 bit, depending on the platform.In C#, I map this to a
longtype which is always a 64 bit signed integer.If I run this on a 64 bit system, everything fits bit by bit.
If I run this on a 32-bit system, the C# runtime will promote the 32-bit return value to
longproperly.Please correct me if I'm wrong.
I will look into testing this on a 32 bit system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
DateTimethe correct for this timestamp?When I see a
DateTime, I expect this represent the "real" moment when the event occurred. I also expect to be able to compare this value with otherDateTimeinstances coming from other sensors.If instead this timestamp represents the time elapsed since the OS started, IMO the
TimeSpantype would be more appropriate.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The kernel does indeed return the absolute value of the system clock when the CAN frame was received (microseconds since the 1.1.1970). So I think
DateTimeis a good type for this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know, thanks