/*********************************************************************/
/*  Library of Modbus/TCP and Modbus/RTU to Modbus/RTU for I-7188E   */
/*  and Modbus/RTU to Modbus/RTU protocol converte for I-7188XB      */
/*  [25,Sep,2002] first version by Kevin                             */
/*********************************************************************/
Version 1.7.2 [2012/01/03] by Mac
    Support iP-8000
    New function
        Accepts Modbus/RTU and Modbus/ASCII broadcast requests
        a. The requests must be for address 0
        b. The requests must be for writing AO and DO. 
           FC5  Write single coil (0xxxx)  for DO
           FC15 Force multiple coils (0xxxx)  for DO
           FC6  Write single register (4xxxx)  for AO
           FC16 Write multiple registers (4xxxx)  for AO
        c. The slaves will not response to the master.
        
    === Relative information ======
    Modbus Utility: Ver 1.7.0 [2007,Aug,23]    
    
    MiniOS7 image file: 
        7188XA (40M CPU) (Not Changed) 
            2.02 build 004, Feb 26 2007
            CD:\Napdos\Modbus\7188XA\OS_Image\For_40M\7188xa_CR_20070226.img
        7188XB (40M CPU) (Not Changed) 
            2.00 build 006, Mar 1 2007
            CD:\Napdos\Modbus\7188XB\OS_Image\For_40M\7188XB_CR_20070301.img
        7188XC (20M CPU) (Not Changed) 
            2.00 build 006, Mar 1 2007
            CD:\Napdos\Modbus\7188XC\OS_Image\For_20M\7188XC-20070301.img
        7188EX (40M CPU) (Not Changed) 
            2.02 build 002, Apr 10 2007
            CD:\Napdos\Modbus\7188e\OS_Image\For_40M\7188e-UDP-CR-20070410.img
            
	      I-8000 (40M CPU) (Updated)
            2.02 build 013, Jun 17 2011
            CD:\Napdos\Modbus\8000e\OS_Image\For_40M\8000_UDP-20110125.img
        I-8000 (80M CPU) (Updated)
            2.02 build 013, Jun 25 2011
            CD:\Napdos\Modbus\8000e\OS_Image\For_80M\C836_UDP-20110117.img
        iP-8000 (80M CPU)(New support)
            2.04 build 014, Sep 21 2011
            CD:\Napdos\Modbus\iP8000\OS_Image\C837_2M_UDP-20110921.img                      
------------------------------------------------------------------------
Version 1.7.0 [8,Aug,2007] by Mac
    Support Modbus ASCII Slave
    COM Port Enable Mode defined by
    _VxComm             0  //==> VxComm                                  
    _ModbusRTU_Gateway  1  //==> Modbus/RTU  Gateway                            
    _Programming        2  //==> Programming                             
    _ModbusRTU_Slave    3  //==> UpLink (to be a Modbus/RTU slave port)  
    _Debug              4  //==> Debug (print out some message for debug)
    _Console            5  //==> Consol (not supported yet,ET-6000 uses it to do simple config)
    _ModbusASCII_Slave  6  //==> UpLink (to be a Modbus/ASCII slave port)

    === Relative information ======
    Modbus Utility: Ver 1.7.0 [2007,Aug,23]    
    
    MiniOS7 image file: 
        7188XA (40M CPU) (Not Changed) 
            2.02 build 004, Feb 26 2007
            CD:\Napdos\Modbus\7188XA\OS_Image\For_40M\7188xa_CR_20070226.img
        7188XB (40M CPU) (Not Changed) 
            2.00 build 006, Mar 1 2007
            CD:\Napdos\Modbus\7188XB\OS_Image\For_40M\7188XB_CR_20070301.img
        7188XC (20M CPU) (Not Changed) 
            2.00 build 006, Mar 1 2007
            CD:\Napdos\Modbus\7188XC\OS_Image\For_20M\7188XC-20070301.img
        7188EX (40M CPU) (Not Changed) 
            2.02 build 002, Apr 10 2007
            CD:\Napdos\Modbus\7188e\OS_Image\For_40M\7188e-UDP-CR-20070410.img
            
        8000 (40M CPU) (Updated)
            2.02 build 006, Jun 25 2007
            CD:\Napdos\Modbus\8000e\OS_Image\For_40M\8000_UDP_20070625.img
        8000 (80M CPU) (Updated)
            2.02 build 006, Jun 25 2007
            CD:\Napdos\Modbus\8000e\OS_Image\For_80M\C836_UDP-20070625.img
