Barco Hex Conversion
nhighton
Posts: 18
Hi all,
I'm working with a Barco projector and struggling with lamp hours feedback. The commands manual states that the lamp hours figure is returned from the projector in the following fashion:
Start, Projector Address, Command[0], Data[0], Data[1], Data[2], Data[3], Checksum, Stop
which respectively is:
$FE,$01,$64,$00,$00,$00,$64,$C9,$FF
So data bits are:
$00,
$00,
$00,
$64
the formula to calculate lamp hours in hours is '$00 * 256^3 + $00 * 256^2 + $00 * 256 + $64'
How do I convert the hex values into a more readable data format, int or long for example?
Thanks,
Nick
I'm working with a Barco projector and struggling with lamp hours feedback. The commands manual states that the lamp hours figure is returned from the projector in the following fashion:
Start, Projector Address, Command[0], Data[0], Data[1], Data[2], Data[3], Checksum, Stop
which respectively is:
$FE,$01,$64,$00,$00,$00,$64,$C9,$FF
So data bits are:
$00,
$00,
$00,
$64
the formula to calculate lamp hours in hours is '$00 * 256^3 + $00 * 256^2 + $00 * 256 + $64'
How do I convert the hex values into a more readable data format, int or long for example?
Thanks,
Nick
0
Comments
You'll need to replace 'result(x)' with your data bytes, but the multipliers should be correct.
lampRunTime = (result(11) * 16777216) + (result(12) * 65536) + (result(13) * 256) + result(14)
Also I should have pointed out that in my example I have removed the 1st 3 bytes of the string, that is why I am starting at byte 1 instead of 4.
Edit: The time is reported in hours isn't it? (when using $64 to resuest lamp hours) I can't imagine the lamp hours on a projector ever getting above 1 million let alone 16 mil.
Based on what has been posted previously, the following should work for you (brackets for clarity):
+1 on that. You're speaking to a computer so speak like a computer.
I've been speaking in a voice-generated-voice to the computer for the past few hours, but I can't say it's made any difference.
Jokes aside, I agree. If you're tryin to converse with someone/-thing the most accessible way to do so is in their native language. Only if you can't should you look at other ways. (Say Java)
Doing it that way makes your program run faster and more efficient as well.
//Converting Auser's function
define_function long ParseLampHours(char cData[])
{
stack_var long lLampHours
STRING_TO_VARIABLE(lLampHours,"$E3,cData",1)
return lLampHours
}