How to send 64 bit unsigned value correctly?

66 views
Skip to first unread message

Hongbo Miao

unread,
Nov 30, 2024, 3:39:03 AM11/30/24
to IADS
Hi IADS team,

I am writing some Rust code to send message to IADS. I am using packet format 100.
When I only have IRIG time and signal values (float), the code works well.
Now I am hoping to add a unix time in nanosecond format "UnixTimestampNs", the type is "unsigned long".

I have read IADS Real Time Data Source Interface v9.2.6.pdf
It mentions how to send a 32 bit value, but not 64 bit value when use packet format 100.
The way I did is setting tag 1 and then padding zero for tag 2, and fill the 64 bit value in little endian byte order.

Here is my updated code with  "UnixTimestampNs":
let time_high = ((iads_time >> 32) & 0xFFFFFFFF) as u32;
let time_low = (iads_time & 0xFFFFFFFF) as u32;
buffer[offset..offset + 4].copy_from_slice(&time_high.to_le_bytes());
offset += 4;
buffer[offset..offset + 4].copy_from_slice(&time_low.to_le_bytes());
offset += 4;

// Write UnixTimestampNs as 64-bit value
let tag1 = 3u16;
buffer[offset..offset + 2].copy_from_slice(&tag1.to_le_bytes());
offset += 2;
buffer[offset..offset + 2].copy_from_slice(&0u16.to_le_bytes()); // Padding
offset += 2;
buffer[offset..offset + 8].copy_from_slice(&signals.timestamp_ns.to_le_bytes());
offset += 8;

// Write signal data in pairs
for (i, signals_chunk) in signals.signals.chunks(2).enumerate() {
  // Write tags for pair
  let tag2 = (4 + i * 2) as u16;
  let tag3 = (5 + i * 2) as u16;
  buffer[offset..offset + 2].copy_from_slice(&tag2.to_le_bytes());
  offset += 2;
  buffer[offset..offset + 2].copy_from_slice(&tag3.to_le_bytes());
  offset += 2;

  // Write first value
  buffer[offset..offset + 4].copy_from_slice(&signals_chunk[0].value.to_le_bytes());
  offset += 4;

  // Write second value (or 0 if this is an odd-numbered final chunk)
  let second_value = signals_chunk.get(1).map(|s| s.value).unwrap_or(0.0);
  buffer[offset..offset + 4].copy_from_slice(&second_value.to_le_bytes());
  offset += 4;
}

You can see from the screenshot, the raw data 1732955798102000000 ("Sat Nov 30 2024 08:36:38 GMT+0000" if you use https://www.unixtimestamp.com/ to convert).
However, in the display, I am using "AlphaNumeric" to display it. , I got 27164881700623488
3.jpg

Here is this AlphaNumeric's "UnixTimestampNs" value property:
1.jpg  2.jpg

I am not sure why the value “UnixTimestampNs” is not displaying correctly. Could it be due to an incorrect way of sending it, or perhaps the AlphaNumeric property is not set up correctly?

Thanks
Hongbo

mij...@curtisswright.com

unread,
Dec 3, 2024, 6:10:16 PM12/3/24
to IADS
Section 2.3.1 of the IADS Real Time Data Source documentation included with the developer kit explains the details of encapsulating 64bit time into 2 32bit words. Format 100, only supports 32bit data values; thus 64bit time must be separated into a high 32 and low 32 using 2 tag identifiers.  I might be wrong, but I believe even Format 101 requires time to be in two separate 32bit words.

Regards,
Mike

Reply all
Reply to author
Forward
0 new messages