------------------------------------------------------------------------

Version 1.6.9 [18,May,2007] by Mac
    Improving the Modbus/RTU response check
        After receiving the response data from a RTU device,
        the Modbus library will automatically check the data length after CRC checking.
        This will improve the identification of the response data.
        For Example:
        If the response is
        01 04 10 07 F1 07 E8 07 E8 07 A8 07 A4 00 00 00 00 00 00 00 00 [E7 00]
        The response check will end at [00 E7], because of [00 E7] is the CRC value of front data.
        
    Disable Function
        Set UpLink mode as a simple Slave, disable Gateway function in it.
        If the Net ID of the request does not match the controller ID,
        the request from COM Port will not pass to other COM Ports.
        The gateway function is only used for TCP/IP connections.
        
    Change Argument
        Change blank value (unit:ms)
        baudrate   Ver 1.6.3   1.6.6   1.6.8   1.6.9
        -------------------------------------------
            115200:     10      100     25       3
             57600:     10      100     25       5
             38400:     12      60      40       7
             19200:     12      60      40       9
              9600:     15      70      60      15
              4800:     20      80      80      28
              2400:     25      90      90      50
           default:     15      50      40      15
        -------------------------------------------
        
    === For programming ====
    Add Function   
        Distributed Modbus_Request_Event to Modbus_Request_Event and Modbus_Response_Event
        Modbus_Request_Event:    
            When the 7188E/8000E receives a Modbus/TCP or Modbus/RTU command,
            the Modbus library will automatically call the function Modbus_Request_Event,
        Modbus_Response_Event:
            Before the 7188E/8000E response to the initial request,
            the Modbus library will first call the function Modbus_Response_Event,
            You can write some code both in Modbus_Request_Event and Modbus_Response_Event functions.
            Receive Modbus Request=>Modbus_Request_Event=>.....=>Modbus_Response_Event=>Send Modbus Response
            
    Fix Bug
        When using ModbusASCII_Master function to get DI data,
        the binary content of the first byte is copied in every bytes follwing the first byte.
        Therefore the digits follwing the first 8 bits are not real values.
         
    === Relative information ======
    Modbus Utility: Ver 1.6.9 [2007,Mar,21]    
    
    MiniOS7 image file: 
        7188XA (40M CPU) (Not Changed) 
            2.02 build 004, Feb 26 2007
            CD:\Napdos\Modbus\7188XA\OS_Image\For_40M\7188xa_CR_20070226.img
        7188XB (40M CPU) (Not Changed)
            2.00 build 006, Mar 1 2007
            CD:\Napdos\Modbus\7188XB\OS_Image\For_40M\7188XB_CR_20070301.img
        7188XC (20M CPU) (Not Changed)
            2.00 build 006, Mar 1 2007
            CD:\Napdos\Modbus\7188XC\OS_Image\For_20M\7188XC-20070301.img
        7188EX (40M CPU) (Updated)
            2.02 build 002, Apr 10 2007
            CD:\Napdos\Modbus\7188e\OS_Image\For_40M\7188e-UDP-CR-20070410.img
            
        8000 (40M CPU) (Updated)
            2.02 build 002, Apr 9 2007
            CD:\Napdos\Modbus\8000e\OS_Image\For_40M\8000_UDP_20070409.img
        8000 (80M CPU) (Updated)
            2.02 build 002, Apr 9 2007
            CD:\Napdos\Modbus\8000e\OS_Image\For_80M\C836_UDP-20070409.img
------------------------------------------------------------------------

