/*
Serial.c : To get 64-bit hardware unique serial number. 
                                                                           
Compiler: BC++ 3.1,                                                            
          Turbo C ++ 1.01(3.01) (free from http://community.borland.com/museum)
          MSC 6.0,                                                             
          MSVC 1.52.                                                           
                                                                               
Compile mode: large                                                            
                                                                               
Project: serial.c                                                               
         ..\Lib\(8000E.Lib,7188XAL.Lib,7188XBL.Lib,7188XL.Lib or 7188EL.Lib)   
                                                                               
Hardware: 7188/8000

Detail description:
    The 64-bit hardware unique serial number is used to 
    protect use's software. Not every controller equips it. 
    You must check the detail specifics of the contorller. 
    
    You can type command 'Ver' under 7188> or i-8000> prompt to 
    list the number. If the controller doesn't equip a unique number,
    it shows 5A 5A 5A 5A 5A 5A 5A 5A.


[24 May,2005] by Bill
*/

#include "..\..\lib\vp2k.h"
/*---------------------------------------------------------------------------------*/

void main(void)
{
    unsigned char cProtectID[8]={0x01,0x6f,0x58,0x6c,0x10,0x00,0x00,0xb9};
    //unsigned char cProtectID[8]={0x01,0x7d,0xea,0xae,0x0d,0x00,0x00,0x24};
    unsigned char cSerialNumber[8];
    int bSerialNumOk;
    int i,iRet;
    
    InitLib();
    
    bSerialNumOk=1; //Assume the ID is nok at beginning.
	iRet=GetSerialNumber(cSerialNumber);
	
    //Print ("\n\r iRet= %d \n\r",iRet);
    if(iRet==NoError)
    {
        Print("Read Serial Number Ok!\r\n");
        Print("Serial Number:");
        for(i=0;i<8;i++){
        	Print("%02X ",cSerialNumber[i]);
            if(cSerialNumber[i]!=cProtectID[i]) bSerialNumOk=0;
		}
    }
    else 
    	bSerialNumOk=0;
    	    	
    //Print ("\n\r bSerialNumOk= %d \n\r",bSerialNumOk);
    if(bSerialNumOk > 0)
        Print("\r\nID Ok!");    
    else 
        Print("\r\n(%d)ID error!",iRet);
}
