
History
    98/07/24 First Edition
    98/08/24 Modifies the description error for u_del/u_dir/u_download/u_upload/u_mkdir/u_rmdir/u_chdir

Title: Interface (remote shell) manual for communication between devices


The manual describes a remote shell that establishes an interface communication between onHand/Ruputer and PC terminal.

--------------------------------------------------------------------------------
1. Module Description

1.1 Module Overview

                                      | 
                                      v
                      +-------------------------------+ 
                      | Communication initialization  | 
                      | Data initialization           | 
                      +---------------+---------------+ 
                                      | 
                                      v
                            +-------------------+ 
                            |  Negotiation      | 
                            |  process          | 
                            +---------+---------+ 
  +-----------------------------+     | 
  |                             v     v
  |                         +-------------------+ 
  |                         | Command acceptance| 
  |                         |                   | 
  |                         +---------+---------+ 
  |                                   | 
  |                                   v
  |                         +-------------------+ 
  |                         | Function select   | 
  |                         |                   | 
  |                         +---------+---------+ 
  |                                   | 
  |             +---------------------+---------------------+ 
  |             v                     v                     v
  |   +-------------------+ +-------------------+ +-------------------+ 
  |   |  Each function    | |  Each function    | |  Each function    | 
  |   |           process | |            process| |            process| 
  |   +---------+---------+ +---------+---------+ +---------+---------+ 
  |             |                     |                     | 
  |             +---------------------+---------------------+ 
  |                                   v
  |                         +-------------------+ 
  |                         |      Response     | 
  |                         |    transmision    | 
  |                         +---------+---------+ 
  |                                   | 
  |                                   v
  |                  NO     /------------------\
  +----------------------- /         END ?      \
                           \                    /
                            \------------------/
                                      | YES
                                      v
                            +-------------------+ 
                            |        Exit       | 
                            |                   | 
                            +-------------------+ 


  The chart above shows a flow from the RSHELLD activation to its end.
  After the RSHELLD activation, command acceptance, function process, and response transmission are repeated.
  Additionally, since UPLOAD/DOWNLOAD is a special process using the X-MODEM protocol, a response exceptionally returns before the X-MODEM communication.
  RSHELLD successfully exits when an END command is received. But if an error (command error, response error, or X-MODEM error) is found, an error code is set in a return code for restoration.

  The following chart describes several functions that require special processes.


2.2 DIR

  This function requires a special process in sending the obtained directory data.
  The process flow is as follows:

                             | 
      +-----------------+    | 
      |                 v    v
      |             +-------------------+ 
      |             | Command acceptance| 
      |             |                   | 
      |             +---------+---------+ 
      |                       | 
      |                       v
      |             /------------------\     Subcommand = 2
      |            / Subcommand number  \-------------------+ 
      |            \                    /                   | 
      |             \------------------/                    | 
      |                       |   Subcommand = 1            | 
      |                       v                             | 
      |             +-------------------+                   | 
      |             |    dos_fnd_first  |                   | 
      |             |                   |                   | 
      |             +---------+---------+                   | 
      |                       | File retrieval can be       | 
      |                       | attempted up to five times  | 
      |                       |     +-----------------------+ 
      |                       v     v
      |             +-------------------+ 
      |             |    dos_fnd_next   | 
      |             |                   | 
      |             +---------+---------+ 
      |                       | 
      |                       v
      |             +-------------------+ 
      |             |     Response      | 
      |             |  directory data   | 
      |             |   Transmission    | 
      |             +---------+---------+ 
      |                       | 
      |                       v
      |  5 or more  /-------------------\
      +------------/    Number of search \
                   \       files        /
                    \------------------/
                              | Less than 5
                              v
                    +-------------------+ 
                    |        Exit       | 
                    |                   | 
                    +-------------------+ 


  A DIR command limits the attempt of obtaining/sending the directory data up to five times.
  Upon receiving this command, a file is searched five times, then the file data is sent to the terminal as a response, thereafter waiting for the next DIR command.
  In this process, a subcommand number is first used to identify whether this command is a search or not. If the subcommand number is 1, this is the first search, if it is 2, it is a search of the second time or more.
  This exchange of data between the command and the response finishes when the number of searched files becomes less than 5 (no searched file).


2.3     UPLOAD

(1)  File check

                         | 
                         v
                 /--------------\   FAILED
                /     dos_open   \--------------+ 
                \                /              | 
                 \--------------/               | 
                         |  SUCCEED             | 
                         v                      v 
        FAILED   /--------------\        /--------------\   FAILED
     +----------/     dos_crtmp  \      /     dos_creat  \-----------+ 
     |          \                /      \                /           | 
     |           \--------------/        \--------------/            | 
     |            SUCCEED|                         | SUCCEED         | 
     |                   | <-----------------------+                 | 
     |                   |                                           | 
     v                   v                                           v
    ERROR                O.K.                                       ERROR

  UPLOAD uses X-MODEM protocol for a file transmission. First, the name of the searched file must be checked to determine whether a file can be created with that name. 
  After that result is sent as a response, a communication through X-MODEM protocol is initiated.
  RSHELLD performs this file check twice so that UPLOAD can be called as a one shared function.
  If the specified file name is invalid and a file check is made during the UPLOAD process, RSHELLD cannot return an error data to the terminal.
  For this reason, RSHELLD makes a file check once and removes the created file before calling UPLOAD function.