Version 1.6.8 [13,Mar,2007] by Kevin
    Support P824 CPU.
    
    Add one mode for COM port
       Mode5 = Consol.
       ET-6000 uses it to perform simple configurations.
       
    Change blank value (unit:ms)
        baudrate   Ver 1.6.3   1.6.6   1.6.8
        -------------------------------------------
            115200:     10      100     25     
             57600:     10      100     25
             38400:     12      60      40
             19200:     12      60      40
              9600:     15      70      60
              4800:     20      80      80
              2400:     25      90      90
           default:     15      50      40
        This blank value is used to receive COM port data.
               
    Can work with MiniOS7 Utility 3.x.x.
        MiniOS7 Utility 3.x.x can configure, upload files to 
        7188E/8000E via the Ethernet. The maintenance becomes very easy.
        
    === For programming ====    
    Add function Modbus_Request_Event,
        You can execute some code, once the 7188E/8000E gets a Modbus/TCP
        or Modbus/RTU request. Following related global variables 
        (defined in .h) are also usefull:
            extern unsigned int iModbusRequest_Fun;
            extern unsigned int iModbusRequest_Addr;
            extern unsigned int iModbusRequest_IOCount;
            extern unsigned long lModbusRequest_TimeTicks;

    Fix bug
        1. Initial COM port buffer status as IDEL when been set to Modbus Gateway Mode,
           else after changing the COM port mode, the gateway could be not work.
           
        2. ID cannot set to 128~255.
        
        3. ModbusRTU_Master, ModbusASCII_Master could not work correctly.
            Only happen to Modbus Function 1, 2, 15. 
            Calling "ceil" to translate bit number to byte number.       
            But "Ceil" sometimes doesn't work correctly. 
            So, using another method to replace "ceil".
                    
    === Relative information ======
    Modbus Utility: Ver 1.6.8 [2006,Aug,16]    
    
    MiniOS7 image file: 
        7188XA (40M CPU) (Updated) 
            2.00 build 008, Feb 26 2007
            CD:\Napdos\Modbus\7188XA\OS_Image\For_40M\7188XA_CR_20070226.img
        7188XB (40M CPU) (Updated)
            2.00 build 006, Mar 1 2007
            CD:\Napdos\Modbus\7188XB\OS_Image\For_40M\7188XB_CR_20070301.img
        7188XC (20M CPU) (Updated)
            2.00 build 006, Mar 1 2007
            CD:\Napdos\Modbus\7188XC\OS_Image\For_20M\7188XC-20070301.img
        7188EX (40M CPU) (Updated)
            2.02 build 002, Mar 01 2007
            CD:\Napdos\Modbus\7188e\OS_Image\For_40M\7188E-UDP-CR-20070301.img
            
        8000 (40M CPU) (Updated)
            2.02 build 002, Mar 12 2007
            CD:\Napdos\Modbus\8000e\OS_Image\For_40M\8000_UDP_20070312.img
        8000 (80M CPU) (Updated)
            2.02 build 002, Mar 12 2007
            CD:\Napdos\Modbus\8000e\OS_Image\For_80M\C836_UDP-20070312.img
------------------------------------------------------------------------

