LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert date/time to HEX command and write to a bin file

Hello,

 

I have to do the following thing. I have the date/time string, let's say 08:45:23, 12.08.09, where the hour, the minutes, the seconds, the day, the month and the year represent hex number or in other words I have the following command:

Byte 0 - Byte 5

0x08; 0x45; 0x23; 0x12; 0x08; 0x09;

 

Now I want to write this command in a binary file in order to send thefile later throught serial RS232 connection.

Now, I am not sure whether I write the command in the binary file in the correct format. What I simply do is to write it as a string

("084523120809"). Is this the correct way. I guess no, because when transmitted it does not work as expected.

How can I write this string as a HEX command in the binary file?

 

Thanks for the replies in advance

IG

Message Edited by igurov on 08-12-2009 01:51 AM
0 Kudos
Message 1 of 20
(6,537 Views)
sorry for the stupid name of the thread 😞
0 Kudos
Message 2 of 20
(6,533 Views)

Hi igurov,

which string do you have to send to your RS232 device?

 

Mike

0 Kudos
Message 3 of 20
(6,531 Views)
I have to send this 0x08; 0x45; 0x23; 0x12; 0x08; 0x09 as a HEX command but it should be written in a bin file first.
0 Kudos
Message 4 of 20
(6,529 Views)
It doesn't make much sense that the hex value would have the same digit values as the decimal value. That would mean it's two different numbers. For example, decimal 23 is hex 0x17, not hex 0x23. Hex 0x23 is decimal 35. Are you sure about those hex values?
0 Kudos
Message 5 of 20
(6,484 Views)
yes, i am sure. And it is just a pattern, so actually it does make sense. And does this fact make a difference for the writting and transmitting. I think it is exactly the same.
Message Edited by igurov on 08-13-2009 12:44 AM
0 Kudos
Message 6 of 20
(6,468 Views)
Do you know the difference between decimal and hex values? It's not the same, that the whole point, and it's why it doesn't make sense. Decimal 32 is not the same as hex 32. These are two different values, even though they both have the digits "3" and "2". The hex value will be the same as the decimal value up to the value of 9. In your example the hour is 8. In decimal this is 8, in hex this is 8. The minutes is 45. That's decimal. In hex, this is 2D, not 45, as you claim in your example. Hex 45 is a completely different number (and a completely different "pattern").
0 Kudos
Message 7 of 20
(6,442 Views)

Hi smercurio,

 

maybe igurov has to send BCD numbers? Smiley Wink

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 20
(6,436 Views)

GerdW wrote: 

maybe igurov has to send BCD numbers? Smiley Wink


Well, that would certainly make more sense.

0 Kudos
Message 9 of 20
(6,430 Views)

I know exactly what the difference between decimal and hex is!? But I am not sure whether you understand what I really want.

I have a specific requirements and mainly that I have to write the string of date/time as hex value in a file and then send it via serial connection. Please, tell me, where in the whole story sth does not make sense to you.

Or maybe a command like byte0- byte6 0x19;0x08;0x09;0x07;0x53;0x24 does not make sense to you !? 

0 Kudos
Message 10 of 20
(6,376 Views)