/******************************/
/* AD2COM Battery conditions  */
/*   RS-232C Version          */
/******************************/

A communication is attempted to a hyperterminal on PC.

<<<Setting on PC>>>
The following is a programming for this time.
PC activation -> Program -> Accessary -> Hyperterminal -> Hypertrm.exe
The process above enables to obtain a voltage value to PC through a RS-232C cable.

If Hypertrm.exe is activated:
1. Prompts the setting for connection. Enter "AD2COM."
2. In Telephone Number, RS-232C selects any from com1 to com4. (example: com1)
3. Properties for com1
    bit/sec     38400
    data bit    8
    parity      none
    stop bit    1
    flow control    none
4. During connection, the counter at the left below of screen changes.
   PC should be waiting in this state.
5. When exiting, a message "Do you save the session, AD2COM?" If you select "yes" this setting is saved for the next time you click on the icon for AD2COM.

Note: if you set to serial port that is same port to PC Filer,"rupshell" process already use the port. So after terminate "rupshell" process(Alt-Ctrl-Del ->select "rupshell" to be quit.),you'll test Hypertrm.exe.


<<<Description>>>
To avoid overlaps, this section does not deal with the same points covered in lesson1 and lesson2 about AD2COM.

After program activation, connecting a RS-232C cable prompts to the next process.
Read a voltage value by one byte transfer from PC to forward that value to the RS-232 output.

PC sending code
34h(4) --- Light load voltage value display (pwread =***d)
           RS-232C output (P0=***)
36h(6) --- Heavy load voltage value display (pwread2=***d)
           RS-232C output (P2=***)
38h(8) --- LCD ON
           RS-232C output (LCD ON)
32h(2) --- LCD OFF
           RS-232C output (LCDOFF)

When LCD is ON, use 34h and 36h to display a voltage value on the LCD screen.
When LCD is OFF, no value is displayed even with 34h and 36h.
Regardless of whether LCD is ON or OFF, an RS-232C putput is carried out.
Other keys are not enabled.
Keys on onHand/Ruputer are also diabled.
An communication error such as RS-232C disconnection also brings to an end.

<<<Souce file>>>

#define TIMEOUT_ERR 0x10
 Refer to BIOSerr below.

bi_complreadn()
 Receives multiple characters.
 Until the number of characters specified as an argument is received, this function does not return.
 However, if a timeout is specified with bi_cominit() and even a one character is not received within that alloted time, it returns.

 Format
  bi_complreadn(read,len,count)

  char *read    Array variables where character strings to be received are stored
  int   len     Number of characters to be received
  int   count   Number of characters that have acutally been received

  Return value  0=Normal terminal -1=Abnormal terminal

BIOSerr
 Amoung global variables provided by the operating system, BIOS functions (starting with bi_ such as bi_complwrite() or bi_comopen()) are set if the return value is abnormal termination -1.

  Extracting errors during communication.
   bit0:    Overrun error           (0:no error 1:error)
   bit1:    Parity error            (0:no error 1:error)
   bit2:    Framing error           (0:no error 1:error)
   bit3:    Receiving buffer overflow   (0:no error 1:error)
   bit4:    Timeout error           (0:no error 1:error)
   bit5:    Not open           		(0:no error 1:error)
   bit7:    Received data exist     (0:no error 1:error)

   In the sample above, TIMEOUT_ERR is bit4=1, thus:
    BIN = 00010000b
    HEX = 10h
    DEC = 16d

 Likewise, for dos_****, DOSerr is set.

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