Version 1.6.7 [28,Aug,2006] by Kevin
    1. Fix bug of Read/Write register address >500
        Remove MAX_REGISTER_COUNT limitatation in VcomCmdModbus.
        MAX_REGISTER_COUNT was removed from .h file since version 1.6.4.
        But in the source code, it is not removed.
    
    2. Fix bug of Modbus/RTU communictaion
        Following two modes are rewrote since version 1.6.5.
            a. COM port as UpLink mode (calling function CheckModbusRequest)
            b. ModbusRTU_Master
        For I-7188XA and 7188XB, the communication becomes unstable.
        In this version, the two functions are improved to more stable.
        
        So, if your firmware uses mbr7_165.Lib or mbr7_166.Lib, you have to
        update to version 1.6.7 to solve the problem.
        
    3. Support multi commands in one TCP/IP packet. 
        In standard Modbus/TCP protocol, one TCP/IP packet only contains
        one modbus command (6 leading bytes + Command). 
        In this version, you can give several commands in one TCP/IP 
        packet, and get all results in one response packet.
        For example:
            packetA ==>  [6 Leading bytes] + [Command A] 
                       + [6 Leading bytes] + [Command B]
                       + [6 Leading bytes] + [Command C]
                       + [6 Leading bytes] + [Command D]
                       
            packetB <==  [6 Leading bytes] + [Result A] 
                       + [6 Leading bytes] + [Result B]
                       + [6 Leading bytes] + [Result C]
                       + [6 Leading bytes] + [Result D]
                       
        This method can reduce TCP/IP packets and makes your programm
        get better performance to access Modbus/TCP devices.
        
        Of course, your Modbus/TCP driver must support this.
        
    === For programming ====    
    1. Add global variables
            lModbusRequest_TimeTicks
                According to this variable, you can know the timeticks 
                of the latest Modbus request.
    
    2. Fix bug of ModbusRTU_Master
        Since version 1.6.6, the function was re-wrote to support non-blocked
        communication mode. The non-blocked mode for M-7000 series I/O modules
        doesn't work well.
                    
    === Relative information ======
    Modbus Utility: Ver 1.6.8 [2006,Aug,16]    
    
    MiniOS7 image file: 
        For 7188XA (40M CPU) (No channged)
            2.00 build 002, Jul 14 2006
            CD:\Napdos\Modbus\7188XA\OS_Image\For_40M\7188XA_CR_20060614.img
        For 7188XB (40M CPU) (No channged)
            2.00 build 002, Jul 14 2006 
            CD:\Napdos\Modbus\7188XB\OS_Image\For_40M\7188XB_CR_20060614.img
        For 7188EX (40M CPU) (No channged)
            2.00 build 002, Jul 08 2006
            CD:\Napdos\Modbus\7188e\OS_Image\For_40M\7188E_CR_20060608.img
        For 8000 (40M CPU) (No channged)
            2.00 build 004, Sep 02 2005
            CD:\Napdos\Modbus\8000e\OS_Image\For_40M\8k050902.img
        For 8000 (80M CPU) (No channged)
            2.00 build 004, Sep 02 2005
            CD:\Napdos\Modbus\8000e\OS_Image\For_80M\8e050902.img
------------------------------------------------------------------------
Version 1.6.6 [04,Jul,2006] by Kevin
    1. COM ports of I-8000 controller support variant enable modes 
       like 7188E does. 
       The enable modes include
            (a) VxComm 
            (b) Modbus/RTU gateway
            (c) Programming
            (d) UpLink (be a Modbus/RTU slave port)
            (e) Debug
       
       Modbus Utility 1.5.1 can help users to configurate COM port setting.
       
    For programming
        1. MBT8_150.lib becomes two files ==> MBT8_166.lib and IO_152.lib
            MBT8_nnn.Lib takes care Modbus communication.
            IO_nnn.Lib takes care I/O scan kernel.
        
        2. Change EEPROM location to store data 
           (Synchronize data location for 7188/8000)
           Please refer EEPROM_List.txt in lib dirctory for details.
           
        3. Improve ModbusRTU_Master2Slave and ModbusASCII_Master2Slave
            (a) add non-blocked communication mode.
                there is one iWait parameter can decide to use 
                blocked (original mode) or non-blocked (new mode).
            (b) add functions
                    ModbusRTU_Master_Send
                    ModbusRTU_Master_Receive
                    ModbusASCII_Master_Send
                    ModbusASCII_Master_Receive  
                    
        4. Improve VcomSaveComData
            The function can check whether the data stored in EEPROM
            is same as the new one. If yes, the function will not write
            data to EEPROM again. This can avoid the EEPROM been wrote 
            too frequently.
            (EEPROM can only be wrote about 1,000,000 times)
            (This only for non-Xserver programming)
            
        5. From this version, 7188/8000 use same modbus kernel.
            (a) Every modbus function for 7188 and 8000 is same.
                That is to say, COM port of I-8000 controller can be set 
                to one of VxComm, Modbus/RTU gateway, UpLink, Debug.
                
            (b) To use I/O module on I-8000 controller, you have to 
                include another I/O library, IO_nnn.lib.
                (Before MBT8_150.lib, the modbus kernel and I/O scan kernel
                 are combined together)
                 
            (c) Lib and Head files are reduced to 
                    MBRTU.h         (for all 7188/8000)
                    MBTCP.h         (for all 7188/8000)
                    MBR7_nnn.Lib    (for all 7188)
                    MBR8_nnn.Lib    (for all 8000)
                    MBT7_nnn.Lib    (for 7188E only)
                    MBT8_nnn.Lib    (for 8000E only)
                    
    === Relative information ======
    Modbus Utility: Ver 1.5.1 [2006,Jun,21]    
    
    MiniOS7 image file: 
        For 7188XA (40M CPU) (No channged)
            2.00 build 002, Jul 01 2005
            CD:\Napdos\Modbus\7188XA\OS_Image\For_40M\XA050701.img
        For 7188XB (40M CPU) (No channged)
            2.00 build 002, Jul 01 2005 
            CD:\Napdos\Modbus\7188XB\OS_Image\For_40M\XB050701.img
        For 7188EX (40M CPU) (No channged)
            2.00 build 002, Jul 01 2005
            CD:\Napdos\Modbus\7188e\OS_Image\For_40M\e-050701.img
        For 8000 (40M CPU) (No channged)
            2.00 build 004, Sep 02 2005
            CD:\Napdos\Modbus\8000e\OS_Image\For_40M\8k050902.img
        For 8000 (80M CPU) (No channged)
            2.00 build 004, Sep 02 2005
            CD:\Napdos\Modbus\8000e\OS_Image\For_80M\8e050902.img                     
