                                                              1996.10.11
                                                            ken-ichi HAYASHI
=============================================================================

                    QV-10 SERIAL COMMUNICATIONS PROTOCOL
                  
=============================================================================

    This document describes the serial communication protocol used by
    QV-10's "DIGITAL" connecter. This information is not official. 
    Rather, it is the result of individual analysis. Please.  Do *not* 
    contact CASIO to ask questions about this information. 
   
    You should read source code of 'qvplay' too.


S E R I A L   P R O T O C O L
=============================

    * 9600baud 8 bit stop bit 1 Non parity
    * No flow control
    * RTS off
    * CTS,DTR on

CASIO's QV-10 serial cable is a level converter. It converts RS-232C 
voltage levels to QV-10's voltage levels. This voltage converter circuit
uses the electrical power supplied by the host computer's RS-232C 
connector. (V+ is CTS, V- is RTS.) To recieve digital data from QV-10, 
set the CTS terminal to ON, RTS terminal to OFF. 

On power-up, QV-10 serial communication speed defaults to 9600baud.  This
speed may be changed with the'CB' command, described below. This change
remains in effect until power off or another 'CB' command.


C O M M A N D   F O R M A T
===========================

Commands generally follow this format:
    0x05 0xXX 0xXX ... 0x06 (hex)
That is, a command flag (0x05, or ENQ) followed by command parameters,
followed by an ACK. (0x06).



C O M M A N D  L I S T
======================

    above the line: data sent to QV-10
    ---------------------------------------
    below the line: data recieved from QV-10

ASCII code values are quoted.
All other values are hex.

RESET CAMERA
============

* Reset Camera #1

    05 'QR' 06
    ------------    Reset QV10.
      06  5c    

Comment:
  This command is acceptable, in all states.
  The meaning of 0x5c is checksum.
  Checksum value is reverse bits of all sum of command bytes and
  palameter bytes .
  ~('Q(51)' +  'R(52)') = 5c

* Reset Camera #2

    05 'QE' 06
    ------------    Reset QV10.
      06  69    

Comment:
  This command does not clear the QV10's LCD.    
  The meaning of 0x69 is checksum.


QUERY PICTURE NUMBER
====================

    05 'MP' 06
    -------------- Fetch number of pictures in QV10
      06  62  XX 

Comment:
    Number of pictures in QV10 returned at XX. 
    The meaning of 0x62 is checksum.


SHOW PICTURE #XX ON LCD
======================

    05 'DA' XX 06
    ---------------- Show picture on QV10's LCD. 
      06      YY 

Comment:
    Picture number is specified by XX.
    The return byte YY is checksum. (0x7a - XX )


GET PICTURE DATA IN JPEG FORMAT
===================================
    05 'DA' XX 06 05  'DL' 06 05 'MG' 06 12              06
    --------------------------------------------------------------------
     06      YY     06   6f     06  6b     [Picture Data] [Picture Data]

    06           06                    06
    -----------------------------......---------------- 
    [Picture Data] [Picture Data]        02 00 00 03 FC


Comment:
    XX is the picture number.
    The return byte YY is checksum. (0x7a - XX).
    Return byte 6f is checksum.
    Return byte 6b is checksum.
    02 00 00 03 FC should be end marker.
    If you want to get 'fine mode' picture data in QV100,
    you must use 'Mg' instead of 'MG'.

FORMAT OF [Picture Data]
========================

    02 WW WW JJ JJ JJ JJ JJ ........ 17 SS

Comment:
 WW WW: Data Block Size (2 bytes):  (Normally 0x00 0x80, 128 bytes)
        The data preceeding the endmark(02 00 00 03 FC) is its 
        block size(under 0x00 0x80).
    JJ: Picture data. (Image Area of CAM format) 
        (Please refer to the CAM format information below).
    SS: Check sum.  Reverse bits of all sum of second byte (after 0x02) 
        of data block to before SS (0x17).

SEND JPEG FORMAT PICTURE DATA TO QV-10
======================================

    05 'MH' 06 [Picture Data] [Picture Data] 
    ------------------------------------------
      06  6a 12             06             06

    [Picture Data] [Picture Data]       02 00 00 03 FC
    ----------------------------......----------------
    06           06                   06

    05 'DJ' 06
    --------------
      06  ZZ


Comment:
    The return byte 6a is checksum.
    The return byte ZZ(normaly 06 ?) is unknown.
    [Picture Data] format is the same as above.
    The procedure of send a 'fine mode' picture for QV100 is unknown.

