Example 2 Downloading a picture

To download a picture we use command 02. The parameter is a 16 bit integer which corresponds to the number of the picture we want to download. The command thus consists of the following bytes:

00 02 02 00 09 00

Assuming that everything goes as planned, the camera will respond to this command with the response message:

00 03 00 02 xx xx ----- xx xx

(an important point to note is that the packet will be terminated with an ETB instead of an ETX except if this is the last packet of data in which case it would be an ETX

The camera keeps sending such packets until all the data has been transferred. The way we will know when the transfer is ready is that the packet will be terminated by an ETX instead of an ETB.

We will now have a look at a lower level to see the actual bytes transferred between the computer and the camera. As I mentioned previously, all commands and data must be encapsulated in the low level protocol, described at the beginning of this document.

The low level protocol does things such as attaching control characters and checksums, as well as checking for any transmission errors.

The actual sequence of bytes transmitted is as follows:
Computer sends: Camera Sends Name Description
10 02 DLE-STX Data Link Escape followed by Start of TeXt - this indicates the beginning of a packet of data to be transmitted over the serial link
00 02 02 00 09 00 This is the actual data that we want to transmit. It is the download command described above
10 03 DLE-ETX Data Link Escape followed by End of TeXt - this indicates the end of the message
01 BCC Block check character - this is a checksum computed by doing an XOR of all the data bytes as well as the final ETX character
06 ACK Acknowledge - the camera acknowledges that it has received the command correctly and understood it
10 02 DLE-STX Data Link Escape followed by Start of TeXt - this indicates the beginning of the packet of data to be transmitted to the computer
00 03 00 02 00 02 xx xx ----- xx xx This is the actual response message sent by the camera and contains a block of the first 512 bytes of picture data
10 17 DLE-ETB Data Link Escape followed by End of Transmission Block - this indicates the end of the packet, but that more packets of data are waiting to be sent
76 BCC Block check character - this is a checksum computed by doing an XOR of all the data bytes as well as the final ETX character
06 ACK Acknowledge - we acknowledge receipt of the block of the data sent by the camera
10 02 DLE-STX Data Link Escape followed by Start of TeXt - this indicates the beginning of another packet of data to be transmitted to the computer
00 03 00 02 00 02 xx xx ----- xx xx This is the actual response message sent by the camera and contains a block of the next 512 bytes of picture data
10 17 DLE-ETB Data Link Escape followed by End of Transmission Block - this indicates the end of the packet, but that more packets of data are waiting to be sent
F3 BCC Block check character - this is a checksum computed by doing an XOR of all the data bytes as well as the final ETX character
06 ACK Acknowledge - we acknowledge receipt of the block of the data sent by the camera
The above (highlited steps are repeated until all but the last packet of data have been transmitted
10 02 DLE-STX Data Link Escape followed by Start of TeXt - this indicates the beginning of another packet of data to be transmitted to the computer
00 03 00 02 nn nn xx xx ----- xx xx This is the last block of data sent by the camera and will usually contain less than 512 bytes of data
10 17 DLE-ETX Data Link Escape followed by End of Text - this indicates the end of the packet and also of the whole messae, meaning that no more packets of data remain to be sent for this picture
29 BCC Block check character - this is a checksum computed by doing an XOR of all the data bytes as well as the final ETX character
06 ACK Acknowledge - we acknowledge receipt of the block of the data sent by the camera


Page last updated on 6th June 1999 Back to first page , Back to home page