/****************************************************************************
*
*	Name:			ioctl.c
*
*	Description:	E2 startup command routine.
*
*	Copyright:		(c) 1999 Conexant Systems Inc.
*
*	Revision:	Date:		Author:				Description:
*
*	Linux-1.0	May 29 2002	Shen Wei Wang			Created.
*					shenwei.wang@conexant.com
*
*****************************************************************************
*	$Author:   Shen Wei Wang  $
*	$Revision:   1.0  $
*	$Modtime:   May 29 2002 11:09:58  $
****************************************************************************/
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
//#include "cnxtusb.h"


#define DEVICE_FILE_NAME "E2Dev"

#define CNXT_IOCTL_START                      1
#define CNXT_IOCTL_STOP                       2
#define CNXT_IOCTL_DOWNLOAD		      50

void ioctl_set_msg(int file_desc, char *message, char c );
main(int argc, char *argv[])
{
	int file_desc, ret_val;
	int iNum=0;
	char * msg = "Setup the ADSL environment\n";

	if(argc == 1)
	{
		printf ("command number...\n");
		return;
	}

	file_desc = open (DEVICE_FILE_NAME , O_RDWR);
	if (file_desc < 0){
		printf ( "Can't open device file: %s\n", DEVICE_FILE_NAME);
		exit(-1);
	}
	printf ("Successed! Return Value = %d \n", file_desc);
	if ( !strcmp ( argv[1], "50" ) )
		iNum = 50;
	ioctl_set_msg(file_desc, msg, (char )iNum );//tolower(argv[1][0]));
	if (file_desc >= 0)
		close(file_desc);
	
}

void ioctl_set_msg(int file_desc, char *message, char c )
{
	int ret_val;
	ret_val = ioctl(file_desc, c , message);
	if(ret_val < 0){
		printf("ioctl_set_msg failed: %d\n", ret_val);
		exit(-1);
	}
	//printf ("Message is %s\n", message);
	printf("OK\n");
}