GET THUMBNAIL IMAGE AS "YCC" FORMAT
===================================

    05 'DA' XX 06 05 'DL' 06 05  'MK' 06 12             06
    -------------------------------------------------------------------- 
    06    YY        06  6f     06   67     [Picture Data] [Picture Data]

    06           06                   06
    ----------------------------......---------------- 
    [Picture Data] [Picture Data]      02 00 00 03 FC

Comment:
    XX: Picture Number
    YY: checksum.  (0x7a - XX)
    The return byte 6f is checksum.
    The return byte 67 is checksum.

FORMAT OF [PICTURE DATA]
========================

     02 WW WW TT TT TT TT TT ........ 17 SS

Comment:
 WW WW: Data block size. (2byte). 
        Normally 0x00 0x80 (128 bytes)
        The data preceeding the endmark(02 00 00 03 FC) is its 
        block size(under 0x00 0x80).
    TT: Picture data. (YCC format)
    SS: Check sum.
        Reverse bits of all sum of second byte (after 0x02) 
        of data block to before SS (0x17).
    Thumbnail image size is 52(W)x36(H).

    In 2808 bytes, 
        the first 1872 bytes contain Y element data(0 to 255), 
        the second 468 bytes contain Cb element data(-128 to 127), 
        the third 468 bytes contain Cr element data(-128 to 127). 

    The Y element is represented by an unsigned char.
    Cb and Cr elements are represented by signed char. 
    The formula to convert YCC to RGB, is described in "ppm.c".
    (qvplay's source file)


GET PICTURE DATA IN YCC FORMAT
==================================

    05 'DA' XX  06 05 'DL' 06 05 'ML' 06 12              06
    -------------------------------------------------------------------- 
      06      YY     06  6f     06  66     [Picture Data] [Picture Data]

    06            06                 06
    ----------------------------......---------------- 
    [Picture Data] [Picture Data]     02 00 00 03 FC


Comment:
    XX: Picture Number.
    YY: checksum. (0x7a - XX)
    The return byte 6f is checksum.
    The return byte 66 is checksum.


FORMAT OF [PICTURE DATA]
========================

    02 WW WW JJ JJ JJ JJ JJ ........ 17 SS
    
Comment:
  WW WW: Data block size. (2bytes). 
         Normaly 0x00 0x80, 128 bytes.
         The data preceeding the endmark(02 00 00 03 FC) is its 
         block size(under 0x00 0x80).
     TT: Picture Data. (YCC format)
     SS: Check sum.
         Reverse bits of all sum of second byte (after 0x02) of data 
         block to before SS(0x17).

 - When picture is 'normal mode' picture
    Picture size is 480(W)x240(H).
    All Picture Data size is 153600 byte.

    In 153600 bytes, 
        the first 115200 bytes contain Y element data(0 to 255), 
        the second 19200 bytes contain Cb element data(-128 to 127), 
        the third 19200 bytes contain Cr element data(-128 to 127). 

 - When picture is 'fine mode' picture
    Picture size is 640(W)x480(H).
    All Picture Data size is 460800 byte.

    In 460800 bytes, 
        the first 307200 bytes contain Y element data(0 to 255), 
        the second 76800 bytes contain Cb element data(-128 to 127), 
        the third 76800 bytes contain Cr element data(-128 to 127). 

    The Y element is represented by an unsigned char.
    Cb and Cr elements are represented by signed char. 
    The formula to convert YCC to RGB, is described in "ppm.c".
    (qvplay's source file)


SEND A YCC FORMAT PICTURE TO QV-10
==================================

    05 'MM' 06 [Picture Data] [Picture Data] 
    -----------------------------------------
      06  65  12            06    

    [Picture Data] [Picture Data]       02 00 00 03 FC
    ----------------------------......----------------
    06           06                   06

    05 'DN' 06 05 'DJ' 06
    -----------------------------
      06  6d    06   ZZ

Comment:
    The return byte 65 is checksum.
    The return byte 6d is checksum.
    The return byte ZZ is unknown.
    [Picture Data] format is as described above.
    The procedure of send a 'fine mode' picture for QV100 is unknown.

DELETE A PICTURE FROM QV-10 MEMORY
===================================

    05 'DF' XX ff 06
    ------------------- 
    06    YY    

Comment:
    XX: Picture Number.
    YY: checksum (0x76 - XX)

TAKE A PICTURE    
==============

    05 'DR' 06
    -------------    
      06  69  ZZ

Comment:
    You must set QV10 to REC mode.
    The return byte 69 is checksum.
    ZZ: When QV10's function SW is PLAY mode, it is 15,
        in REC mode, it is 06.

CHANGE SERIAL COMMUNICATION SPEED
=================================

    05 'CB' XX   06
    ----------------    
      06      YY    

Comment:
   XX: Select XX from the table below
   YY: checksum 

     XX(decimal(hex)): baud
         --------------------
            46(0x2e) : 9600
            22(0x16) : 19200
            11(0x0b) : 38400
             7(0x07) : 57600
             3(0x03) : 115200
         --------------------


CHANGE PICTURE ORDER
====================

    05 'DI' XX 06 05 'DY' 02 XX 06 05 'DF' XX ff 06 05 'Dj' VV 06 
    ------------------------------------------------------------------------ 
      06      YY    06         ZZ    06         WW    06      UU

Comment:
    XX: source picture number
    YY: checksum (0x72 - XX)
    ZZ: unknown
    WW: checksum (0x76 - XX)
    VV: destination picture number
    UU: checksum (0x51 - XX)

FOR EXAMPLE: XX = 5 VV =2
    picture order before: 1 2 3 4 5 6 ...
    picture order after:  1 5 2 3 4 6 ...

POWER OFF QV-10
====================

    05  'QX'  06
    --------------
      06    56 

Comment:
    Power off QV-10.
    The return byte 56 is checksum.

REPORT BATTERY VOLTAGE
======================

    05  'RB'  05  FF  FE  E6  06
    --------------------------------
      06                    83  XX

Comment:
      Fetch battery boltage.
    XX: battery voltage.
        XX/0x10 (devide by 0x10) is an approximate voltage value.
    The return byte 83 is checksum.

SHOW TEST COLOR PATTERN
=======================

    05  'DP' 06
    -------------
      06   XX 

Comment:
    Show 'test color patten' on LCD.
    The return byte XX is checksum.

REPORT SWITCH AND CCD LENS UNIT STATUS
=======================================

    05  'DS'  06
    ----------------
      06    XX  YY XX

Comment:
      Report REC/PLAY switch status and CCD  unit status.
    The return byte XX is checksum.
    YY: unknown
    ZZ: REC/PLAY switch position and CCD lens unit position.
        REC/PRAY SW,  CCD lens unit,  value of ZZ
            REC pos.     normal pos.     0x00
            REC pos.    reverse pos.     0x80
           PLAY pos.     normal pos.     0x40
           PLAY pos.    reverse pos.     0xc0

PROTECT PICTURE or UNPROTECT PICTURE
====================================

    05  'DY'  XX  YY  06
    -----------------------
      06            ZZ

Comment:
      Protect picture or unprotect picture.

    Picture number is specified by XX.
    YY: 0x00 unprotect picture
    YY: 0x0  protect picture
    The return byte ZZ is checksum.

REPORT PICTURE ATTRIBUTE
========================

    05  'DY' 02 XX  06
    -----------------------
      06          YY  ZZ

Comment:
      Get information(protected or not, normal or fine) about a picture.

    Picture number is specified by XX.
    YY: checksum
    ZZ: picture attribute.
        protect,  resolution, value of ZZ
            off       normal    0x00
            on        normal    0x01
            off       fine      0x02
            on        fine l    0x03

CHANGE IMAGE TRANSFER BLOCK SIZE 
================================

    05  'PP' XX YY  06
    -----------------------
      06          ZZ

Comment:
      Change block size to XX YY.

    Block size(default 0x00 0x80) is specified by XX YY.
    XX: higher byte
    YY: lower byte
    ZZ: checksum

SET DEFAULT PICTURE
===================

    05  'DV' XX  06
    ---------------
      06       YY

Comment:
      Set default picture shown on LCD when power on or reset.

    XX: Picture number
    YY: checksum

REPORT HARDWARE REVISION?
=========================

    05  'SU' 06
    ------------------------
      06   XX   YY ZZ WW VV

Comment:
      Get hardware revison number.(may be)

    XX: checksum
    YY: unknown
    ZZ: unknown
    WW: unknown
    VV: unknown

UNKNOWN COMMANDS
================
'DI' 'DK' 'DM' 'DQ'

'EB' 'Eb' remain memory size (in picture unit) ?
'MQ' 'Mq' picture bytesize ?
'DL'     set current picture to get out ?

SPECIAL THANKS
==============
  Itojun-san, Brahma-san, Goto-san, Mario-san
  (Thanks for their research and report about the serial protocol)
  Dr. Sadun
  (Thanks for fixup of early version of this document which 
    written in my poor English.)
  Kuwata-san
  (Thanks for the report about battery voltage.)
