/* Open port, then get serial number from DS2502. 

   Author: Moki Matsushima  

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software Foundation,
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 

    File level history (record changes for this file here.)

    read_sn.c   
    
    v 0.0.0 19 Sep 2018  by Winson Chen
    Read serial number on LX-2031 PAC
   
*/   
#include<stdio.h>
#include<stdlib.h>
#include <getopt.h>
#include "msw.h"

void usage();
char* const short_options = "hvs";
struct option long_options[] = {
	{"help", 0, NULL, 'h'},
	{"version", 0, NULL, 'v'},
	{"support", 0, NULL, 's'},
	{0, 0, 0, 0},
};

int main(int argc, char *argv[])
{
	int i, wRetVal, c;
	DWORD temp;
	unsigned char serial_num[8];

	
	while((c = getopt_long (argc, argv, short_options, long_options, NULL)) != -1)
	{
		switch (c)
		{
			case 'h':
				usage();
				return 0;
			case 'v':
				printf("SDK version = %s \n",GetSDKversion());
				return 0;
			case 's':
				printf("Support LX-2031\n");
				return 0;
			default:
                                printf("Try `read_sn -h' for more information.\n");
                                return 0;
                        break;
		}
	}

	Read_SN(serial_num);

	printf("serial number = ");
	for(i = 0; i < 8; i++)
		printf("%x ",serial_num[i]);
	printf("\n");

	return 0;
}

void usage()
{
	printf("Read Serial Number.\n");
	printf("-h,	display this help and exit\n");
	printf("-v,	output SDK version and exit\n");
	printf("-s,	support LinPAC platform\n");
}