------------------------------------------------------------------------

Version 1.6.5 [07,Mar,2006] by Kevin
    Fix communicatin bug when a RS-485 port works as a Modbus/RTU slave.
        This is a multidrop problem. If there are several slave devices 
        on the same RS-485 bus, the communication has problem.
        It was fixed.
        
        For RS-232 or Ethernet port, the communication is correct.
        
    === Relative information ======
    Modbus Utility: Ver 1.3.3 [2005,May,05]    
    
    MiniOS7 image file: 
        For 7188XA (40M CPU) (No channged)
            2.00 build 002, Jul 01 2005
            CD:\Napdos\Modbus\7188XA\OS_Image\For_40M\XA050701.img
        For 7188XB (40M CPU) (No channged)
            2.00 build 002, Jul 01 2005 
            CD:\Napdos\Modbus\7188XB\OS_Image\For_40M\XB050701.img
        For 7188EX (40M CPU) (No channged)
            2.00 build 002, Jul 01 2005
            CD:\Napdos\Modbus\7188e\OS_Image\For_40M\e-050701.img
        For 8000 (40M CPU) (No channged)
            2.00 build 004, Sep 02 2005
            CD:\Napdos\Modbus\8000e\OS_Image\For_40M\8k050902.img
        For 8000 (80M CPU) (No channged)
            2.00 build 004, Sep 02 2005
            CD:\Napdos\Modbus\8000e\OS_Image\For_80M\8e050902.img  
------------------------------------------------------------------------
            
