beautypg.com

3 query commands, Query commands – DVDO VP50 PRO User Manual

Page 23

background image

1.3 Query

Commands

Query commands allow an external device to determine the setting of a given control.

Building on the information presented in the previous section on constructing Command
Packets, we will discuss the method for building a Query Packet. We’ll use the example
of querying the “power” state of the unit (Command ID A1 used in the previous section).

Again, using the example of a sentence, the dialog would be:
Attention this is a query which is this long and I want to know the setting of this
function
>>pause<< [checksum – optional] I’m done talking

There are some fairly obvious similarities which can be seen between Commands and

Queries. These values are still the same for queries as they are based on ASCII look-up
equivalents:

“Attention” = Start Text or STX = 0x

02

in HEX notation

>>pause<< = Null or NUL = 0x

00

in HEX notation

“I’m Done Talking” = End Text or ETX = 0x

03

in HEX notation


If you recall that the “is a command” bytes are 3 and 0, we have defined “is a query”
bytes as 2 and 0 – or 0x32 and 0x30 in HEX notation. So, looking at the sentence and
replacing what we know, we would get:
0x02 0x32 0x30 which is this long and I want to know the setting of this function 0x00
[checksum – optional] 0x03

To query “power”, we use the same command ID found in Section 3, which we used to
set the state – “A” and “1”, or 0x41 and 0x31. Again looking at the sentence and
replacing what we know, we would get:
0x02 0x32 0x30 which is this long 0x41 0x31 0x00 [checksum – optional] 0x03

We would then calculate the length (which in this type of packet is always “3” or

0x30 and 0x33 since it must be two bytes). With this value, and if you do not need a
checksum the final packet would be:
0x02 0x32 0x30 0x30 0x33 0x41 0x31 0x00 0x03

To calculate the checksum, we take all of the values and add them up, then truncate

the result to an 8-bit number (two nybbles):
0x02 + 0x32 + 0x30 + 0x30 + 0x33 + 0x41 + 0x31 + 0x00 = 0x139

If you truncate the result by only keeping the right most two “nybbles” and you

should get 0x39 – remember these two nybbles are then assumed to be ASCII stand-in
which must be converted to HEX notation (for data expansion). The two bytes for the
checksum would be 0x33 and 0x39 so that your final query packet with checksum would
be:

0x02 0x32 0x30 0x30 0x33 0x41 0x31 0x00 0x33 0x39 0x03

23

This manual is related to the following products: