/*
 *  read_sn.c
 *
 *  v 0.0 2021.5.31
 *    Read serial number for LP-2841/9x81(i.MX8).
 */

#include<stdio.h>
#include<stdlib.h>
#include <getopt.h>
#include "msw.h"

int main(int argc, char *argv[])
{
	int num;
	int result = 0, pac_id = 0;
	unsigned char serial_num[8];

        result = linpac_read_pacid(&pac_id);

        if(result)
        {
                printf("pacid(%d) : LinPAC ID read error!\n",result);
                return FAILURE;
        }
	else
	{
		if(pac_id == LP2841 || pac_id == LP2841_4G)
                {
	            Read_SN(serial_num);
		    printf("LP-2841 serial number = ");

		    for(num=0; num<8; num++)
			printf("%02X ", serial_num[num]);

		    printf("\n");
                }
                else if(pac_id == LP9X81 || ALP9X81)
                {

			result = Open_Slot(0);
	
			if (result > 0) 
			{
				printf("open Slot failed!\n");
				return FAILURE;
			}

			//printf("%d\n",getSystemStatus());
			Read_SN(serial_num);

			printf("serial number = ");

			for(num=0; num<8; num++)
				printf("%02X ", serial_num[num]);

			printf("\n");

			Close_Slot(0);
                }
                else
                {
                        printf("Unknown Device!\n");
                }

        }

	return 0;
}

