From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

receive serial data with time

Solved!
Go to solution

Hi,

 

I have a question about serial data. 

When I receive the serial data from NI-9870, is it possible to get the time when the data came in?

Can timestamp helpful?

 

Please let me know.

Thank you.

 

 

0 Kudos
Message 1 of 5
(1,046 Views)

I just get the time immediately after the message is read.  For a RS-232 bus, this is about as accurate as you will really need.  If you need more accuracy, then your device that is sending the data should timestamp things and put that information in the message.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 5
(990 Views)

Thanks for your reply!!

 

The code I attached is possible to receive serial data and save as a file that contains time and date?

I'm a beginner so not sure about my code....

 

Thank you 🙂

 

0 Kudos
Message 3 of 5
(974 Views)
Solution
Accepted by jw121

1. You should be constantly reading from the serial port to keep the buffer cleared.  You can conditionally log the data.

2. No need for the wait since the VISA Read will limit the loop rate.

3. Use the File IO functions to write your file.  Open the file before your loop and close the file after the loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 5
(954 Views)

Thank you so much!!!

Have a great day 🙂

0 Kudos
Message 5 of 5
(938 Views)