(2)  Drive space check

  During uploading, a file writing may run out of the free drive space. To avoid this, RSHELLD uses dos_dfspace, a DOS function, to check the free drive space before calling UPLOAD.


(3)  Data blocking
                
+---------------------------------------------------------------------------------------+ 
| 128 bytes| 128 bytes| 128 bytes| 128 bytes| 128 bytes| 128 bytes| 128 bytes| 128 bytes| 
+---------------------------------------------------------------------------------------+ 
|<------------------------------------------------------------------------------------->|
                             8 blocks/1024 bytes

  To increase the transmission speed, UPLOAD uses a data blocking. The structure of that blocking is shown above.
  One data block size for X-MODEM protocol is 128 bytes. Writing this block every time causes a significant time loss.
  Thus, received data is reorganized to be 8 blocks/1024 bytes before a file writing.


2.4  DOWNLOAD

(1)  Receiving a NAK (negative acknowledge)
  In X-MODEM protocol, the file receiver (UPLOAD) sends a NAK. When the file sender receives the NAK, a file transmission starts.
  However, if DOWNLOAD is called as a process (not by RSHELLD but by another application) and UPLOAD and DOWNLOAD are not synchronized, the NAK that should be the first task of the process may be missing.
  To avoid this, DOWNLOAD skips reading other data unless it receives the NAK, the first task. However, if receiving buffers are not cleared and DOWNLOAD is called, a communication may be started by even a garbage NAK stored in the buffers.
  For prevention, before calling UPLOAD/DOWNLOAD, some kinds of measure, such as a negotiation that calls for synchronization must be taken to clear all receiving buffers.


(2)  Data blocking/file check

 Like UPLOAD, DOWNLOAD also makes a file check to carry out a data blocking and determine whether a received file name is valid to open it. 

--------------------------------------------------------------------------------
***** Detailed description *****
      An interface used to communicate this device (onHand/Ruputer) and a terminal is described below. The available functions are as follows:
    
        end         ...Exits this utility
        copy        ...Copies a file
        del         ...Deletes a file
        dir         ...Obtains directory data in flash memory
        format      ...Formats flash memory disk
        ren         ...Renames a file
        reset       ...Reset
        ver         ...Obtains its system version
        download    ...Copies a file in the disk in onHand/Ruputer to PC
        upload      ...Copies a file in PC to the disk in onHand/Ruputer
        mkdir       ...Creates a new directory
        rmdir       ...Deletes a directory
        chdir       ...Changes current directory
        gtime       ...Obtains time
        stime       ...Sets time
        gpower      ...Detects battery voltage
        chkdsk      ...Checks the consistence of flash memory