Version 1.6.4 [17,Feb,2006] by Kevin
    1. Add command buffer for Modbus/RTU Gateway 
        Each COM port can store 4 commands in the buffer. While several 
        Modbus masters use same COM port gateway, the buffer can store
        the commands and then bypass them to Modbus/RTU device that
        connected to the COM port.
        The function can avoid data collision.
        
    For programming
        1. support XS structor.
        2. add RefreshWDT to ModbusRTU_Master2Slave.
            this can avoid reset by WDT when the timeout parameter is
            more than 0.8 second.
        3. add Debug information for Modbus/AsCII Master to Slave.
        4. change InitModbus
            the function now needs four extra parameters.
        5. add Modbus/TCP master to slave function     

    === Relative information ======
    Modbus Utility: Ver 1.3.3 [2005,May,05]    
    
    MiniOS7 image file: 
        For 7188XA (40M CPU) (No channged)
            2.00 build 002, Jul 01 2005
            CD:\Napdos\Modbus\7188XA\OS_Image\For_40M\XA050701.img
        For 7188XB (40M CPU) (No channged)
            2.00 build 002, Jul 01 2005 
            CD:\Napdos\Modbus\7188XB\OS_Image\For_40M\XB050701.img
        For 7188EX (40M CPU) (No channged)
            2.00 build 002, Jul 01 2005
            CD:\Napdos\Modbus\7188e\OS_Image\For_40M\e-050701.img
        For 8000 (40M CPU) (No channged)
            2.00 build 004, Sep 02 2005
            CD:\Napdos\Modbus\8000e\OS_Image\For_40M\8k050902.img
        For 8000 (80M CPU) (No channged)
            2.00 build 004, Sep 02 2005
            CD:\Napdos\Modbus\8000e\OS_Image\For_80M\8e050902.img  
------------------------------------------------------------------------        
Version 1.6.3 [29,Sep,2005] by Kevin
    For programming
        1. Change ModbusMaster2Slave:
                Rename to ModbusRTU_Master2Slave,
                Add a lTimeout parameter.
        
        2. Add ModbusASCII_Master2Slave
           The function usage is same as ModbusRTU_Master2Slave
           but use Modbus/ASCII protocol.   
        
        3. Support i-8000 controller.
           7188XA/XB/EX and i-8000 controller use the same source code.
           But the library for i-8000 still not support the I/O module
           plug in slots.
           So, if users want to program the i-8000 with auto scan I/O
           modules, the original Modbus/TCP library (MBT8_xxx.Lib) 
           for i-8000E is still the best choose.
           
           If you want to use 8410/8411/8810/8811 with Modbus protocol,
           this library (MBR8_xxx.Lib) is ok, but you have to programm 
           the I/O modules that plug in slots. 
           
    === Relative information ======
    Modbus Utility: Ver 1.3.3 [2005,May,05]    
    
    MiniOS7 image file: 
        For 7188XA (40M CPU) (Updated)
            2.00 build 002, Jul 01 2005
            CD:\Napdos\Modbus\7188XA\OS_Image\For_40M\XA050701.img
        For 7188XB (40M CPU) (Updated)
            2.00 build 002, Jul 01 2005 
            CD:\Napdos\Modbus\7188XB\OS_Image\For_40M\XB050701.img
        For 7188EX (40M CPU) (No channged)
            2.00 build 002, Jul 01 2005
            CD:\Napdos\Modbus\7188e\OS_Image\For_40M\e-050701.img
        For 8000 (40M CPU) (Updated)
            2.00 build 004, Sep 02 2005
            CD:\Napdos\Modbus\8000e\OS_Image\For_40M\8k050902.img
        For 8000 (80M CPU) (Updated)
            2.00 build 004, Sep 02 2005
            CD:\Napdos\Modbus\8000e\OS_Image\For_80M\8e050902.img  
------------------------------------------------------------------------
Version 1.6.2 [26,Aug,2005] by Kevin
    Improve system stability and performance
        There are many libraries updated. The whole system becomes
        more stable and has better performance.
        You can check the list in the Lib directory.
        (7188E_Lib_List_162.txt)
        
    For porgramming
        Add function
            Add functions for Modbus/TCP master. 
            There are 3 new functions:
                1. ModbusTCP_Init
                2. ModbusTCP_Master2Slave
                3. ModbusTCP_Close
            
            Using the function, 7188E/8000E can link to 8 remote 
            Modbus/TCP devices.
            The function can detect whether the remote Modbus/TCP device
            is alive or not. If the device crashs, the function 
            can know the connection is disconnected.
            And it can recover the connection once the remote Modbus/TCP 
            device becomes alive.

    === Relative information ======
    Modbus Utility: Ver 1.3.3 [2005,May,05]    
    
    MiniOS7 image file: 
        For 40M CPU (updated)
            2.00 build 002, Jul 01 2005
            CD:\Napdos\Modbus\7188e\OS_Image\For_40M\e-050701.img
