{"id":6282,"date":"2026-03-17T11:26:20","date_gmt":"2026-03-17T10:26:20","guid":{"rendered":"https:\/\/grodansparadis.com\/wordpress\/?p=6282"},"modified":"2026-03-17T11:26:20","modified_gmt":"2026-03-17T10:26:20","slug":"nano-second-timestamp","status":"publish","type":"post","link":"https:\/\/grodansparadis.com\/wordpress\/?p=6282","title":{"rendered":"nano second timestamp"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2026\/03\/pexels-photo-707676.jpeg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"580\" height=\"787\" data-attachment-id=\"6283\" data-permalink=\"https:\/\/grodansparadis.com\/wordpress\/?attachment_id=6283\" data-orig-file=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2026\/03\/pexels-photo-707676.jpeg?fit=958%2C1300&amp;ssl=1\" data-orig-size=\"958,1300\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;Photo by Andrey Grushnikov on &lt;a href=\\&quot;https:\/\/www.pexels.com\/photo\/black-and-white-photo-of-clocks-707676\/\\&quot; rel=\\&quot;nofollow\\&quot;&gt;Pexels.com&lt;\/a&gt;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;black and white photo of clocks&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"pexels-photo-707676\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Photo by Andrey Grushnikov on &lt;a href=&quot;https:\/\/www.pexels.com\/photo\/black-and-white-photo-of-clocks-707676\/&quot; rel=&quot;nofollow&quot;&gt;Pexels.com&lt;\/a&gt;&lt;\/p&gt;\n\" data-large-file=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2026\/03\/pexels-photo-707676.jpeg?fit=580%2C787&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2026\/03\/pexels-photo-707676.jpeg?resize=580%2C787&#038;ssl=1\" alt=\"black and white photo of clocks\" class=\"wp-image-6283\" srcset=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2026\/03\/pexels-photo-707676.jpeg?w=958&amp;ssl=1 958w, https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2026\/03\/pexels-photo-707676.jpeg?resize=221%2C300&amp;ssl=1 221w, https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2026\/03\/pexels-photo-707676.jpeg?resize=755%2C1024&amp;ssl=1 755w, https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2026\/03\/pexels-photo-707676.jpeg?resize=768%2C1042&amp;ssl=1 768w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><figcaption class=\"wp-element-caption\">Photo by Andrey Grushnikov on <a href=\"https:\/\/www.pexels.com\/photo\/black-and-white-photo-of-clocks-707676\/\" rel=\"nofollow\">Pexels.com<\/a><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The 64-bit nano second timestamp is now introduced for VSCP. This is what we often call a Unix timestamp with nano second resolution and which holds the number of nanoseconds since the epoch (<em>January 1, 1970, 00:00:00 UTC<\/em>).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The &#8220;old&#8221; format with separate bytes for year, month, day, hour, minute, second and a 32-bit microsecond timestamp was constructed that way to make it easy for very low-end devices to receive\/send time information. This is still possible as the format is preserved. But the new format will be promoted.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Note that it is still possible to send a microsecond timestamp for devices that rely on it. Just multiply the value with 1000 and set it to timestamp_ns. Relative timestamps can easily still be used.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Two header bits 9\/8 specify the frame format. They were originally set to 0b00 and would with the new format be set to 0b01. So when a new event is constructed they shoudl be set. The define <strong>VSCP_HEADER16_FRAME_VERSION_UNIX_NS<\/strong> in vscp.h does that. Priority is probably also bits that should be altered usually to <strong>VSCP_PRIORITY_NORMAL<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Helpers to convert between the two formats are available in the helper library and in vscphelper.cpp and vscp-firmware-helper.c. They are<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><em>int64_t<br>vscp_fwhlp_to_unix_ns(int year, int month, int day, int hour, int minute, int second, uint32_t microsecond);<\/em><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">and<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><em>void<br>vscp_fwhlp_from_unix_ns(int64_t unix_ns,<br>int *year,<br>int *month,<br>int *day,<br>int *hour,<br>int *minute,<br>int *second,<br>uint32_t *microsecond);<\/em><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>year<\/strong> and <strong>month<\/strong> is still available in the event defines also if nanosecond timestamps are used. This  to preserve the size of frames.  It is recommended to set year=0xffff and month=0xff when the new timestamp is used. Still the frame versin bits in the header is the main detection to use for frame type.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The 64-bit nano second timestamp is now introduced for VSCP. This is what we often call a Unix timestamp with nano second resolution and which holds the number of nanoseconds since the epoch (January 1, 1970, 00:00:00 UTC). The &#8220;old&#8221; format with separate bytes for year, month, day, hour, minute, second and a 32-bit microsecond [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[13],"tags":[],"class_list":["post-6282","post","type-post","status-publish","format-standard","hentry","category-vscp"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4raCZ-1Dk","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6282","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6282"}],"version-history":[{"count":2,"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6282\/revisions"}],"predecessor-version":[{"id":6285,"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6282\/revisions\/6285"}],"wp:attachment":[{"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6282"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}