Barco Projector Hex
ryanww
Posts: 196
So I am trying to get the lamp hours out of a Barco SLM R6 Performer. I don't quite understand how they are sending me the data and what I have to do to just put it in an integer. Here is their explanation of it:
Description : Read the lamp run time in hours.
Command : Command[0] \x64
Data : No data bytes.
Return data : The return data-transfer being the lamp run time in hours
consists of four data bytes. The first byte is the most
significant byte !
Formula : Lamp run time (hours)
= Data[0]*256^3 + Data[1]*256^2 + Data[2]*256 + Data[3]
Example :
Read the lamp run time of a projector with address \x01.
Suppose the lamp run time is 100 hours.
Transmit:
Start \xfe
Projector address \x01
Command[0] \x64
Checksum \x65
Stop \xff
Receive (acknowledge):
Start \xfe
Projector address \x01
Command[0] \x00
Command[1] \x06
Checksum \x07
Stop \xff
Receive (answer)
Start \xfe
Projector address \x01
Command[0] \x64
Data[0] \x00
Data[1] \x00
Data[2] \x00
Data[3] \x64
Checksum \xc9
Stop \xff
lamp run time =
\x00 * 256^3 + \x00 * 256^2 + \x00 * 256 + \x64
Thanks,
Ryan
Description : Read the lamp run time in hours.
Command : Command[0] \x64
Data : No data bytes.
Return data : The return data-transfer being the lamp run time in hours
consists of four data bytes. The first byte is the most
significant byte !
Formula : Lamp run time (hours)
= Data[0]*256^3 + Data[1]*256^2 + Data[2]*256 + Data[3]
Example :
Read the lamp run time of a projector with address \x01.
Suppose the lamp run time is 100 hours.
Transmit:
Start \xfe
Projector address \x01
Command[0] \x64
Checksum \x65
Stop \xff
Receive (acknowledge):
Start \xfe
Projector address \x01
Command[0] \x00
Command[1] \x06
Checksum \x07
Stop \xff
Receive (answer)
Start \xfe
Projector address \x01
Command[0] \x64
Data[0] \x00
Data[1] \x00
Data[2] \x00
Data[3] \x64
Checksum \xc9
Stop \xff
lamp run time =
\x00 * 256^3 + \x00 * 256^2 + \x00 * 256 + \x64
Thanks,
Ryan
0
Comments
For explanation sake, let's say it sends you:
Then calculate it this way:
It returns an unsigned 32 bit value. This would be data type LONG in NetLinx. So be sure to define your lamp time variable as a LONG data type.
Now even though the integer will be 32 bits, the value doesn't needed to be converted down to a 16 bit normal number. It will still have the same value in it correct?
Thanks again,
Ryan
Thanks,
Ryan
Thats right.
In Windows open calculator:
Start, run, type - calc, then enter.
Click the hex radio button. Type in 64, then click the Dec radio button. This is a good way for making hex/decimal decimal/hex conversions.
But I have never used the mod function that the manual says to do. I have just always added the projector address and the command hex and put the sum in the checksum and it has always worked. But when I went back through the manual, it says your supposed to do this:
Checksum byte :
The "checksum byte" is used to detect errors during
transmission or reception.
Formula :
Checksum byte = (Projector address + Command bytes + Data bytes) modulo 256
So I added this code: nChecksumAdd = ((nProjectorAddress + nCommand_0)%256)
That should work correct?
Thanks again,
Ryan
Yes that is correct. It returns the lower byte of the checksum.
Another way this could be written would be to use a bitwise AND operator:
nChecksumAdd = ((nProjectorAddress + nCommand_0) & 0xFF)
Thanks for the help!
Ryan