------------------------------------------------------------------------
           
Version 1.6.1 [05,May,2005] by Kevin
    Change mapping for Modbus/RTU gateway
        About 'Station per COM port' option
        Before: Every COM port is assigned the station number no matter
                what COM port mode it is. But only the COM port mode 
                set to Modbus/RTU gateway can gateway Modbus/TCP to
                Modbus/RTU. That is to say, some station numbers are 
                assigned to some COM port but not used.
        Now: Modbus/RTU station numbers are only assigned to the COM 
             port that is set to Modbus/RTU gateway mode.
             
        The Modbus Utility on-line help , revision information shows 
        the difference.
        
    === Relative information ======
    Modbus Utility: Ver 1.3.3 [2005,May,05] (Updated) (Necessary)
------------------------------------------------------------------------

Version 1.6.0 [08,Apr,2005] by Kevin
    Let NAP OPC server support Modbus/RTU device that "use Modbus/RTU 
    Gateway mode to connect to the COM port of the 7188.
        Before:
            OPC server only supports internal registers of 
            7188XA/7188XA/7188XB.
------------------------------------------------------------------------
            
Version 1.5.9 [22,Sep,2004] by Kevin
    Provides a Modbus/RTU library (MBR7Ennn.Lib and MBRTU_7E.h) for 7188EX.
    It can be integrated to user's program that not developed on 
    the Xserver architecture.
    Demo program please refer MBDemo00.
------------------------------------------------------------------------

Ver 1.5.8 [26,Jun,2004] by Kevin
    Improve communication performance (reduce 3ms or 6 ms communication time)
        Before:
            Configuration 0:
                Wiring: PC <===> 7188
                Request internal register takes 
                (Communication time)+(Delay 3 ms)+(CPU calculation)
                
            Configuration 1:
                Wiring: PC <===> 7188 <===> Modbus/RTU device
                Request Modbus/RTU devicetakes  
                (Communication time)+(Delay 3 ms)+(CPU calculation)
                (Communication time)+(Delay 3 ms)+(CPU calculation) 
                
        Ver 1.5.8
            Configuration 0:
                Wiring: PC <===> 7188
                Request internal register takes 
                (Communication time)+(CPU calculation)
                
            Configuration 1:
                Wiring: PC <===> 7188 <===> Modbus/RTU device
                Request Modbus/RTU devicetakes  
                (Communication time)+(CPU calculation)
                (Communication time)+(CPU calculation)                
                
        Note: CPU calculation takes 1~2ms
        
    (for mofifying the Modbus firmware only)
        Modify function ModbusMaster2Slave:
            supports modbus function code 5 and 6.
            cleafy return value
                before: always return 0
                now: return different value to identify different 
                     situation, such as timeout, CRC check error,
                     exception code, etc.
        
        Add global variables
            iModbusRequest_Fun
            iModbusRequest_Addr;
            iModbusRequest_IOCount;
------------------------------------------------------------------------

Ver 1.5.7 [16,Feb,2004] by Kevin
    Support 7188XA      
------------------------------------------------------------------------

Ver 1.5.6 [1,Jan,2004] by Kevin
    Fix bug:
        1. Cannot communicate with NAP OPC server.
------------------------------------------------------------------------

Ver 1.5.5 [24,Nov,2003] by Kevin
    Support multi Modbus/RTU uplink COM port (slave COM port)
        Usage 1: Run the Modbus Utility to set the COM port 
                 enable mode to UpLink.
        Usage 2: Modify the Modbus firmware (in C language) to call function
                 Set_EnableMode to set the COM port enable mode to UpLink.
                
    Remove functions (for mofifying the Modbus firmware only)
        Set_DebugPort, Set_ModbusUpLinkPort
    
    Remove variables (for mofifying the Modbus firmware only)
        iModbusUpLinkPort, iDebugPort
            
    Note: the C source code relative to the Modbus kernel and configuration
          in the Modbus demos are also chnaged. Please refer to 
          MBDemo00 (for 7188XB) or MTDemo00 (for 7188EX) to modify 
          your customized Modbus firmware to use the new version library.
          
