Exemple #1
0
//-------------------------------------------------------------------------------------
int
main(void)
{
	int count = 0;
	int i, j ;

	keypad_4x4_init();

	while(count <100)
	{
	    keypad_4x4_scan();

	    for(i=0 ; i< 4 ;i++)
	    {
            	for(j=0 ; j< 4 ;j++)
            	{
		    if(key_status[i][j]==0)
			printf("%c " ,key_map[i][j]);
		    else
		        printf("O ");
//		     printf("%c " ,key_status[i][j]+'0');
            	}
		printf("\n");
	    }
	    printf("========================\n");

            BBBIO_sys_delay_ms(100);
	    count ++;
	}

	iolib_free();
	return 0;
}
Exemple #2
0
void init_screen():

char black_image_path[] = "/mnt/data/bin/tangible-test.sh /mnt/data/img/default_400x240/monochrome/black.png";
char fanny_hug_image_path[] = "/mnt/data/bin/tangible-test.sh /mnt/data/img/default_400x240/monochrome/fanny_hug.png";
char fanny_heartbeat_image_path[] = "/mnt/data/bin/tangible-test.sh /mnt/data/img/default_400x240/monochrome/fanny_heartbeat.png";
char fanny_buzz_image_path[] = "/mnt/data/bin/tangible-test.sh /mnt/data/img/default_400x240/monochrome/fanny_buzz.png";

int main(void)
{

        iolib_init();

        iolib_setdir(8,30, DIR_OUT); //Pin 30 on P8 expansion header.
        iolib_setdir(8,39, DIR_OUT); //Pin 39 on P8 expansion header.

        init_screen();

        while(1)
        {
         
                debug_schedule();

                //test_schedule();
                //break;
        }

        iolib_free();

        return(0);
}
int
main(void)
{
	int del;
	iolib_init(); /* Initialize I/O library - required */
	iolib_setdir(8,11, BBBIO_DIR_IN);   /* Set pin P8 - 11 as input */
	iolib_setdir(8,12, BBBIO_DIR_OUT);  /* Set pin P8 - 12 as output */

	int count = 0;
	while(count < 50)
	{
		count ++ ;
		if (is_high(8,11))   /* Check if in is high (i.e. button pressed) */
		{
			del=100; /* fast speed */
		}
		if (is_low(8,11))    /* Check if in is low (i.e button is released) */
		{
			del=500; /* slow speed */
		}

		pin_high(8,12);       /* Set pin to high - LED on */
		iolib_delay_ms(del);  /* Delay for 'del' msec */
		pin_low(8,12);		  /* Set pin to low - LED off */
		iolib_delay_ms(del);  /* Delay for 'del' msec */

	}
	iolib_free();  /* Release I/O library prior to program exit - required */
	return(0);
}
/*
 * Class:     org_bulldog_beagleboneblack_jni_NativeGpio
 * Method:    teardown
 * Signature: ()Z
 */
