LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

decode time stamp from c-code

Hi everybody,
 
I have a TCP/IP where I send datagrams (in c-code) to LabVIEW (which is the server).
The datagram sends with every data a time stamp in the following way: dd.mm.yyyy hh:mm:ss.zzz, where zzz stands for milliseconds. I would like to see my data in a waveform chart at the LabVIEW frontpanel, but I'm not sure how to get a continuous time stamp from the c-code. I tried it with "scan from string" (as my data enters LabVIEW as a string), and then I made a sum of the minutes (times 60) and the seconds, which works for one minute, but after one minute my time goes of course to zero again which isn't nice for the waveform chart...
Does anybody has a nice idea how to solve this? Any examples?
 
Thanks in advance!
Steffi
 
0 Kudos
Message 1 of 9
(5,537 Views)
Hi steffi,

use "scan from string" with this format code: "%d.%d.%d %d:%d:%d.%d" to get all components from your timestamp.
And you can use "Date/Time to seconds" to form all those values into a valid LabView timestamp.

Added attachment to show all this...


Message Edited by GerdW on 02-01-2008 09:57 AM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(5,533 Views)
This code should help you,
I only have a problem to read the final '.' my localization set the ',' as decimal sign and I can't get LabVIEW to change the decimal sign in this parser.

Ton



Message Edited by TonP on 02-01-2008 10:00 AM

Message Edited by TonP on 02-01-2008 10:01 AM
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 3 of 9
(5,527 Views)
Hi TonP,

nice solution - I have to get used to time formatting codes too Smiley Wink

Have you tried to include "%,;" at the start of your format string? Does it help with time formats too? Oops, I see you already opened a new thread to discuss this...


Message Edited by GerdW on 02-01-2008 10:41 AM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 9
(5,515 Views)


@GerdW wrote:

nice solution - I have to get used to time formatting codes too Smiley Wink



What I do in these cases, create a timestamp control, and change the Display Format to match what I want (using advanced formatting) in that way I most likely get the correct string.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 5 of 9
(5,509 Views)
Hello GerdW and TonP,

thank you very much for your help.
Unfortunately I can't open your vi, GerdW, as I only have LabVIEW 7.1. Maybe you can post it for 7.1 again? I don't know what type of the output I have to choose (right now I have U32 and I can't use the "Date/Time to seconds").
What default value did you set, TonP? When I tried your solution, LabVIEW says that I have too many format specifiers in my "scan from string"? Do you have an idea what my mistake is? And I can't create a constant at the output as I didn't set a default I guess.


Thank you very much,
Steffi
0 Kudos
Message 6 of 9
(5,489 Views)
Hi steffi,

you should have told us before which LV version you use...

Try to use the solution described in my first message, I will try to add an example in LV71 later.
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 9
(5,486 Views)
Hi steffi,

here's a LV7.1 version...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 9
(5,475 Views)
My code won't work in LV 7.x, the %<xxx>T is introduced in LabVIEW 8.0 if I'm correct.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 9 of 9
(5,457 Views)