===============================================================================
Ver 1.5.4 [14,Aug,2003] by Kevin
    Fixes bug:
        1. When chnanging the COM port mode in Modbus Utility,
           you must reboot the 7188E to effect the change.
           The bug is due to the functions EnableCom and DisableCom
           of the Xserver don't work properly. The bug is fixed when
           update the Xserver library (Vcom3009.Lib) to 4,Aug,2003.
           Now, you don't reboot the 7188E to effect the change.
           
    Open function:
        1. Allow users change COM port settings (data bit, stop bit, parity).
           Note: to use the function, the Modbus Utility must be version 1.2.4    
           
    MiniOS7 image file:
        for 7188EX: 2.00.001 (e-030529.img)
        for 7188XB: 2.00.001 (xb030516.img)       

===============================================================================           
Ver 1.5.3 [26,Jun,2003] by Kevin
    Change name of firmware (exe file running on 7188EX)
        The original name is MBTCP_7E.exe no mater what version it is.
        The new name becomes MBT7_nnn.exe which nnn means the version.
        For example: MBT7_153.exe means the firmware version is "1.5.3".
        
    Update 7188EL.Lib (25,Jun,2003)
        If you just need the default firmware (don't need to modify the 
        firmware in C language), then discard the things 
        that I will explain following.

        Detail explaination:  
        The COM1 and COM2 of the 7188E has two working modes,       
        one is normal mode and another is DMA mode.
        To install the COM1/2 in the normal mode, you need to call InstallCom.
        To install the COM1/2 in the DMA mode, you need to call InstallCom1_DMA
        and InstallCom2_DMA. The default working mode of the COM1/2 of the 
        Xserver kernel is the DMA mode.
        
        The bug is:
            When calling InstallCom to change the COM port working mode from 
            DMA mode to normal mode, the COM1/2 cannot work properly.
            
        Now the bug is fixed after updating the 7188EL.Lib.

===============================================================================
Ver 1.5.3 [13,Jun,2003] by Kevin
    Fix bug:
        1. Cannot communicate with NAP OPC server.
        
    Modify function ModbusMaster2Slave:
        Add function code 01 and 03 to read back DO and AO registers.
        
    7188E-MTCP supports Modbus/RTU slave function.

===============================================================================    
Ver 1.5.2 [30,Apr,2002] by Kevin
    Change declaration
        1. MAX_REGISTER_COUNT 
                Before: #define MAX_REGISTER_COUNT 100
                Now:    int MAX_REGISTER_COUNT=500;
           
        2. iMemory_DI, iMemory_DO, iMemory_AI, iMemory_AO 
                Before:  unsigned char iMemory_DI[MAX_REGISTER_COUNT];
                Now:     unsignedchar *iMemory_DI;
 
        Above changes let users can re-assign MAX_REGISTER_COUNT in the .C 
        source code to enlarge the memory buffer size(default is 500).
        Usage:
            MAX_REGISTER_COUNT=512;
            iRet=InitModbus();          

===============================================================================
Ver 1.5.1 [31,Mar,2002] by Kevin
	Fix bug:
		When access less than 8 DI or DO registers, return error message.

===============================================================================
Ver 1.5.0 [17,Mar,2003] by Kevin
	Change:
		1. Modbus function code (for configuration) 
		   from 39 to 107.
		2. iModbusInternalID ==> iModbusNetID
	
	Note:
		Modbus Utility must be version 1.2.0 or later.
        MiniOS7 image file must be e-021023.img.

===============================================================================
Ver 1.4.0 [31,Dec,2002] by Kevin
	1. Remove all debug code to speed up performance.
	2. Use EEPROM to store settings and support Modbus Utility 
	   to configure 7188E -MTCP.

===============================================================================
Ver 1.3.0 [16,Oct,2002] by Kevin
	7188XB and 7188E use same Modbus kernel