***** Interface *****
    0.Negotiation

  For the commands between a terminal (PC) and this device (onHand/Ruputer), the terminal (PC) is always the master while this device (onHand/Ruputer) is the slave. It is thus recommendable to activate the program on this device (onHand/Ruputer) before the program on the PC is activated. However, considering realistic settings, a more flexible interface is required. For this reason, a sequence that checks the conditions between this device (onHand/Ruputer) and the terminal (PC) should be provided before moving to the actual sequence.

      1) The device (onHand/Ruputer) sends two bytes (CR+LF) in a row at an interval of 0.5 seconds.
      2) When the terminal (PC) receives the two bytes data (CR+LF), it sends three bite data, 'Erg'.
      3) Upon receiving the three bite data 'Erg', the device (onHand/Ruputer) sends an ACK code.

      If the device does not receive 'Erg' successfully within one second since its sending in 3) above, the procedure is repeated from 1).



    1.General types
        a.1) Command  (terminal(PC)  ->  device(onHand/Ruputer))
            15                 7              0
            +-----------------+----------------+
            | Subcommand number| Command number|
            +-----------------+----------------+
            |           Data lengt             |
            +----------------------------------+
            |           Data                   |
            |                                  |
            =                                  =
            |                                  |
            +-----------------+----------------+
                              |  Check SUM     |
                              +----------------+
 
        a.2) Command check  (device(onHand/Ruputer)  ->  terminal(PC))
                ACK / NACK
           
            
        b.1) Response(deivce(onHand/Ruputer)  ->  terminal(PC))
            15                  7             0
            +------------------+---------------+
            | Subcommand number| Command number|
            +------------------+---------------+
            |            Data length           |
            +----------------------------------+
            |            Data                  |
            |                                  |
            =                                  =
            |                                  |
            +------------------+---------------+
                               |  Check SUM    |
                               +---------------+

        b.2) Response check  (terminal(PC)  ->  device(onHand/Ruputer))
                ACK / NACK

  Data length is a bite count of the entire packet which does not include sum, but does 'command number' and 'data length'. Sum indicates one's complement of a sum by bite for this area.
  The receiver provides a one second timer from receiving a command number to receiving the entire packet. If a receiving error, timeout, or sum error occurs, a NACK returns to the sender. In this case, the sender attempts to send the entire packet again. If the sender receives (sends) NACKs five times in a row, a communication error returns to the caller. If it successfully receives the entire packet, an ACK returns to the sender. A timer on the sender of command/response from a packet transmission to receiving an ACK/NACK should be set to two seconds.

  As explained above, a sending/receiving process is proceeded packet by packet as verifying a normal communication. This method is mainly designed for an infrared communication usually with a lower communication quality. However, a timer from a command to a response is not used since required times for each command vary and are difficult to estimate.
  The following each command description does not provide these ACK/NACK procedures.
      Result statuses during response are defined as follows:
                0x0000      Normal termination
                0xfffe      Voltage drop
                0xfffc      An error detected by BIOS 
                Others      An error detected by PS-DOS


    2.Communication data format for each command
        2.0  end    ...Exits the utility
            a)  Command  (Terminal(PC)  ->  device(onHand/Ruputer))
                    15                     7                  0
                    +---------------------+--------------------+
                0   |(2)Subcommand number |(1)  Command number |
                    +---------------------+--------------------+
                1   |            (3)Data length                |
                    +---------------------+--------------------+
                                          |  Check  SUM        |
                                          +--------------------+

                    (1)  Command number
                        Specify 0.
                    
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        4


            b)  Response (device(onHand/Ruputer)  ->  terminal(PC))
                    15                    7                 0
                    +--------------------+-------------------+
                0   |(2)Subcommand number|(1)Command number  |
                    +--------------------+-------------------+
                1   |       (3)Data length                   |
                    +----------------------------------------+
                2   |  (4)Result status                      |
                    +--------------------+-------------------+
                                         |  Check  SUM       |
                                         +-------------------+
                    
                    (1)  Command number
                        Specify 0.
                
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        6
                
                    (4)  Result status
                        0: Normal termination,  Other than 0: Abnormal termination
                    



        2.1  copy   ...Copies a file
            a)  Command  (terminal(PC)  ->  device(onHand/Ruputer))
                    15                    7                 0
                    +--------------------+-------------------+
                0   |(2)Subcommand number|(1)Command number  |
                    +--------------------+-------------------+
                1   |  (3)Data length                        |
                    +----------------------------------------+
                2   |  (4)Length of the source file name     |
                    +----------------------------------------+
                3   |  (5)Length of the target file name     |
                    +----------------------------------------+
                4   |  (6)Source file name                   |
                    +-                                      -+
                5   |       (ASCIZ character string)         |
                    +-                                      -+
                    =                                        =
                    +-                                      -+
                    |                                        |
                    +----------------------------------------+
                    |  (7)Target file name                   |
                    +-                                      -+
                    =       (ASCIZ character string)         =
                    +-                                      -+
                    |                                        |
                    +-------------------+--------------------+
                                         |  Check  SUM       |
                                         +-------------------+

                    (1)  Command number
                        Specify 1.
                    
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        -

                    (4)  Length of the source file name
                        Specify the length of the source file name.
                        The file name should be specified in a full-path,
                        and has to be 64 bytes at maximum including NULL characters.

                    (5)  Length of the target file name
                        Specify the length of the target file name.
                        The file name should be specified in full-path,
                        and has to be 64 bytes at maximum including NULL characters.

                    (6)  Source file name
                        Specify the source file name.

                    (7)  Target file name
                        Specify the target file name.


            b)  Response (device(onHand/Ruputer)  ->  terminal(PC))
                    15                    7                 0
                    +--------------------+-------------------+
                0   |(2)Subcommand number|(1)Command number  |
                    +--------------------+-------------------+
                1   |  (3)Data length                        |
                    +----------------------------------------+
                2   |  (4)Result status                      |
                    +--------------------+-------------------+
                                         |  Check  SUM       |
                                         +-------------------+
                    
                    (1)  Command number
                        Specify 1.
                
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        6
                
                    (4)  Result status
                        0: Normal termination,  Other than 0: Abnormal termination

                    
        2.2  del    ...Deletes a file
            a)  Command  (terminal(PC)  ->  device(onHand/Ruputer))
                    15                    7                  0
                    +--------------------+--------------------+
                0   |(2)Subcommand number|(1)  Command number |
                    +--------------------+--------------------+
                1   |       (3)Data length                    |
                    +-----------------------------------------+
                2   |       (4)File name to be deleted        |
                    +-                                       -+
                   ===      (ASCIZ character string)         ===
                    +-                                       -+
                    |           Within 64 bytes               |
                    +--------------------+--------------------+
                                         |  Check  SUM        |
                                         +--------------------+

                    (1)  Command number
                        Specify 2.
                    
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        Path size (variable-length)
                
                    (4)  File name to be deleted
                        Specify file name to be deleted and the full-path.
            

            b)  Response (device(onHand/Ruputer)  ->  terminal(PC))
                    15                   7                 0
                    +-------------------+-------------------+
                0   |(2)Subcommand number|(1)Command number |
                    +-------------------+-------------------+
                1   |  (3)Data length                       |
                    +---------------------------------------+
                2   |  (4)Result status                     |
                    +-------------------+-------------------+
                                        |  Check  SUM       |
                                        +-------------------+
                    
                    (1)  Command number
                        Specify 2. 
                
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        6
                
                    (4)  Result status
                        0: Normal termination,  Other than 0: Abnormal termination
                   
                    
        2.3  dir    ...Obtains directory date in flash memory.
            2.3.1  First attempt
            a)  Command  (terminal(PC)  ->  device(onHand/Ruputer))
                    15                   7                 0
                    +-------------------+-------------------+
                0   |(2)Subcommand number|(1)Command number |
                    +-------------------+-------------------+
                1   |       (3)Data length                  |
                    +-------------------+-------------------+
                2   |       (4)Directory name               |
                    +-                                     -+
                   ===      (ASCIZ character string)       ===
                    +-                                     -+
                    |           Within 64 bytes             |
                    +-------------------+-------------------+
                                        |  Check  SUM       |
                                        +-------------------+

                    (1)  Command number
                        Specify 3.
                    
                    (2)  Subcommand number
                        Specify 1.
                    
                    (3)  Data length
                        Path size (variable-length)
                    
                    (4) Directory name
                        Specify the directory name and the full-path.


            b)  Response (device(onHand/Ruputer)  ->  terminal(PC))
                    15                   7                 0
                    +-------------------+-------------------+
                0   |(2)Subcommand number|(1)Command number |
                    +-------------------+-------------------+
                1   |       (3)Data length                  |
                    +---------------------------------------+
                2   |  (4)Result status                     |
                    +---------------------------------------+
                3   |  (5)Sequence number                   |
                    +---------------------------------------+
                4   |  (6)Byte count of free disk space     |
                    +-                                     -+
                5   |                                       |
                    +---------------------------------------+
                6   | (7)Number of information setting files|
                    +---------------------------------------+
                7   |  (8)File information 1                |
                    +-      (22 bytes)                     -+
                   ===                                     ===
                    +-                                     -+
                13  |                                       |
                    +---------------------------------------+
                   ===                                     ===
                    |                                       |
                    +---------------------------------------+
                52  |  (8)File information 5                |
                    +-      (22 bytes)                     -+
                   ===                                     ===
                    +-                                     -+
                56  |                                       |
                    +-------------------+-------------------+
                                        |  Check  SUM       |
                                        +-------------------+
                    
                    (1)  Command number
                        Specify 3.
                
                    (2)  Subcommand number
                        Specify 1.
                    
                    (3)  Data length
                        14+Number of information setting files*22
                        
                    (4)  Result status
                        0: Normal termination, Other than 0: Abnormal termination
                    
                    (5)Sequence number
                        Set 1.
                    
                    (6)Byte count of free disk space
                        Set the free space of flash memory disk in bytes.
            
                    (7)Number of information setting files
                        Number of files whose directory date has been set (maximum 5)

                    (8)File information 
                        Set the file information items as follows (maximum 5).
                        +-------------------+
                        |  Written time     |  +0
                        +-------------------+
                        |  Written date     |  +2
                        +-------------------+
                        |  File size        |  +4
                        +-------------------+
                        |  Attribute        |  +8
                        +-------------------+
                        |  File name  (13B) |  +9        ASCIZ character string
                        +-------------------+

                
            2.3.2  Second attempt and later
            a)  Command  (terminal(PC)  ->  device(onHand/Ruputer))
                    15                    7                 0
                    +--------------------+-------------------+
                0   |(2)Subcommand number|(1)Command number  |
                    +--------------------+-------------------+
                1   |       (3)Data length                   |
                    +--------------------+-------------------+
                                         |  Check  SUM       |
                                         +-------------------+

                    (1)  Command number
                        Specify 3.
                    
                    (2)  Subcommand number
                        Specify 2.  
                    
                    (3)  Data length
                        4
                
            
            b)  Response (device(onHand/Ruputer)  ->  terminal(PC))
                    15                    7                  0
                    +--------------------+--------------------+
                0   |(2)Subcommand number|(1) Command number  |
                    +--------------------+--------------------+
                1   |       (3)Data length                    |
                    +-----------------------------------------+
                2   |  (4)Result status                       |
                    +-----------------------------------------+
                3   |  (5)Sequence number                     |
                    +-----------------------------------------+
                4   |  (6)Byte count of free disk space       |
                    +-                                       -+
                5   |                                         |
                    +-----------------------------------------+
                6   |  (7)Number of information setting files |
                    +-----------------------------------------+
                7   |  (8)File information 1                  |
                    +-      (22 bytes)                       -+
                   ===                                       ===
                    +-                                       -+
                13  |                                         |
                    +-----------------------------------------+
                   ===                                       ===
                    |                                         |
                    +-----------------------------------------+
                52  |  (8)File information 5                  |
                    +-      (22 bytes)                       -+
                   ===                                       ===
                    +-                                       -+
                56  |                                         |
                    +---------------------+-------------------+
                                          |  Check  SUM       |
                                          +-------------------+
                    
                    (1)  Command number
                        Specify 3.
                
                    (2)  Subcommand number
                        Specify 2.
                    
                    (3)  Data length
                        14+Number of files*22.

                    (4)  Result status
                        0: Normal termination, Other than 0: Abnormal termination

                    (5)Sequence number
                        Set the sequence number of this packet.

                    (6)Byte count of free disk space
                        Set the free space of flash memory disk in bytes.

                    (7)Number of information setting files
                        Number of files whose directory date has been set (maximum 5).

                    (8)File information 
                        Set the file information items as follows (maximum 5)
                        +-------------------+
                        |  Written time     |  +0
                        +-------------------+
                        |  Written date     |  +2
                        +-------------------+
                        |  File size        |  +4
                        +-------------------+
                        |  Attribute        |  +8
                        +-------------------+
                        |  File name  (13B) |  +9        ASCIZ character string
                        +-------------------+


        2.4  format ...Formats flash memory disk
            a)  Command  (terminal(PC)  ->  device(onHand/Ruputer))
                    15                    7                  0
                    +--------------------+--------------------+
                0   |(2)Subcommand number|(1)  Command number |
                    +--------------------+--------------------+
                1   |       (3)Data length                    |
                    +-----------------------------------------+
                2   |  (4)Byte count in a sector              |
                    +-----------------------------------------+
                3   |  (5)Number of sectors per cylinder      |
                    +-----------------------------------------+
                4   |  (6)Number of cylinder per head         |
                    +-----------------------------------------+
                5   |  (7)Number of heads per drive           |
                    +--------------------+--------------------+
                                         |  Check  SUM        |
                                         +--------------------+

                    (1)  Command number
                        Specify 4.
                    
                    (2)  Subcommand number
                        Specify a format type from 1 - 3.
                        (See "<wbiosLibManu(c)/(ASM).txt>  bi_format" for details.)
                    
                    (3)  Data length
                        12
                
                    (4)  Byte count in a sector
                        Set byte count in a sector.
                        
                    (5)Number of sectors per cylinder
                        Set number of sectors per cylinder1.
            
                    (6)Number of cylinder per head
                        Set number of cylinder per head.

                    (7)Number of heads per drive
                        Set umber of heads per drive.


            b)  Response (device(onHand/Ruputer)  ->  terminal(PC))
                    15                    7                 0
                    +--------------------+-------------------+
                0   |(2)Subcommand number|(1)  Command number|
                    +--------------------+-------------------+
                1   |       (3)Data length                   |
                    +----------------------------------------+
                2   |  (4)Result status                      |
                    +--------------------+-------------------+
                                         |  Check  SUM       |
                                         +-------------------+
                    
                    (1)  Command number
                        Specify 4.  
                

                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        6
                
                    (4)  Result status
                        0: Normal termination,  Other than 0: Abnormal termination


        2.5  ren    ...Changes a file name
            a)  Command  (terminal(PC)  ->  device(onHand/Ruputer))
                    15                    7                 0
                    +--------------------+-------------------+
                0   |(2)Subcommand number|(1)Command number  |
                    +--------------------+-------------------+
                1   |       (3)Data length                   |
                    +----------------------------------------+
                2   |  (4)Length of the existing file name   |
                    +----------------------------------------+
                3   |  (5)Length of a new file name          |
                    +----------------------------------------+
                4   |  (6)The existing file name             |
                    +-                                      -+
                5   |       (ASCIZ character string)         |
                    +-                                      -+
                    =                                        =
                    +-                                      -+
                    |                                        |
                    +----------------------------------------+
                    |  (7)New file name                      |
                    +-                                      -+
                    =       (ASCIZ character string)         =
                    +-                                      -+
                    |                                        |
                    +--------------------+-------------------+
                                         |  Check  SUM       |
                                         +-------------------+

                    (1)  Command number
                        Specify 5.
                    
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        --

                
                    (4)  Length of the existing file name
                        Specify the length of the existing file name. 
                        The file name should be specified in full-path,
                        and has to be 64 bytes at maximum including NULL characters.

                    (5)  Length of a new file name
                        Specify the length of a new file name.
                        The file name should be specified in full-path,
                        and has to be 64 bytes at maximum including NULL characters.

                    (6)  The existing file name
                        Specify the existing file name.
    
                    (7)  New file name
                        Specify a new file name.

                
            b)  Response (device(onHand/Ruputer)  ->  terminal(PC))
                    15                    7                 0
                    +--------------------+-------------------+
                0   |(2)Subcommand number|(1)Command number  |
                    +--------------------+-------------------+
                1   |       (3)Data length                   |
                    +----------------------------------------+
                2   |  (4)Result status                      |
                    +--------------------+-------------------+
                                         |  Check  SUM       |
                                         +-------------------+

                    (1)  Command number
                        Specify 5.  
                
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        6
                
                    (4)  Result status
                        0: Normal termination,  Other than 0: Abnormal termination
           
                    
        2.6  reset  ...Reset
            a)  Command  (terminal(PC)  ->  device(onHand/Ruputer))
                    15                    7                 0
                    +--------------------+-------------------+
                0   |(2)Subcommand number|(1)Command number  |
                    +--------------------+-------------------+
                1   |       (3)Data length                   |
                    +--------------------+-------------------+
                                         |  Check  SUM       |
                                         +-------------------+

                    (1)  Command number
                        Specify 6.
                    
                    (2)  Subcommand number
                        Not for use.
                
                    (3)  Data length
                        4
                
            
            b)  Response (device(onHand/Ruputer)  ->  terminal(PC))
                    15                    7                 0
                    +--------------------+-------------------+
                0   |(2)Subcommand number|(1) Command number |
                    +--------------------+-------------------+
                1   |       (3)Data length                   |
                    +----------------------------------------+
                2   |  (4)Result status                      |
                    +--------------------+-------------------+
                                         |  Check  SUM       |
                                         +-------------------+

                    (1)  Command number
                        Specify 6.
                
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        6
                
                    (4)  Result status
                        Not for use. 
                   
                    
        2.7  ver    ...Obtains the system version
            a)  Command  (terminal(PC)  ->  device(onHand/Ruputer))
                    15                    7               0
                    +--------------------+-----------------+
                0   |(2)Subcommand number|(1)Command number|
                    +--------------------+-----------------+
                1   |       (3)Data length                 |
                    +--------------------+-----------------+
                                         |  Check  SUM     |
                                         +-----------------+

                    (1)  Command number
                        Specify 7.
                    
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        4


            b)  Response (device(onHand/Ruputer)  ->  terminal(PC))
                    15                    7                0
                    +--------------------+------------------+
                0   |(2)Subcommand number|(1)Command number |
                    +--------------------+------------------+
                1   |       (3)Data length                  |
                    +---------------------------------------+
                2   |  (4)Result status                     |