JNIEXPORT jboolean JNICALL Java_org_bulldog_beagleboneblack_jni_NativeGpio_teardown
  (JNIEnv * env, jclass clazz) {
	int ret = iolib_free();
	if(ret < 0) {
		return JNI_FALSE;
	}

	return JNI_TRUE;
}
Exemple #5
0
/* ----------------------------------------------------------- */
int main(void)
{
	int i ,j;
	unsigned int *buf_ptr = &buffer[0];

	/* BBBIOlib init*/
	iolib_init();

	/* using ADC_CALC toolkit to decide the ADC module argument .
	 *
	 *	#./ADC_CALC -f 44100 -t 30
	 *
	 *	Suggest Solution :
	 *		Clock Divider : 34 ,    Open Dly : 1 ,  Sample Average : 1 ,    Sample Dly : 1
	 */
	const int clk_div = 34 ;
	const int open_dly = 1;
	const int sample_dly = 1;

	BBBIO_ADCTSC_module_ctrl(clk_div);
	BBBIO_ADCTSC_channel_ctrl(BBBIO_ADC_AIN0, BBBIO_ADC_STEP_MODE_SW_CONTINUOUS, open_dly, sample_dly, BBBIO_ADC_STEP_AVG_1, buffer, AUDIO_BUFFER_SIZE);

	struct timeval t_start,t_end;
 	float mTime =0;

	for(i = 0 ; i < 5 ; i++) {
		/* fetch data from ADC */
		BBBIO_ADCTSC_channel_enable(BBBIO_ADC_AIN0);

		gettimeofday(&t_start, NULL);
		BBBIO_ADCTSC_work(AUDIO_BUFFER_SIZE);
		gettimeofday(&t_end, NULL);

		/* **********************************************************
		*
		*	Add your Socket transmit function in this block
		*
		************************************************************* */

		mTime = (t_end.tv_sec -t_start.tv_sec)*1000000.0 +(t_end.tv_usec -t_start.tv_usec);
		mTime /=1000000.0f;
		printf("Sampling finish , fetch [%d] samples in %lfs\n", AUDIO_BUFFER_SIZE, mTime);
	}
	BBBIO_ehrPWM_Disable(BBBIO_PWMSS0);


	iolib_free();
	return 0;
}
Exemple #6
0
/* ----------------------------------------------------------- */
int main(void)
{
	unsigned int sample;
	int i ,j;
	unsigned int buffer_AIN_0[100] ={0};
	unsigned int buffer_AIN_1[100] ={0};

	/* BBBIOlib init*/
	iolib_init();

	/*ADC work mode : Busy polling mode  */
	//BBBIO_ADCTSC_module_ctrl(BBBIO_ADC_WORK_MODE_BUSY_POLLING, 1);
	BBBIO_ADCTSC_module_ctrl(BBBIO_ADC_WORK_MODE_TIMER_INT, 1);

	/*ADC work mode : Timer interrupt mode
	 *	Note : This mode handle SIGALRM using signale() function in BBBIO_ADCTSC_work();
	 */
	//BBBIO_ADCTSC_module_ctrl(BBBIO_ADCTSC_module_ctrl(BBBIO_ADC_WORK_MODE_BUSY_POLLING, 1);

	BBBIO_ADCTSC_channel_ctrl(BBBIO_ADC_AIN0, BBBIO_ADC_STEP_MODE_SW_CONTINUOUS, 0, 1, BBBIO_ADC_STEP_AVG_1, buffer_AIN_0, 100);
	BBBIO_ADCTSC_channel_enable(BBBIO_ADC_AIN0);

	BBBIO_ADCTSC_channel_ctrl(BBBIO_ADC_AIN1, BBBIO_ADC_STEP_MODE_SW_CONTINUOUS, 0, 1, BBBIO_ADC_STEP_AVG_1, buffer_AIN_1, 100);
	BBBIO_ADCTSC_channel_enable(BBBIO_ADC_AIN1);

	for(i = 0 ; i < 3 ; i++) {
		printf("Start sample , fetch 10 sample \n");
		BBBIO_ADCTSC_work(10);

		printf("Channel 0 :\n");
		for(j = 0 ; j < 10 ; j++) {
			sample = buffer_AIN_0[j];
			printf("\t[sample : %d , %f v]\n", sample, ((float)sample / 4095.0f) * 1.8f);
		}
		printf("Channel 1 :\n");
		for(j = 0 ; j < 10 ; j++) {
			sample = buffer_AIN_1[j];
			printf("\t[sample : %d , %f v]\n", sample, ((float)sample / 4095.0f) * 1.8f);
                }
		printf("------------------------------\n");
		sleep(1);
	}

	iolib_free();
	return 0;
}
Exemple #7
0
int main(void)
{
	iolib_init();
	int i=0;
	float SM_1_duty ;	//Sermotor 1 , connect to ePWM0A

	for(i=0 ;i<= 180 ;i+=10)
	{
	    SM_1_duty  = 4.0f + i* 0.04444f ;
	    printf("Angle : %d , duty : %f\n" ,i ,SM_1_duty);
	    BBBIO_PWMSS_Setting(0 , 50.0f ,SM_1_duty , SM_1_duty);
	    sleep(1);
	}

	iolib_free();
	return(0);
}
Exemple #8
0
//-----------------------------------------------
int main(void)
{
	int DebFlag  =DEBOUNCING_BUTTON_UP;
	int DebCount = 0;
	iolib_init();

	iolib_setdir(8,12, BBBIO_DIR_IN);
	iolib_setdir(8,11, BBBIO_DIR_IN);

#ifdef DEBOUNCING
        BBBIO_sys_Enable_Debouncing(8 ,11 ,10);
#else
	BBBIO_sys_Disable_Debouncing(8 ,11);
#endif

	printf("OK\n");

        int count = 0;
	int Test =0;
        while(Test <10)
        {
                count ++ ;
                if (is_high(8,11))
                {
		    DebFlag = DEBOUNCING_BUTTON_DOWN;
                }
		else
                {
		    if(DebFlag == DEBOUNCING_BUTTON_DOWN)
		    {
			DebCount ++ ;
			DebFlag = DEBOUNCING_BUTTON_UP ;
		    }
                }
		if(count == 10000000)
		{
		    printf("%d\n",DebCount);
		    count =0;
		    Test ++;
		}
        }
	BBBIO_sys_Disable_Debouncing(8 ,11);
        iolib_free();
	printf("Release\n");
        return(0);
}
int main(void)
{
	iolib_init(); /* Initialize I/O library - required */

	    pthread_t thread1, thread2,thread3, main_id;
	    //initial the data buffer and create the threads
	    main_id=pthread_self();
	    buffer_init(b);
	    pthread_create( &thread1, NULL, &producerth1, NULL);
	    pthread_create( &thread2, NULL, &producerth2, NULL);
	    pthread_create( &thread3, NULL, &comsumerth, NULL);

	    //join the thread when finished
	    pthread_join( thread1, NULL);
	    pthread_join( thread2, NULL);
	    pthread_join( thread3, NULL);
	iolib_free();  /* Release I/O library prior to program exit - required */
	return(0);
}
Exemple #10
0
//------------------------------------------------------------------------
int
main(void)
{
	int raw_temp  =0;
	int i= 0;
	iolib_init();
	iolib_setdir(8,11, BBBIO_DIR_OUT);
	iolib_setdir(8,12, BBBIO_DIR_OUT);
        iolib_setdir(8,15, BBBIO_DIR_IN);
        iolib_setdir(8,16, BBBIO_DIR_OUT);


	for(i=0 ;i< 10 ; i++)
	{
	    raw_temp = ADT7301_read();
	    printf("%f\n",(float)(raw_temp)/32.0f);
	    sleep(1);
	}
	iolib_free();
	return 0 ;
}
Exemple #11
0
/* ----------------------------------------------------------- */
int main(void)
{
	unsigned int sample;
	int i ,j;
	unsigned int buffer_AIN_0[BUFFER_SIZE] ={0};
	unsigned int buffer_AIN_1[BUFFER_SIZE] ={0};

	/* BBBIOlib init*/
	iolib_init();

	/* using ADC_CALC toolkit to decide the ADC module argument . Example Sample rate : 10000 sample/s
	 *
	 *	#./ADC_CALC -f 10000 -t 5
	 *
	 *	Suggest Solution :
	 *		Clock Divider : 160 ,   Open Dly : 0 ,  Sample Average : 1 ,    Sample Dly : 1
	 *
	 */
//	const int clk_div = 34 ;
	const int clk_div = 160;
	const int open_dly = 0;
	const int sample_dly = 1;

	/*ADC work mode : Timer interrupt mode
	 *	Note : This mode handle SIGALRM using signale() function in BBBIO_ADCTSC_work();
	 */
	BBBIO_ADCTSC_module_ctrl(BBBIO_ADC_WORK_MODE_TIMER_INT, clk_div);

	/*ADC work mode : Busy polling mode  */
	/* BBBIO_ADCTSC_module_ctrl(BBBIO_ADC_WORK_MODE_BUSY_POLLING, clk_div);*/


	BBBIO_ADCTSC_channel_ctrl(BBBIO_ADC_AIN0, BBBIO_ADC_STEP_MODE_SW_CONTINUOUS, open_dly, sample_dly, \
				BBBIO_ADC_STEP_AVG_1, buffer_AIN_0, BUFFER_SIZE);

	BBBIO_ADCTSC_channel_ctrl(BBBIO_ADC_AIN1, BBBIO_ADC_STEP_MODE_SW_CONTINUOUS, open_dly, sample_dly, \
				BBBIO_ADC_STEP_AVG_1, buffer_AIN_1, BUFFER_SIZE);
	

	//BBBIO_ADCTSC_module_ctrl(BBBIO_ADCTSC_module_ctrl(BBBIO_ADC_WORK_MODE_BUSY_POLLING, 1);

//	BBBIO_ADCTSC_channel_ctrl(BBBIO_ADC_AIN1, BBBIO_ADC_STEP_MODE_SW_CONTINUOUS, 0, 1, BBBIO_ADC_STEP_AVG_1, buffer_AIN_1, 100);

	for(i = 0 ; i < 3 ; i++) {
		printf("Start sample , fetch %d sample \n", BUFFER_SIZE);
		BBBIO_ADCTSC_channel_enable(BBBIO_ADC_AIN0);
		BBBIO_ADCTSC_channel_enable(BBBIO_ADC_AIN1);
		BBBIO_ADCTSC_work(SAMPLE_SIZE);

		printf("AIN 0 :\n");
		for(j = 0 ; j < SAMPLE_SIZE ; j++) {
			sample = buffer_AIN_0[j];
			printf("\t[sample : %d , %f v]\n", sample, ((float)sample / 4095.0f) * 1.8f);
		}
		printf("AIN 1 :\n");
		for(j = 0 ; j < SAMPLE_SIZE ; j++) {
			sample = buffer_AIN_1[j];
			printf("\t[sample : %d , %f v]\n", sample, ((float)sample / 4095.0f) * 1.8f);
                }
		printf("------------------------------\n");
		sleep(1);
	}

	iolib_free();
	return 0;
}
void inputCleanup() {
	iolib_free();
}
Exemple #13
0
/* ----------------------------------------------------------- */
int main(void)
{
	unsigned int sample;
	int i ,j;
	unsigned int buffer_AIN_2[BUFFER_SIZE] ={0};

	time_t rawtime;
	char data_file_name[255];
	FILE* data_file;

	/* BBBIOlib init*/
	iolib_init();

	/* using ADC_CALC toolkit to decide the ADC module argument . Example Sample rate : 10000 sample/s
	 *
	 *	#./ADC_CALC -f 10000 -t 5
	 *
	 *	Suggest Solution :
	 *		Clock Divider : 160 ,   Open Dly : 0 ,  Sample Average : 1 ,    Sample Dly : 1
	 *
	 */
//	const int clk_div = 34 ;

	// ADC sampling settings
	const int clk_div = 25;
	const int open_dly = 5;
	const int sample_dly = 1;

	/*ADC work mode : Timer interrupt mode
	 *	Note : This mode handle SIGALRM using signale() function in BBBIO_ADCTSC_work();
	 */
	BBBIO_ADCTSC_module_ctrl(BBBIO_ADC_WORK_MODE_TIMER_INT, clk_div);	// use timer interrupts

	/*ADC work mode : Busy polling mode  */
	/* BBBIO_ADCTSC_module_ctrl(BBBIO_ADC_WORK_MODE_BUSY_POLLING, clk_div);*/


	// microphone is connected to AIN2
	BBBIO_ADCTSC_channel_ctrl(BBBIO_ADC_AIN2, BBBIO_ADC_STEP_MODE_SW_CONTINUOUS, open_dly, sample_dly, \
				BBBIO_ADC_STEP_AVG_1, buffer_AIN_2, BUFFER_SIZE);
	

	//BBBIO_ADCTSC_module_ctrl(BBBIO_ADCTSC_module_ctrl(BBBIO_ADC_WORK_MODE_BUSY_POLLING, 1);

	//	BBBIO_ADCTSC_channel_ctrl(BBBIO_ADC_AIN1, BBBIO_ADC_STEP_MODE_SW_CONTINUOUS, 0, 1, BBBIO_ADC_STEP_AVG_1, buffer_AIN_1, 100);

	printf("Starting capture...\n");
	// get time
	time(&rawtime);

	// start capture
	BBBIO_ADCTSC_channel_enable(BBBIO_ADC_AIN2);
	BBBIO_ADCTSC_work(SAMPLE_SIZE);

	// format file name
	snprintf(data_file_name, sizeof(data_file_name), "%s", ctime(&rawtime));	//copy time to string
	data_file_name[strcspn(data_file_name,"\n")] = 0;							//remove trailing newline
	// convert space to _ in filename
	char *p = data_file_name;
	for (i=0; i < strlen(data_file_name); i++){
		if (data_file_name[i] == '\0') break;
		else if (data_file_name[i] == ' ') data_file_name[i] = '_';

	}
	strcat(data_file_name,".dat" );
	
	printf("saving sound data to: %s\n",data_file_name);
	data_file = fopen(data_file_name,"w");	// open file in write mode
	
	// add current time value to top of file
	fprintf(data_file, "%s", ctime(&rawtime));

	// write buffer to file
	for(j = 0 ; j < SAMPLE_SIZE ; j++)
		fprintf( data_file, "%u\n", buffer_AIN_2[j] );

	fclose( data_file );

	iolib_free();
	return 0;
}
void bbio::close(){
    BBBIO_GPIO_low(BBBIO_GPIO1 ,port_din_SPI[0]);
    BBBIO_GPIO_low(BBBIO_GPIO1 ,port_clk_SPI[0]);
    BBBIO_GPIO_low(BBBIO_GPIO1 ,port_cs_SPI[0]);
    iolib_free();
}
Exemple #15
0
//-----------------------------------------------------------------
int
main(void)
{
	struct timeval t_start,t_end;
	pid_t PID ;
	struct sched_param param;
	int maxpri = sched_get_priority_max(SCHED_FIFO);

	param.sched_priority =maxpri ;
	PID =getpid();
//	sched_setscheduler(PID , SCHED_FIFO ,&param );

	iolib_init();
	iolib_setdir(8,11, BBBIO_DIR_OUT);	// Server motor
	iolib_setdir(8,12, BBBIO_DIR_OUT);
	iolib_setdir(8,15, BBBIO_DIR_OUT);
	iolib_setdir(8,16, BBBIO_DIR_OUT);
	iolib_setdir(8,22, BBBIO_DIR_OUT);
        iolib_setdir(8,23, BBBIO_DIR_OUT);
	BBBIO_sys_Enable_GPIO(BBBIO_GPIO2);

	BBBIO_GPIO_set_dir(BBBIO_GPIO2 ,	// key pad pin
                           BBBIO_GPIO_PIN_12 |BBBIO_GPIO_PIN_10 |BBBIO_GPIO_PIN_8 |BBBIO_GPIO_PIN_6 ,   // input
                           BBBIO_GPIO_PIN_13 |BBBIO_GPIO_PIN_11 |BBBIO_GPIO_PIN_9 |BBBIO_GPIO_PIN_7 );  // output

	int i , j ;
	// recover
        ActionPush(SM_BUTTOM ,90 ,0);
        ActionPush(SM_ARM1 ,90 ,0);
        ActionPush(SM_ARM2 ,110 ,0);
        ActionPush(SM_ARM3 ,150 ,0);
        ActionPush(SM_HAND ,90 ,0);
        ActionStart();

	Angle_Arm_1 =90 ;
	Angle_Arm_2 =110 ;
	Angle_Arm_3 =150;
	Angle_Hand =90 ;
	Angle_Buttom = 90 ;

        //-----------------------------------------
        // create 4x4 scan therad

        pthread_t pid_4x4 ;
        int ret ;
        ret = pthread_create(&pid_4x4, NULL, (void *)Thread_4x4_scan, NULL);

        //-----------------------------------------

	usleep(100000);

	float max_Angle =0 ;


for(j=0 ;j <5 ; j ++)
{
	for(i=0 ; i<7 ;i++)
	{
            ActionPush(SM_BUTTOM ,Action[i][0] ,0);
            ActionPush(SM_ARM1 ,Action[i][1] ,0);
            ActionPush(SM_ARM2 ,Action[i][2] ,0);
            ActionPush(SM_ARM3 ,Action[i][3] ,0);
            ActionPush(SM_HAND ,Action[i][4] ,0);
            ActionStart();
	}
}

/*
	while(key_status[3][3]==1)	//f
	{

	    ActionPush(SM_BUTTOM ,Angle_Buttom ,0);
            ActionPush(SM_ARM1 ,Angle_Arm_1 ,0);
            ActionPush(SM_ARM2 ,Angle_Arm_2 ,0);
            ActionPush(SM_ARM3 ,Angle_Arm_3 ,0);
            ActionPush(SM_HAND ,Angle_Hand ,0);

            ActionStart();
	}
*/
        ActionPush(SM_BUTTOM ,90 ,0);
        ActionPush(SM_ARM1 ,90 ,0);
        ActionPush(SM_ARM2 ,110 ,0);
        ActionPush(SM_ARM3 ,150 ,0);
        ActionPush(SM_HAND ,90 ,0);
        ActionStart();

	//---------------------------

	pthread_join(pid_4x4,NULL);
	printf("Finish\n");

	iolib_free();
	return(0);
}
void FreeGpioA() 
{
	iolib_free();
}
Exemple #17
0
//-----------------------------------------------------------------
int
main(void)
{
	int del =5;
	iolib_init();
	printf("init finish\n");
/*
	BBBIO_GPIO_set_dir(BBBIO_GPIO1 , 0 ,
					BBBIO_GPIO_PIN_12 |
					BBBIO_GPIO_PIN_13 |
                                        BBBIO_GPIO_PIN_14 |
                                        BBBIO_GPIO_PIN_15 );
*/
	BBBIO_sys_Enable_GPIO(BBBIO_GPIO2);

	iolib_setdir(8,11, BBBIO_DIR_OUT);	// Scan A
	iolib_setdir(8,12, BBBIO_DIR_OUT);	// Scan B
        iolib_setdir(8,15, BBBIO_DIR_OUT);	// Scan C
        iolib_setdir(8,16, BBBIO_DIR_OUT);	// Scan D

	iolib_setdir(8,39, BBBIO_DIR_OUT);      // Seg A
	iolib_setdir(8,40, BBBIO_DIR_OUT);      // Seg B
        iolib_setdir(8,41, BBBIO_DIR_OUT);      // Seg C
        iolib_setdir(8,42, BBBIO_DIR_OUT);      // Seg D
        iolib_setdir(8,43, BBBIO_DIR_OUT);      // Seg E
        iolib_setdir(8,44, BBBIO_DIR_OUT);      // Seg F
        iolib_setdir(8,45, BBBIO_DIR_OUT);      // Seg G
        iolib_setdir(8,46, BBBIO_DIR_OUT);      // Seg . (point)


	printf("OK");

	int count = 0;
	int DisplayNumber =1234 ;
	while(count < 200)
	{
		count ++ ;
		pin_low(8,11);
		Display_Number(DisplayNumber / 1000);
		iolib_delay_ms(del);
		pin_high(8,11);

                pin_low(8,12);
                Display_Number(DisplayNumber / 100);
                iolib_delay_ms(del);
                pin_high(8,12);

                pin_low(8,15);
                Display_Number(DisplayNumber / 10);
                iolib_delay_ms(del);
                pin_high(8,15);

                pin_low(8,16);
                Display_Number(DisplayNumber);
                iolib_delay_ms(del);
                pin_high(8,16);
	}
	BBBIO_sys_Disable_GPIO(BBBIO_GPIO2);
	iolib_free();
	return(0);
}
Exemple #18
0
int main(int argc, char *argv[])
{
    int i = 0;
    unsigned char datatosend[20] = {0,1,2,3,4,5,6,7,8,9};
    unsigned char tmp_payload_xmit[PAYLOAD_BUF_LEN];

#ifdef MULTIPLE_COMMANDS

    char command[MAX_COMMAND_LEN];
    char string1[TXT_STR_LEN], string2[TXT_STR_LEN] = "quit";
    char default_argv[] = "";
    int i = 0;

#endif  //MULTIPLE_COMMANDS

#ifndef DEBUG

#ifdef USE_SPI

    //Open SPI:
    flexsea_spi_open();

    //Initialize IO library:
    iolib_init();
    iolib_setdir(RESET_PORT, RESET_PIN, DIR_OUT);
    pin_low(RESET_PORT, RESET_PIN);

#endif

#else

    printf("\nFlexSEA-Plan - Debug or Native USB\n==================================\n\n");

#ifdef USE_USB

    //Open USB (serial) port:
    flexsea_serial_open(100, 50000);

    /*

    	//Test code
    	for(i = 0; i < 30; i++)
    	{
    		tx_cmd_ctrl_mode(FLEXSEA_EXECUTE_2, CMD_WRITE, tmp_payload_xmit, PAYLOAD_BUF_LEN, CTRL_OPEN);
    		comm_gen_str(tmp_payload_xmit, comm_str_spi, PAYLOAD_BUF_LEN);
    		flexsea_serial_transmit(COMM_STR_BUF_LEN, comm_str_spi, 0);
    	}
    	*/

#endif

#endif

#ifdef MULTIPLE_COMMANDS

    while(fgets(command, sizeof(command), stdin))
    {
        int fake_argc = 1;

        //Fills fake_argv with empty strings to avoid sending old values with new commands
        for(i = 0; i < MAX_ARGS; i++)
        {
            fake_argv[i] = default_argv;
        }

        //First argument
        fake_argv[fake_argc] = strtok(command, delims);

        //Other arguments
        while( fake_argv[fake_argc] != NULL )
        {
            fake_argv[++fake_argc] = strtok(NULL, delims);
        }

        //Enable for terminal debug only:
        /*
        for(i = 0; i < MAX_ARGS; i++)
        {
            printf("fake_argv[%i] = %s\n", i, fake_argv[i]);
        }
         */

        //Do we want to exit? (exit when "quit" is received)
        strcpy(string1, fake_argv[1]);
        if(!strcmp(string1, string2))
        {
            printf("Quitting.\n");
            break;
        }
        else
        {
            //Parser for console commands:
            flexsea_console_parser(fake_argc, fake_argv);

            //Can we decode what we received?
            decode_spi_rx();
        }
    }

#endif  //MULTIPLE_COMMANDS

#ifdef SINGLE_COMMAND

    //Parser for console commands:
    parser_console(argc, argv);

    //Can we decode what we received?

#ifdef USE_SPI

    decode_spi_rx();

#endif

#ifdef USE_USB

    //decode_usb_rx();	ToDo

#endif

#endif  //SINGLE_COMMAND

#ifndef DEBUG

#ifdef USE_SPI

    //Close SPI:
    flexsea_spi_close();

    iolib_free();

#endif

#ifdef USE_USB

    //Close serial port:
    flexsea_serial_close();

#endif

#endif

    return 0;
}