LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert hex string to time stamp?

Hello everyone..

 

I am currently working on a project in which I have to read the data from a unit and display that data using LabVIEW. I am using serial communication for reading the data. The read data is in hex format. 

 

Now, I want to convert this hex string to a time stamp value. I am reading total 16 bytes. How to convert this hex data to a time stamp value. I have developed a VI. But I want to know that the displayed time stamp is correct or not? Or suggest me some other solution. 

 

I am using LabVIEW 2011.

 

Thanks & Regards,

Manisha

0 Kudos
Message 1 of 7
(7,238 Views)

Hi mancan,

                  As Iam using LV2009 Iam unable to open your example.Anyway for converting hex to time stamp

       

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks as kudos only:)
Message 2 of 7
(7,235 Views)

Thanks Danil for ypur quick reply. 

 

I have tried that but it is giving me error. I have posted my VI with LabVIEW 2009 and the error. Please suggest me if am wrong.

 

Thanks & Regards,

Manisha

Download All
0 Kudos
Message 3 of 7
(7,231 Views)

Please tell us the constitution of the string and we can then try and extract some meaningfull data out of it.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 4 of 7
(7,197 Views)

Thanks Danil and Ace,

 

I have solved that problem by modifying the code at hardware side.

 

Thanks & Regards,

Manisha

0 Kudos
Message 5 of 7
(7,195 Views)

A very late response, however for reference, a solution to your problem would be similar to the example I'm attaching.  In this example, a timestamp in generated and converted to date/time. All of the fields are converted to an I8 except for the fractional seconds.  That field is multiplied by 100 (2 decimal places) and then converted to an I8.  Each value is cast to a string, and then concatinated.  The cast process will create a the equivilent hex string.

Converting from hex string to timestamp is simplified if your string is an U8 or I8 (for time it should be the same thing since there shouldn't be negative time) because you can use string to byte array.  The byte array will now each time value seperated in the same order of the string.  Using the index array, and the date/time to seconds, you can bundle each element to create your timestamp.  The seconds to date/time can be used with the bundle to fill in any missing fields.  For example, if you timestamp only has hour:min:sec:hsec, you can still have todays date in your timestamp. Sorry I didn't see this post till now, however I hope this helps you in the future.

Message 6 of 7
(7,061 Views)

Thank you Mr_Steve.

 

Thanks for this solution. But I have already done modification at hardware side for this problem. But this will definitely help me in future.

 

Thanks & Regards,

Manisha

0 Kudos
Message 7 of 7
(7,049 Views)