|                   +---------------------------------------+
                3   |  (5)Version information               |
                    +-      (8 bytes)                      -+
                4   |                                       |
                    +-                                     -+
                   ===                                    ===
                    +-                                     -+
                    |                                       |
                    +-------------------+-------------------+
                                        |  Check  SUM       |
                                        +-------------------+
                    
                    (1)  Command number
                        Specify 7.
                
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        6  +  Byte count of the version information 
                
                    (4)  Result status
                        0: Normal termination,  Other than 0: Abnormal termination
                    
                    (5)  Version information
                        The version information of the system is set.
                        Leading byte:   Major version(integer part)
                        First byte:  Minor version(decimal part)
                        Second byte and later:  Reserved

                    
        2.8  download       ...Transmits a file in the disk in onHand/Ruputer to PC.
            a)  Command  (terminal(PC)  ->  device(onHand/Ruputer))
                    15                    7                 0
                    +--------------------+-------------------+
                0   |(2)Subcommand number|(1)Command number  |
                    +--------------------+-------------------+
                1   |       (3)Data length                   |
                    +----------------------------------------+
                2   |       (4)Transmitted file name         |
                    +-                                      -+
                   ===      (ASCIZ character string)        ===
                    +-                                      -+
                    |           Within 64 bytes              |
                    +-------------------+--------------------+
                                        |  Check  SUM        |
                                        +--------------------+

                    (1)  Command number
                        Specify 8.
                    
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        Path size (variable-length)
                
                    (4)  Transmitted file name
                        Specify the file name to be transmitted and the full-path.  


            b)  Response (device(onHand/Ruputer)  ->  terminal(PC))
                The terminal(PC) immediately sends a NAK code if it is successfully terminated after receiving a response.
                    15                    7                  0
                    +--------------------+--------------------+
                0   |(2)Subcommand number|(1)Command number   |
                    +--------------------+--------------------+
                1   |       (3)Data length                    |
                    +-----------------------------------------+
                2   |  (4)Result status                       |
                    +-----------------------------------------+
                3   |                                         |
                    +-  (5)  File size                       -+
                4   |                                         |
                    +-----------------------------------------+
                5   |   (6) File time                         |
                    +-----------------------------------------+
                6   |   (7) File date                         |
                    +--------------------+--------------------+
                7   |   Check  SUM       |(8)File attribute   |
                    +--------------------+--------------------+

                    (1)  Command number
                        Specify 8.
                
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        27
                
                    (4)  Result status
                        0: Normal termination,  Other than 0: Abnormal termination
            
                    (5)  File size
                        Size of the file to be transmitted
                        
                    (6)  File time
                        Time for the file to be transmitted

                    (7)  File date
                        Date for the file to be transmitted

                    (8)  File Attribute
                        Attribute of the file to be transmitted

                
        2.9  upload ...Transmits a file in PC to the disk in onHand/Ruputer.
            a)  Command  (terminal(PC)  ->  device(onHand/Ruputer))
                    15                      7                   0
                    +----------------------+---------------------+
                0   |(2)Subcommand number  |(1) Command number   |
                    +----------------------+---------------------+
                1   |       (3)Data length                       |
                    +--------------------------------------------+
                2   |(4)Length of the file name to be transmitted|
                    +--------------------------------------------+
                3   |   (5)Transmitted file name                 |
                    +-                                          -+
                   ===      (ASCIZ character string)            ===
                    +-                                          -+
                    |           Within 64 bytes                  |
                    +---------------------+----------------------+
                    |                                            |
                    +-  (6)File size                             -+
                    |                                            |
                    +--------------------------------------------+
                    |   (7) File time                            |
                    +--------------------------------------------+
                    |   (8) File date                            |
                    +---------------------+----------------------+
                    |   Check  SUM        |(9)File attribute     |
                    +---------------------+----------------------+

                    (1)  Command number
                        Specify 9.
                    
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        13+Path size of a file(variable-length)

                    (4)  Length of the file name to be transmitted
                        Specify the length of the file name to be transmitted
                        The file name should be specified in full-path,
                        and has to be 64 bytes at maximum including NULL characters.

                    (5)  Transmitted file name
                        Specify the file name to be transmitted and the full-path

                    (6)  File size
                        Size of the file to be transmitted

                    (7)  File time
                        Time for the file to be transmitted

                    (8)  File date
                        Date for the file to be transmitted

                    (9)  File attribute
                        Attribute of the file to be transmitted

                
            b)  Response (device(onHand/Ruputer)  ->  terminal(PC))
                The device (onHand/Ruputer)immediately sends a NAK if it is successfully terminated after receiving a response.
                    15                    7                  0
                    +--------------------+--------------------+
                0   |(2)Subcommand number|(1)  Command number |
                    +--------------------+--------------------+
                1   |       (3)Data length                    |
                    +-----------------------------------------+
                2   |  (4)Result status                       |
                    +--------------------+--------------------+
                                         |  Check  SUM        |
                                         +--------------------+

                    (1)  Command number
                        Specify 9.
                
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        6
                
                    (4)  Result status
                        0: Normal termination,  Other than 0: Abnormal termination
           
                    
        2.10  mkdir ...Creates a new directory 
            a)  Command  (terminal(PC)  ->  device(onHand/Ruputer))
                    15                    7                 0
                    +--------------------+-------------------+
                0   |(2)Subcommand number|(1)Command number  |
                    +--------------------+-------------------+
                1   |       (3)Data length                   |
                    +----------------------------------------+
                2   |       (4)New directory name            |
                    +-                                      -+
                   ===      (ASCIZ character string)        ===
                    +-                                      -+
                    |           Within 64 bytes              |
                    +-------------------+--------------------+
                                        |  Check  SUM        |
                                        +--------------------+

                    (1)  Command number
                        Specify 10.
                    
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        Path size (variable-length)
                
                    (4)  New directory name
                        Specify the new directory name and the full-path
            

            b)  Response (device(onHand/Ruputer)  ->  terminal(PC))
                    15                     7                0
                    +---------------------+------------------+
                0   |(2)Subcommand number |(1)Command number |
                    +---------------------+------------------+
                1   |       (3)Data length                   |
                    +----------------------------------------+
                2   |  (4)Result status                      |
                    +---------------------+------------------+
                                          |  Check  SUM      |
                                          +------------------+
                    
                    (1)  Command number
                        Specify 10.
                
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        6
                
                    (4)  Result status
                        0: Normal termination,  Other than 0: Abnormal termination
                   

        2.11  rmdir ...Deletes a directory 
            a)  Command  (terminal(PC)  ->  device(onHand/Ruputer))
                    15                    7                0
                    +--------------------+------------------+
                0   |(2)Subcommand number|(1)Command number |
                    +--------------------+------------------+
                1   |       (3)Data length                  |
                    +---------------------------------------+
                3   |  (4)Name of directory to be deleted   |
                    +-                                     -+
                   ===  (ASCIZ character string)           ===
                    +-                                     -+
                    |           Within 64 bytes             |
                    +-------------------+-------------------+
                                        |  Check  SUM       |
                                        +-------------------+

                    (1)  Command number
                        Specify 11.
                    
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        Path size (variable-length)
                
                    (4)  Name of the directory to be deleted
                        Specify the name of the directory to be deleted and the full-path.
            


            b)  Response (device(onHand/Ruputer)  ->  terminal(PC))
                    15                    7                0
                    +--------------------+------------------+
                0   |(2)Subcommand number|(1)Command number |
                    +--------------------+------------------+
                1   |       (3)Data length                  |
                    +---------------------------------------+
                2   |  (4)Result status                     |
                    +--------------------+------------------+
                                         |  Check  SUM      |
                                         +------------------+
                    
                    (1)  Command number
                        Specify 11.
                
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        6
                
                    (4)  Result status
                        0: Normal termination,  Other than 0: Abnormal termination


        2.12  chdir ...Moves a directory
            a)  Command  (terminal(PC)  ->  device(onHand/Ruputer))
                    15                    7                0
                    +--------------------+------------------+
                0   |(2)Subcommand number|(1)Command number |
                    +--------------------+------------------+
                1   |       (3)Data length                  |
                    +---------------------------------------+
                3   |   (4)Name of directory to be moved    |
                    +-                                     -+
                   ===         (ASCIZ character string)    ===
                    +-                                     -+
                    |           Within 64 bytes             |
                    +-------------------+-------------------+
                                        |  Check  SUM       |
                                        +-------------------+

                    (1)  Command number
                        Specify 12.
                    
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        Size of a path
                
                    (4)  Name of directory to be moved
                            Specify a name of directory to be moved with the full-path. 
                            Specify "." to obtain the current directory name.
            

            b)  Response (device(onHand/Ruputer)  ->  terminal(PC))
                    15                    7                 0
                    +--------------------+-------------------+
                0   |(2)Subcommand number|(1)Command number  |
                    +--------------------+-------------------+
                1   |       (3)Data length                   |
                    +----------------------------------------+
                2   |  (4)Result status                      |
                    +--------------------+-------------------+
                                         |  Check  SUM       |
                                         +-------------------+
                    
                    (1)  Command number
                        Specify 12.
                
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        18
                
                    (4)  Result status
                        0: Normal termination,  Other than 0: Abnormal termination
                    

        2.13  gtime ...Obtains time.
            a)  Command  (terminal(PC)  ->  device(onHand/Ruputer))
                    15                    7                 0
                    +--------------------+-------------------+
                0   |(2)Subcommand number|(1)Command number  |
                    +--------------------+-------------------+
                1   |       (3)Data length                   |
                    +--------------------+-------------------+
                                         |  Check  SUM       |
                                         +-------------------+

                    (1)  Command number
                        Specify 13.
                    
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        4


            b)  Response (device(onHand/Ruputer)  ->  terminal(PC))
                    15                    7                0
                    +--------------------+------------------+
                0   |(2)Subcommand number|(1)Command number |
                    +--------------------+------------------+
                1   |       (3)Data length                  |
                    +---------------------------------------+
                2   |  (4)Result status                     |
                    +--------------------+------------------+
                3   |(5)    Month        |(5)   Year        |
                    +--------------------+------------------+
                4   |(5)    Hour         |(5)   Day         |
                    +--------------------+------------------+
                5   |(5)    Second       |(5)   Minute      |
                    +--------------------+------------------+
                                         |  Check  SUM      |
                                         +------------------+
                    
                    (1)  Command number
                        Specify 13.
                
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        12
                
                    (4)  Result status
                        0: Normal termination,  Other than 0: Abnormal termination
                    
                    (5)  Year, month, day, hour, minute, and second are set in packed BCD.

        2.14  gtime ...Sets time.
            a)  Command  (terminal(PC)  ->  device(onHand/Ruputer))
                    15                    7                0
                    +--------------------+------------------+
                0   |(2)Subcommand number|(1)Command number |
                    +--------------------+------------------+
                1   |       (3)Data length                  |
                    +--------------------+------------------+
                2   |(4)    Month        |(4)   Year        |
                    +--------------------+------------------+
                3   |(4)    Hour         |(4)   Day         |
                    +--------------------+------------------+
                4   |(4)    Second       |(4)   Minute      |
                    +--------------------+------------------+
                                         |  Check  SUM      |
                                         +------------------+

                    (1)  Command number
                        Specify 14.
                    
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        10
                    (4)  Year, month, day, hour, minute, and second are set in packed BCD.


            b)  Response (device(onHand/Ruputer)  ->  terminal(PC))
                    15                    7                  0
                    +--------------------+--------------------+
                0   |(2)Subcommand number|(1)  Command number |
                    +--------------------+--------------------+
                1   |       (3)Data length                    |
                    +-----------------------------------------+
                2   |  (4)Result status                       |
                    +--------------------+--------------------+
                                         |  Check  SUM        |
                                         +--------------------+

                    (1)  Command number
                        Specify 14.
                
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        6
                
                    (4)  Result status
                        0: Normal termination,  Other than 0: Abnormal termination


        2.15  gpower    ...Detects battery voltage.
            a)  Command  (terminal(PC)  ->  device(onHand/Ruputer))
                    15                    7                  0
                    +--------------------+--------------------+
                0   |(2)Subcommand number|(1) Command number  |
                    +--------------------+--------------------+
                1   |       (3)Data length                    |
                    +--------------------+--------------------+
                                         |  Check  SUM        |
                                         +--------------------+

                    (1)  Command number
                        Specify 15.
                    
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        4


            b)  Response (device(onHand/Ruputer)  ->  terminal(PC))
                    15                    7                   0
                    +--------------------+---------------------+
                0   |(2)Subcommand number|(1) Command number   |
                    +--------------------+---------------------+
                1   |  (3)Data length                          |
                    +------------------------------------------+
                2   |  (4)Result status                        |
                    +------------------------------------------+
                3   |(5)Count value of charging and discharging|
                    +-                                        -+
                4   |                                          |
                    +--------------------+---------------------+
                                         |  Check  SUM         |
                                         +---------------------+
                    
                    (1)  Command number
                        Specify 15.
                
                    (2)  Subcommand number
                        Not for use.
                    
                    (3)  Data length
                        10
                
                    (4)  Result status
                        0: Normal termination,  Other than 0: Abnormal termination
                    
                    (5)  Count value of charging and discharging is set.


        2.16  chkdsk    ...Checks the consistency of flash memory.
            a)  Command  (terminal(PC)  ->  device(onHand/Ruputer))
                    15                    7                  0
                    +--------------------+--------------------+
                0   |(2)Subcommand number|(1)  Command number |
                    +--------------------+--------------------+
                1   |       (3)Data length                    |
                    +--------------------+--------------------+
                                         |  Check  SUM        |
                                         +--------------------+

                    (1)  Command number
                        Specify 18.
                    
                    (2)  Subcommand number
                        0: Indicates that chkdsk is executed. 
                        1: Indicates that chkdsk is completed.
                    
                    (3)  Data length
                        4


            b)  Response (device(onHand/Ruputer)  ->  terminal(PC))
                    15                    7                  0
                    +--------------------+--------------------+
                0   |(2)Subcommand number|(1)  Command number |
                    +--------------------+--------------------+
                1   |  (3)Data length                         |
                    +-----------------------------------------+
                2   |  (4)Result status                       |
                    +-----------------------------------------+
                    |                                         |
                    |       (5)Check information              |
                    |                                         |
                    +--------------------+--------------------+
                                         |  Check  SUM        |
                                         +--------------------+
                    
                    (1)  Command number
                        Specify 18.
                
                    (2)  Subcommand number
                        0: Indicates that chkdsk is completed 
                        1: Indicates that chkdsk has not been completed 
                    
                    (3)  Data length
                        10 or variable length
                
                    (4)  Result status
                        0: Normal termination,  Other than 0: Abnormal termination

                    (5)  Check information
                        In case the subcommand number is 0:
                        (The content varies if it is the completion command for chkdsk.)
                    +-------------------------------------------------------+
                3   |         Number of bad clusters                        |
                    +-------------------------------------------------------+
                4   |     Number of floating clusters                       |
                    +-------------------------------------------------------+

                        In case subcommand number is 1:
                    +---------------------------+---------------------------+
                3   |                           | Information on corruption |
                    +-                          +---------------------------+
                4   |                                                       |
                    +-                                                     -+
                .   |   Name of a corrupted file                            |
                    +-  (ASCIZ character string of complete path           -+
                .   |              beginning from the root)                 |
                    +-                                                     -+
                .   |                                                       |
                    +-------------------------------------------------------+
                        Information on corruption
                                  0:The file is incomplete.
                                  1:The file has something unnecessary.
                                  2:The file overlaps with other file.
                                  3:FAT link is incorrect (linked to reserved clusters)

===============================================================================
 Copyright (c) 1998-1999.  Seiko Instruments Inc.  All rights reserved. 
===============================================================================
