Example #1
0
int cmd_module(int argc, char *argv[]) {
	struct module_info *header;
	
	header = (struct module_info *)pvPortMalloc(sizeof(struct module_info));
	
	if (argc < 2) {
		cmd_print("\r\ni2c exists: %d",I2CEE_exists(SLAVE_ADDRESS_MODULE1));
	} else {
		if(ustrncmp(argv[1],"write",5) == 0) {
			header->magic   = 0x3A;
			header->vendor  = 0x01;
			header->product = 0x01;
			header->version = 0x01;
			header->profile = ustrtoul(argv[2],NULL,16);
			header->modres  = ustrtoul(argv[3],NULL,16);
			header->dummy2  = 0;
			header->crc     = crcSlow((unsigned char *)header, sizeof(struct module_info)-sizeof(header->crc));
			
			I2CEE_write(SLAVE_ADDRESS_MODULE1,(unsigned char *) header, sizeof(struct module_info), 0);
			vTaskDelay(100 / portTICK_RATE_MS); // there must be a delay after write or avoid I2CEE_read()
		}
		I2CEE_read(SLAVE_ADDRESS_MODULE1, (unsigned char *) header, sizeof(struct module_info), 0);
		cmd_print("\r\ni2c module magic: %X vendor: %X product: %X version: %X profile: %X modres: %X", header->magic, header->vendor, header->product, header->version, header->profile, header->modres);


	}

	vPortFree(header);
	return(0);
}
Example #2
0
//*****************************************************************************
//
// Command: date
//
// Set the current system date.  Use format "DD/MM/YYYY"
//
//*****************************************************************************
int
CMD_date(int argc, char **argv)
{
    const char *pcNext;

    //
    // Check the argument count and return errors for too many or too few.
    //
    if(argc == 1) {
        return(CMDLINE_TOO_FEW_ARGS);
    }
    if(argc > 2) {
        return(CMDLINE_TOO_MANY_ARGS);
    }

    //
    // Convert the date to unsigned long
    //
    g_ui32DayIdx = ustrtoul(argv[1], &pcNext, 10);
    g_ui32MonthIdx = ustrtoul(pcNext+1, &pcNext, 10) - 1;
    g_ui32YearIdx = (ustrtoul(pcNext+1, NULL, 10) - 2000);

    //
    // Perform the conversions to a time struct and store in the hibernate
    // module after doing a minimal amount of validation.
    //
    if((g_ui32DayIdx > 31) || (g_ui32MonthIdx > 11)) {
        return(CMDLINE_INVALID_ARG);
    }

    DateTimeSet();

    return(0);
}
Example #3
0
int
CMD_MsParam(int argc, char **argv)
{
	uint32_t ui32No;
	uint32_t ui32Param;
	uint32_t ui32Value;
	int i;
    //
    // Keep the compiler happy.
    //
    (void)argc;
    (void)argv;
	if(argc == 4)
	{
		ui32No 	  =	ustrtoul(argv[1], 0, 10);
		ui32Param = ustrtoul(argv[2], 0, 10);
		ui32Value = ustrtoul(argv[3], 0, 10);
		for (i = 0; i < NUMBER_OF_SLAVES; i++)
		  {
		    if (i == ui32No)
		    {
		      arrayTxBytes[i] = (uint8_t)ui32Param;
		      arrayValues[i] = ui32Value;
		    }
		    else
		    {
		      arrayTxBytes[i] = cSPIN_NOP;
		      arrayValues[i] = cSPIN_NOP;
		    }
		  }
		cSPIN_All_Slaves_Set_Param(NUMBER_OF_SLAVES,arrayTxBytes,arrayValues);
	}
	
    return (0);
}
Example #4
0
int
CMD_MgParam(int argc, char **argv)
{
	uint32_t ui32No;
	uint32_t ui32Param;
	int i;
    //
    // Keep the compiler happy.
    //
    (void)argc;
    (void)argv;
	if(argc == 3)
	{
		ui32No 	  =	ustrtoul(argv[1], 0, 10);
		ui32Param = ustrtoul(argv[2], 0, 10);
		for (i = 0; i < NUMBER_OF_SLAVES; i++)
		  {
		    if (i == ui32No)
		    {
		      commandArray[i] = (uint8_t)ui32Param;
		    }
		    else
		    {
		      commandArray[i] = cSPIN_NOP;
		    }
		  }
		cSPIN_All_Slaves_Set_Param(NUMBER_OF_SLAVES,commandArray,responseArray);
		UARTprintf("Dev %d Reg %2X = %2X\n",ui32No,ui32Param,responseArray[ui32No]);
	}
	
    return (0);
}
//*****************************************************************************
//
//Command: time24
//
// Set the current system time. Use format "HH:MM:SS"
//
//*****************************************************************************
int
CMD_time24(int argc, char **argv)
{
    const char *pcNext;

    //
    // Check the argument count and return errors for too many or too few.
    //
    if(argc == 1)
    {
        return(CMDLINE_TOO_FEW_ARGS);
    }
    if(argc > 2)
    {
        return(CMDLINE_TOO_MANY_ARGS);
    }

    //
    // Convert the user string to unsigned long hours and minutes.
    //
    g_ui32HourIdx = ustrtoul(argv[1], &pcNext, 10);
    g_ui32MinIdx = ustrtoul(pcNext + 1, NULL, 10);

    //
    // Perform the conversions to a time struct and store in the hibernate
    // module.  Also do some minimal checking on the input data.
    //
    if((g_ui32HourIdx < 24) && (g_ui32MinIdx < 60))
    {
        DateTimeSet();
    }

    return(0);
}
Example #6
0
//'N hh mm ddddddd e'
int cmd_alarm_set(int argc, char **argv)
{
    if(argc == 6)
    {
        alarm_t    newalarm;
        alarm_id_t na_id;

        na_id = (alarm_id_t)ustrtoul(argv[1], 0, 10);

        if(na_id<=ALARM_CT)
        {
            day_t temp;

            newalarm.hour         = (uint8_t)ustrtoul(argv[2], 0, 10);
            newalarm.minute       = (uint8_t)ustrtoul(argv[3], 0, 10);
            temp                  = (day_t)ustrtoul(argv[4], 0, 2);
            newalarm.enable_flags = ( ((uint8_t)ustrtoul(argv[5], 0, 10)) == 1 ) ? ALARM_ENABLE : 0;

            //bit order must be reversed - too tired for something clever
            newalarm.day_of_week  = 0;
            cmd_printf("%02X:",temp);

            newalarm.day_of_week |= ( ( temp & 0x40 ) >> 6 );
            newalarm.day_of_week |= ( ( temp & 0x20 ) >> 4 );
            newalarm.day_of_week |= ( ( temp & 0x10 ) >> 2 );
            newalarm.day_of_week |= ( ( temp & 0x08 )      );
            newalarm.day_of_week |= ( ( temp & 0x04 ) << 2 );
            newalarm.day_of_week |= ( ( temp & 0x02 ) << 4 );
            newalarm.day_of_week |= ( ( temp & 0x01 ) << 6 );

            cmd_printf("%02X\n",newalarm.day_of_week);

            alarm_set(na_id, &newalarm);
        }
//*****************************************************************************
//
// This function implements the "weprom" command.  It writes a single byte to
// a given location in the I2C flash part on the daughter board.  This is not
// used in the application but is included in case you find a use for it in
// your code.
//
//*****************************************************************************
int
Cmd_weprom(int argc, char *argv[])
{
    const char *pcPos;
    tBoolean bRetcode;
    unsigned long ulAddr, ulVal;

    //
    // Were we passed the correct number of parameters?
    //
    if(argc < 3)
    {
        return(COMMAND_TOO_FEW_ARGS);
    }

    if(argc > 3)
    {
        return(CMDLINE_TOO_MANY_ARGS);
    }

    //
    // Get the parameters.
    //
    ulAddr = ustrtoul(argv[1], &pcPos, 0);
    ulVal  = ustrtoul(argv[2], &pcPos, 0);

    if(ulAddr >= 128)
    {
        UARTprintf("Error: Write address must be between 0 and 127.\n");
        return(COMMAND_INVALID_ARG);
    }

    //
    // Tell the user what we are about to do.
    //
    UARTprintf("Writing value %d (0x%02x) to I2C flash address 0x%02x\n",
               ulVal, ulVal, ulAddr);

    //
    // Write the byte to the flash device.
    //
    bRetcode = EEPROMWritePolled((unsigned char)(ulAddr & 0xFF),
                                 (unsigned char)(ulVal & 0xFF));

    if(bRetcode)
    {
        UARTprintf("Byte written successfully.\n");
    }
    else
    {
        UARTprintf("Error writing byte!\n");
    }

    return(COMMAND_OK);
}
Example #8
0
int
CMD_MCmd(int argc, char **argv)
{
	uint32_t ui32No;
	uint32_t ui32Param;
	uint32_t ui32Param1;
	uint32_t ui32Value=cSPIN_NOP;
	int i;
    //
    // Keep the compiler happy.
    //
    (void)argc;
    (void)argv;
	if(argc >= 3)
	{
		ui32No 	  =	ustrtoul(argv[1], 0, 10);
		ui32Param1 = cmdToint(argv[2]);
		//UARTprintf("ui32Param1 0x%2x\n",ui32Param1);
		switch ((ui32Param1) & DAISY_CHAIN_COMMAND_MASK)
     	{
	        case cSPIN_RUN: ;
	        case cSPIN_MOVE: ;
	        case cSPIN_GO_TO: ;
	        case cSPIN_GO_TO_DIR: ;
	        case cSPIN_GO_UNTIL: ;
	        case cSPIN_GO_UNTIL_ACT_CPY:
				ui32Param=ui32Param1|cmdToint(argv[3]);
				ui32Value = ustrtoul(argv[4], 0, 10);
				break;
			default:
      			ui32Param=ui32Param1;
				if(((ui32Param1) & DAISY_CHAIN_COMMAND_MASK)==cSPIN_RELEASE_SW && argc==5)
					ui32Param|=(cmdToint(argv[3])|cmdToint(argv[4]));
				break;
     	}
		for (i = 0; i < NUMBER_OF_SLAVES; i++)
		  {
		    if (i == ui32No)
		    {
		      commandArray[i] = (uint8_t)ui32Param;
	      	  argumentArray[i] = ui32Value;
			  UARTprintf("cmd 0x%2X,value %d\n",ui32Param,ui32Value);
		    }
		    else
		    {
		      commandArray[i] = cSPIN_NOP;
		      argumentArray[i] = cSPIN_NOP;
		    }
		  }
		cSPIN_All_Slaves_Send_Command(NUMBER_OF_SLAVES, commandArray, argumentArray);
	}
	
    return (0);
}
//*****************************************************************************
//
//Command: time12
//
// Set the current system time.  Use format "HH:MM:SS:X" Where X is 'A' or 'P'
// for AM or PM. HH is hours. MM is minutes. SS is seconds.
//
//*****************************************************************************
int
CMD_time12(int argc, char **argv)
{
    const char *pcNext;

    //
    // Check the argument count and return errors for too many or too few.
    //
    if(argc == 1)
    {
        return(CMDLINE_TOO_FEW_ARGS);
    }
    if(argc > 2)
    {
        return(CMDLINE_TOO_MANY_ARGS);
    }

    //
    // Convert the user string to unsigned long hours and minutes.
    //
    g_ui32HourIdx = ustrtoul(argv[1], &pcNext, 10);
    g_ui32MinIdx = ustrtoul(pcNext + 1, &pcNext, 10);

    //
    // Accomodate the PM vs AM modification.  All times are stored internally
    // as 24 hour format.
    //
    if(ustrncmp(pcNext + 1, "PM", 2) == 0)
    {
        if(g_ui32HourIdx < 12)
        {
            g_ui32HourIdx += 12;
        }
    }
    else
    {
        if(g_ui32HourIdx > 11)
        {
            g_ui32HourIdx -= 12;
        }
    }

    //
    // Perform the conversions to a time struct and store in the hibernate
    // module.  Also do some minimal checking on the input data.
    //
    if((g_ui32HourIdx < 24) && (g_ui32MinIdx < 60))
    {
        DateTimeSet();
    }

    return(0);
}
//*****************************************************************************
// \internal
//
// Handler for the "voff" command.
//
// \param argc contains the number of entries in the argv[] array.
// \param argv is an array of pointers to each of the individual words parsed
// from the command line.  The first entry will be the command itself and later
// entries represent any parameters.
//
// This function is called by the command line parser when the user enters
// the "voff" command.  It sets the voltage offset for one of the oscilloscope
// channels
//
// This handler takes two parameters.  The first is the voltage offset
// expressed in millivolts and the second is the channel number, 0 or 1.
// Positive offset values cause the waveform to move towards the top of
// the display and negative values move it towards the bottom.
//
// \return Returns COMMAND_OK if all is well or other return codes on failure.
//
//*****************************************************************************
int
CmdVOffset(int argc, char *argv[])
{
    long lVoltage;
    unsigned long ulChannel;
    const char *pcPos;

    //
    // Make sure we were passed the command and exactly 2 extra arguments
    //
    if(argc < 3)
    {
        return(COMMAND_TOO_FEW_ARGS);
    }

    if(argc > 3)
    {
        return(CMDLINE_TOO_MANY_ARGS);
    }

    //
    // Now extract numbers from the two command parameters.
    //
    lVoltage = (long)ustrtoul(argv[1], &pcPos, 0);
    ulChannel = ustrtoul(argv[2], &pcPos, 0);

    //
    // Make sure we were passed a valid channel number
    //
    if(ulChannel < 2)
    {
        //
        // Set the scaling for this channel.  This will take effect the next
        // time the display is updated.
        //
        UARTprintf("Setting offset for channel %d to %dmV.\n",
                   ulChannel, lVoltage);

        COMMAND_FLAG_WRITE((ulChannel == 0) ? SCOPE_CH1_POS : SCOPE_CH2_POS,
                           (unsigned long)lVoltage);

        return(COMMAND_OK);
    }
    else
    {
        //
        // Illegal channel number
        //
        UARTprintf("Channel %d is invalid.\n", ulChannel);
        return(COMMAND_INVALID_ARG);
    }
}
Example #11
0
int ft_board_setup(void *blob, bd_t *bd)
{
	int lpae;
	char *env;
	char *endp;
	int nbanks;
	u64 size[2];
	u64 start[2];
	u32 ddr3a_size;

	env = env_get("mem_lpae");
	lpae = env && simple_strtol(env, NULL, 0);

	ddr3a_size = 0;
	if (lpae) {
		ddr3a_size = ddr3_get_size();
		if ((ddr3a_size != 8) && (ddr3a_size != 4))
			ddr3a_size = 0;
	}

	nbanks = 1;
	start[0] = bd->bi_dram[0].start;
	size[0]  = bd->bi_dram[0].size;

	/* adjust memory start address for LPAE */
	if (lpae) {
		start[0] -= CONFIG_SYS_SDRAM_BASE;
		start[0] += CONFIG_SYS_LPAE_SDRAM_BASE;
	}

	if ((size[0] == 0x80000000) && (ddr3a_size != 0)) {
		size[1] = ((u64)ddr3a_size - 2) << 30;
		start[1] = 0x880000000;
		nbanks++;
	}

	/* reserve memory at start of bank */
	env = env_get("mem_reserve_head");
	if (env) {
		start[0] += ustrtoul(env, &endp, 0);
		size[0] -= ustrtoul(env, &endp, 0);
	}

	env = env_get("mem_reserve");
	if (env)
		size[0] -= ustrtoul(env, &endp, 0);

	fdt_fixup_memory_banks(blob, start, size, nbanks);

	return 0;
}
//*****************************************************************************
// \internal
//
// Handler for the "scale" command.
//
// \param argc contains the number of entries in the argv[] array.
// \param argv is an array of pointers to each of the individual words parsed
// from the command line.  The first entry will be the command itself and later
// entries represent any parameters.
//
// This function is called by the command line parser when the user enters
// the "scale" command.  It sets the voltage scale for one of the oscilloscope
// channels
//
// This handler takes two parameters.  The first is the voltage scale expressed
// in millivolts per division and the second is the channel number, 0 or 1.
//
// \return Returns COMMAND_OK if all is well or other return codes on failure.
//
//*****************************************************************************
int
CmdVScale(int argc, char *argv[])
{
    unsigned long ulVoltage;
    unsigned long ulChannel;
    const char *pcPos;

    //
    // Make sure we were passed the command and exactly 2 extra arguments
    //
    if(argc < 3)
    {
        return(COMMAND_TOO_FEW_ARGS);
    }

    if(argc > 3)
    {
        return(CMDLINE_TOO_MANY_ARGS);
    }

    //
    // Now extract numbers from the two command parameters.
    //
    ulVoltage = ustrtoul(argv[1], &pcPos, 0);
    ulChannel = ustrtoul(argv[2], &pcPos, 0);

    //
    // Make sure we were passed a valid channel number
    //
    if(ulChannel < 2)
    {
        //
        // Set the scaling for this channel.  This will take effect the next
        // time the display is updated.
        //
        UARTprintf("Setting scale for channel %d to %dmV/division.\n",
                   ulChannel, ulVoltage);

        g_sRender.ulmVPerDivision[ulChannel] = ulVoltage;
        return(COMMAND_OK);
    }
    else
    {
        //
        // Illegal channel number
        //
        UARTprintf("Channel %d is invalid.\n", ulChannel);
        return(COMMAND_INVALID_ARG);
    }
}
/*------------------------------------------------------------
 * Function Name  : GetOnlineParameterDateFromFlash
 * Description    : 获取参数
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void GetOnlineParameterDateFromFlash( STATUS_RW_FLASH_TypeDef rw )
{
	uint32_t IP = 0;
	uint8_t i = 0;
	
	switch ( rw )
	{
		case READ_FLASH:
			IP = devc_ip_get();
			
			for (i=0; i<4; ++i)
			{				
				usprintf(OnlineParameter.data[3-i],"%03d",(uint8_t)IP);

				IP >>= 8;
			}		
			break;
		
		case WRITE_FLASH:
			for (i=0; i<4; ++i)
			{				
				IP <<= 8;
				
				IP |= (uint8_t)ustrtoul(OnlineParameter.data[i],0,10); 		
			}

			devc_ip_set(IP);
			break;
	}
}
//*****************************************************************************
// \internal
//
// Handler for the "time" command.
//
// \param argc contains the number of entries in the argv[] array.
// \param argv is an array of pointers to each of the individual words parsed
// from the command line.  The first entry will be the command itself and later
// entries represent any parameters.
//
// This function is called by the command line parser when the user enters
// the "time" command.  It expects a single parameter which will be a
// string containing a decimal number representing the number of microseconds
// per division on the waveform display.
//
// \return Returns COMMAND_OK on success or COMMAND_TOO_FEW_ARGS or
// COMMAND_INVALID_ARG on failure.
//
//*****************************************************************************
int
CmdTimebase(int argc, char *argv[])
{
    unsigned long ulTimebase;
    const char *pcPos;

    //
    // Make sure we were passed the command and exactly 1 extra argument
    //
    if(argc < 2)
    {
        return(COMMAND_TOO_FEW_ARGS);
    }

    if(argc > 2)
    {
        return(CMDLINE_TOO_MANY_ARGS);
    }

    //
    // Now extract a number from the first command parameter.
    //
    ulTimebase = ustrtoul(argv[1], &pcPos, 0);

    //
    // Tell the main loop to update the timebase on the next iteration.
    //
    COMMAND_FLAG_WRITE(SCOPE_CHANGE_TIMEBASE, ulTimebase);

    return(COMMAND_OK);
}
//*****************************************************************************
// \internal
//
// Handler for the "hoff" command.
//
// \param argc contains the number of entries in the argv[] array.
// \param argv is an array of pointers to each of the individual words parsed
// from the command line.  The first entry will be the command itself and later
// entries represent any parameters.
//
// This function is called by the command line parser when the user enters
// the "hoff" command.  It expects a single parameter which will be a
// string containing a decimal number representing the number of pixels to
// offset the waveform display in the X direction.  Positive numbers move
// the trigger position to the right.
//
// \return Returns COMMAND_OK on success or COMMAND_TOO_FEW_ARGS or
// COMMAND_INVALID_ARG on failure.
//
//*****************************************************************************
int
CmdHOffset(int argc, char *argv[])
{
    long lPos;
    const char *pcPos;

    //
    // Make sure we were passed the command and exactly 1 extra argument
    //
    if(argc < 2)
    {
        UARTprintf("Command requires 1 parameter\n");
        return(COMMAND_TOO_FEW_ARGS);
    }

    if(argc > 2)
    {
        UARTprintf("Command requires 1 parameter\n");
        return(CMDLINE_TOO_MANY_ARGS);
    }

    //
    // Now extract a number from the first command parameter.
    //
    lPos = (long)ustrtoul(argv[1], &pcPos, 0);

    //
    // Pass the new position to the main command processor.
    //
    COMMAND_FLAG_WRITE(SCOPE_TRIGGER_POS, (unsigned long)lPos);

    return(COMMAND_OK);
}
//*****************************************************************************
// \internal
//
// Handler for the "level" command.
//
// \param argc contains the number of entries in the argv[] array.
// \param argv is an array of pointers to each of the individual words parsed
// from the command line.  The first entry will be the command itself and later
// entries represent any parameters.
//
// This function is called by the command line parser when the user enters
// the "level" or "l" commands.  It expects a single parameter which will be a
// string containing a decimal number representing the ADC sample level at
// which to trigger capture.
//
// \return Returns COMMAND_OK on success or COMMAND_TOO_FEW_ARGS or
// COMMAND_INVALID_ARG on failure.
//
//*****************************************************************************
int
CmdLevel(int argc, char *argv[])
{
    const char *pcPos;
    unsigned long ulLevel;

    //
    // Make sure we were passed the command and exactly 1 extra argument
    //
    if(argc < 2)
    {
        return(COMMAND_TOO_FEW_ARGS);
    }

    if(argc > 2)
    {
        return(CMDLINE_TOO_MANY_ARGS);
    }

    //
    // Extract a number from the first command parameter.
    //
    ulLevel = ustrtoul(argv[1], &pcPos, 0);

    //
    // Pass the command to the main handler for action.
    //
    COMMAND_FLAG_WRITE(SCOPE_TRIGGER_LEVEL, ulLevel);

    return(COMMAND_OK);
}
Example #17
0
//*****************************************************************************
//
// The alert command allows the user to send an alert message to the saved
// email address.
//
//*****************************************************************************
int
Cmd_alert(int argc, char *argv[])
{
    uint32_t ui32Index;

    //
    // Check the number of arguments.
    //
    if(argc < 2) {
        //
        // If there was no second term, prompt the user to enter one next time.
        //
        UARTprintf("Please specify the alert you want to send:\n");
        for(ui32Index = 0; ui32Index < NUM_ALERTS; ui32Index++) {
            //
            // Print a list of the available alert messages.
            //
            UARTprintf("alert %d: %s\n", ui32Index,
                       g_ppcAlertMessages[ui32Index]);
        }
    } else {
        ui32Index = ustrtoul(argv[1], NULL, 0);
        ustrncpy(g_pcAlert, g_ppcAlertMessages[ui32Index], 140);
        g_sAlert.eReadWriteType = READ_WRITE;

        UARTprintf("Alert message set. Sending to the server "
                   "on the next sync operation.");
    }

    return 0;
}
Example #18
0
/**********************************************************************
functionName: FRESULT PcmRecoverWithDate(void)	
description:上位机参数从SD卡恢复,保留加密信息(以文件夹形式)
char 		paseword_system[11];						//系统密码  
**********************************************************************/ 
FRESULT PcmRecoverWithDate( const char *pFile_name )							
{
	FRESULT fresult;
	FIL file_obj;  
	uint32_t br;  
	char pass[11]; 
	char file_name[30];
	uint32_t name_buff = 0;
	
	name_buff = ustrtoul(pFile_name,0,10);
	
	usprintf(file_name,"sys/%08d/pcm.bin",name_buff);
	
	fresult = f_open(&file_obj,file_name,FA_OPEN_EXISTING|FA_READ);
	if (FR_OK != fresult)
	{
		return fresult;
	}	
	
	memcpy(pass,pcm_str->pcm_hmi.paseword_system,11);    	//记录当前密码
	  
	f_read(&file_obj,pcm_ram,PCM_MEM_SIZE,&br);
	f_close(&file_obj); 
	
	memcpy(pcm_str->pcm_hmi.paseword_system,pass,11); 		//恢复当前密码 
	
	return FR_OK;
}
//*****************************************************************************
//
// The "setproxy" command allows the user to change their proxy behavior
//
//*****************************************************************************
int
Cmd_setproxy(int argc, char *argv[])
{
    char pcProxyPort[10];

    //
    // Check the number of arguments.
    //
    if((argc == 2) && (ustrcmp("off",argv[1]) == 0 ))
    {
        g_bUseProxy = false;
        g_pcProxyAddress[0] = 0;
        g_ui16ProxyPort = 0;

        UARTprintf("Attempting to re-establish link with Exosite.\n\n");
        g_bOnline = LocateValidCIK();
    }
    else if(argc == 3)
    {
        //
        // Otherwise, copy the user-defined location into the global variable.
        //
        ustrncpy(g_pcProxyAddress, argv[1], 49);
        ustrncpy(pcProxyPort, argv[2], 9);

        //
        // Make sure that the global string remains terminated with a zero.
        //
        g_pcProxyAddress[49] = 0;
        pcProxyPort[9] = 0;
        g_ui16ProxyPort = ustrtoul(pcProxyPort, NULL, 0);
        g_bUseProxy = true;

        UARTprintf("New Proxy Address: %s\n", g_pcProxyAddress);
        UARTprintf("New Proxy Port: %d\n\n", g_ui16ProxyPort);

        UARTprintf("Attempting to re-establish link with Exosite.\n\n");
        g_bOnline = LocateValidCIK();

    }
    else
    {
        UARTprintf("\nProxy configuration help:\n");
        UARTprintf("    The setproxy command changes the proxy behavior of"
                   "this board.\n");
        UARTprintf("    To disable the proxy, type:\n\n");
        UARTprintf("    setproxy off\n\n");
        UARTprintf("    To enable the proxy with a specific proxy name and "
                   "port, type\n");
        UARTprintf("    setproxy <proxyaddress> <portnumber>. For "
                   "example:\n\n");
        UARTprintf("    setproxy your.proxy.address 80\n\n");
    }

    return 0;
}
Example #20
0
float my_strtof(unsigned char* input, int* outputPieces) {
	float output = 0;
	bool mantissa = false;
	bool negativeValue = false;
	char inputInteger[MAXFIELD];
	char inputFraction[MAXFIELD];
	short i = 0, j = 0, k = 0;

	short strLength = ustrlen((char*) input);

	for (i = 0; i < strLength; i++, k++) {

		if (input[i] == '.') {
			mantissa = true;
			inputInteger[k] = '\0';
			j = 0;
			continue;		//skip the dec.
		}
		if (input[i] == '-') {
			negativeValue = true;
			k--;
			continue;		//skip the dec.
		}
		if (!mantissa) {
			inputInteger[k] = input[i];
		} else {
			inputFraction[j] = input[i];
			j++;
		}
	}

	inputFraction[j] = '\0';
	int integerPart = ustrtoul(inputInteger, NULL, 0);
	int fractionPart = ustrtoul(inputFraction, NULL, 0);
	outputPieces[0] = integerPart;
	outputPieces[1] = fractionPart;
	output = integerPart + (float) (fractionPart / (pow(10, (j - 1))));
	if (negativeValue) {
		return -output;
	}
	return output;

}
Example #21
0
int
CMD_goToDir(int argc, char **argv)
{
	uint32_t ui32Dir;
	uint32_t ui32Abs_pos;
    //
    // Keep the compiler happy.
    //
    (void)argc;
    (void)argv;
	if(argc == 3)
	{
		ui32Dir = ustrtoul(argv[1], 0, 10);
		ui32Abs_pos = ustrtoul(argv[2], 0, 10);
		cSPIN_Go_To_Dir(ui32Dir,ui32Abs_pos);
	}
	
    return (0);
}
Example #22
0
int
CMD_Move(int argc, char **argv)
{
	uint32_t ui32Dir;
	uint32_t ui32Step;
    //
    // Keep the compiler happy.
    //
    (void)argc;
    (void)argv;
	if(argc == 3)
	{
		ui32Dir = ustrtoul(argv[1], 0, 10);
		ui32Step = ustrtoul(argv[2], 0, 10);
		cSPIN_Move(ui32Dir,ui32Step);
	}
	
    return (0);
}
Example #23
0
int
CMD_releaseSW(int argc, char **argv)
{
	uint32_t ui32Dir;
	uint32_t ui32Action;
    //
    // Keep the compiler happy.
    //
    (void)argc;
    (void)argv;
	if(argc == 3)
	{
		ui32Action = ustrtoul(argv[1], 0, 10);
		ui32Dir = ustrtoul(argv[2], 0, 10);
		cSPIN_Release_SW(ui32Action,ui32Dir);
	}
	
    return (0);
}
Example #24
0
int
CMD_sParam(int argc, char **argv)
{
	uint32_t ui32Param;
	uint32_t ui32Value;
    //
    // Keep the compiler happy.
    //
    (void)argc;
    (void)argv;
	if(argc == 3)
	{
		ui32Param = ustrtoul(argv[1], 0, 10);
		ui32Value = ustrtoul(argv[2], 0, 10);
		cSPIN_Set_Param(ui32Param,ui32Value);
	}
	
    return (0);
}
Example #25
0
int
CMD_Run(int argc, char **argv)
{
	uint32_t ui32Dir;
	uint32_t ui32Speed;
    //
    // Keep the compiler happy.
    //
    (void)argc;
    (void)argv;
	if(argc == 3)
	{
		ui32Dir = ustrtoul(argv[1], 0, 10);
		ui32Speed = ustrtoul(argv[2], 0, 10);
		cSPIN_Run(ui32Dir,ui32Speed);
	}
	
    return (0);
}
Example #26
0
int
CMD_goUntil(int argc, char **argv)
{
	uint32_t ui32Action;
	uint32_t ui32Dir;
	uint32_t ui32Speed;
    //
    // Keep the compiler happy.
    //
    (void)argc;
    (void)argv;
	if(argc == 4)
	{
		ui32Action = ustrtoul(argv[1], 0, 10);
		ui32Dir = ustrtoul(argv[2], 0, 10);
		ui32Speed = ustrtoul(argv[3], 0, 10);
		cSPIN_Go_Until(ui32Action,ui32Dir,ui32Speed);
	}
	
    return (0);
}
Example #27
0
int
CMD_MMove(int argc, char **argv)
{
	uint32_t ui32No;
	uint32_t ui32Dir;
	uint32_t ui32Step;
    //
    // Keep the compiler happy.
    //
    (void)argc;
    (void)argv;
	if(argc == 4)
	{
		ui32No 	  =	ustrtoul(argv[1], 0, 10);
		ui32Dir   = ustrtoul(argv[2], 0, 10);
		ui32Step  = ustrtoul(argv[3], 0, 10);
		cSPIN_One_Slave_Move(NUMBER_OF_SLAVES,ui32No,ui32Dir,ui32Step);
	}
	
    return (0);
}
Example #28
0
int cmd_relay(int argc, char *argv[]) {
	unsigned char pin,value;
	unsigned short module;
	
	module = MODULE1;
	if(!(module_exists(module) && (module_profile_id(module) == PROFILE_RELAY))) {
		cmd_print("No relay available.");
		return(0);
	}

	if (argc == 2) {
		pin = ustrtoul(argv[1],NULL,0);
		cmd_print("\r\nrelay module: %d pin: %d value: %d",module,pin, relay_read(module,pin));

	} else if (argc == 3) {
		pin = ustrtoul(argv[1],NULL,0);
		value = ustrtoul(argv[2],NULL,16);
		relay_write(module,pin,value);
	}
	return(0);
}
//数据的获取与保存
//dir:方向 0--获取时间; 1--设置时间
void time_change_data( STATUS_RW_FLASH_TypeDef rw, TIME_DATA_TypeDef *pTime )
{
	tTime t;
	uint16_t temp;

	if(READ_FLASH == rw)					 
	{
		time_cycle();
		t = get_time();	 //获取时间
		numtochar(2,t.usYear % 100,pTime[0].buff);	//获取年
		numtochar(2,t.ucMon,pTime[2].buff);			//获取月
	 	numtochar(2,t.ucMday,pTime[4].buff);		//获取日
		numtochar(2,t.ucHour,pTime[1].buff);		//获取时
		numtochar(2,t.ucMin,pTime[3].buff);			//获取分
		numtochar(2,t.ucSec,pTime[5].buff);			//获取秒
	}
	else
	{
		temp = ustrtoul(pTime[0].buff,0,10);	//设置年
		temp += 2000;
		t.usYear = temp;

		t.ucMon = ustrtoul(pTime[2].buff,0,10);    //设置月
		t.ucMday = ustrtoul(pTime[4].buff,0,10);   //设置日
		t.ucHour = ustrtoul(pTime[1].buff,0,10);	//设置时
		t.ucMin = ustrtoul(pTime[3].buff,0,10);	//设置分
		t.ucSec = ustrtoul(pTime[5].buff,0,10);	//设置秒
	 	
		time_set(t);	
	}	
}
Example #30
0
int
CMD_pwm(int argc, char **argv)
{
	uint32_t ui32Hz;
	uint32_t ui32Delay;
    //
    // Keep the compiler happy.
    //
    (void)argc;
    (void)argv;
	if(argc == 3)
	{
		ui32Hz = ustrtoul(argv[1], 0, 10);
		ui32Delay = ustrtoul(argv[2], 0, 10);
		UARTprintf("Hz %d,last %d\n",ui32Hz,ui32Delay);
		cSPIN_PWM_Enable(ui32Hz);
		cSPIN_Delay(ui32Delay);
		cSPIN_PWM_DISABLE();
	}

    return (0);
}