Ejemplo n.º 1
0
void SpeedSense::populate_log_buffer() {
  static const char mph_str[] PROGMEM = "mph";
  static const char rpm_str[] PROGMEM = "rpm, ";
  strcpy(logBuffer,String(m_rpm).c_str());
  strcat_P(logBuffer,rpm_str);
  strcat(logBuffer,String(m_speed,2).c_str());
  strcat_P(logBuffer,mph_str);
}
Ejemplo n.º 2
0
uint8_t REDFLY::socketConnect(uint8_t proto, uint8_t *ip, uint16_t port, uint16_t lport)
{
  uint8_t ret=INVALID_SOCKET, len;

  //ip
  iptoa(ip, (char*)buffer); 
  //port
  strcat_P((char*)buffer, PSTR(","));
  len = strlen((char*)buffer);
  uitoa(port, (char*)&buffer[len]);
  //local port
  strcat_P((char*)buffer, PSTR(","));
  len = strlen((char*)buffer);
  uitoa(lport, (char*)&buffer[len]);

  if(proto == PROTO_MCAST) //Multicast
  {
    proto = SOCKET_MCAST;
    if(cmd(buffer, 8, PSTR(CMD_MCAST), (char*)buffer) == 0) //xxx.xxx.xxx.xxx,aaaaa,bbbbb
    {
      ret = buffer[2]; //OKx
    }
  }
  else if(proto == PROTO_TCP) //TCP
  {
    proto = SOCKET_TCP;
    if(cmd(buffer, 8, PSTR(CMD_TCP), (char*)buffer) == 0) //xxx.xxx.xxx.xxx,aaaaa,bbbbb
    {
      ret = buffer[2]; //OKx
    }
  }
  else //UDP
  {
    proto = SOCKET_UDP;
    if(cmd(buffer, 8, PSTR(CMD_UDP), (char*)buffer) == 0) //xxx.xxx.xxx.xxx,aaaaa,bbbbb
    {
      ret = buffer[2]; //OKx
    }
  }

  if(ret != INVALID_SOCKET) //handle okay -> save socket handle and type
  {
    for(uint8_t i=0; i<MAX_SOCKETS; i++)
    {
      if(socket_state[i].handle == INVALID_SOCKET)
      {
        socket_state[i].handle = ret;
        socket_state[i].state  = proto;
        break;
      }
    }
  }

  return ret;
}
Ejemplo n.º 3
0
void cmd_print_signed_fix(int16_t value)
{
	if (value<0)
        {
                value = -value;
                strcat_P(cmd_line, PSTR("-"));
        }
	else
	{
		strcat_P(cmd_line, PSTR(" "));
	}

	cmd_print_unsigned_fix(value);
}
Ejemplo n.º 4
0
unsigned long DLSD::open(uint8_t n, uint8_t flags) {
	uint8_t ret;
	unsigned long fsize = 0;
	char path[50];
	digitalWrite(_CS, LOW);
	if (_files_open[n] == false) {
		*(path) = '\0';
		get_from_flash(&(sd_dir_table[n]), _filename);
		strcat(path, _filename);
		strcat(path, "/");
		get_from_flash(&(sd_filename_table[n]), _filename);
		if (n != 0)
			pad_filename(_filename, _files_count[n]);
		strcat_P(_filename, sd_filename_ext);		
		strcat(path, _filename);
		if (_DEBUG) {
			Serial.print("Opening ");
			Serial.println(path);
		}
		ret = _files[n].open(path, flags);
		if (!ret || !_files[n].isOpen())
			return -1;
		_files_open[n] = true;
		fsize = _files[n].fileSize();
	} else {
		fsize = _files[n].fileSize();
	}
	return fsize;
}
Ejemplo n.º 5
0
void cmd_stack_memory(void)
{
	uint16_t result;
		
	result = cmd_get_max_stack_usage();	
	strcpy_P(cmd_line, PSTR("command_thread's max stack usage: "));
	cmd_print_unsigned_fix(result);
	strcat_P(cmd_line, PSTR(" bytes\r\n"));

	cmd_flush();

	result = idle_get_max_stack_usage();	
	strcpy_P(cmd_line, PSTR("idle_thread's max stack usage: "));
	cmd_print_unsigned_fix(result);
	strcat_P(cmd_line, PSTR(" bytes\r\n"));
}
Ejemplo n.º 6
0
void CGCode3DParser::PrintSDFileListRecurse(File& dir, uint8_t depth, unsigned short&count, char* filenamebuffer, char seperatorchar)
{
#ifdef _MSC_VER
#pragma warning (suppress: 4127)
#endif
	while (true)
	{
		File entry = dir.openNextFile();
		if (!entry) break;

		if (entry.isDirectory())
		{
			unsigned int lastidx = strlen(filenamebuffer);
			strcat(filenamebuffer, entry.name());
			strcat_P(filenamebuffer, MESSAGE_PARSER3D_SLASH);
			PrintSDFileListRecurse(entry, depth + 1, count, filenamebuffer, seperatorchar);
			filenamebuffer[lastidx] = 0;
		}
		else
		{
			if (entry.name()[9] != '~')
			{
				if (count != 0)
				{
					StepperSerial.print(seperatorchar);
				}
				StepperSerial.print(filenamebuffer);
				StepperSerial.print(entry.name());
				count++;
			}
		}
		entry.close();
	}
}
Ejemplo n.º 7
0
void menu_modem (void) {
    int i;
    switch (CMD_buffer[3]) {
    case 'd':
        PWR_gsm_stop(); //disable
        usb_tx_string_PV(PSTR("GSM is off\r"));
        break;
    case 'e':  //enable modem
        usb_tx_string_PV(PSTR("GSM Start pending"));
        GSM_modem_init();
        break;
    case 'r':  //reset
        reset_trigger_GSM();
        usb_tx_string_PV(PSTR("GSM restarting"));
        break;
    case 'q':
        menu_modem_status();
        break;
    case 'i':
        usb_tx_string_P(PSTR("V2X uses the SIM5320A 3G GSM modem + GPS receiver by SIMCOM\r"));
        break;
    case 'x':
        strcat_P(CMD_buffer, PSTR("\r\n"));  //put these char at the end of the string
        GSM_add_string_to_buffer(BUFFER_OUT, &CMD_buffer[4]); //send it on to the modem
        GSM_mark_for_processing(BUFFER_OUT); //initiate send
        break;
    case '?':
    default:
        usb_tx_string_P(PSTR("*** Modem Menu ***\rE: Enable\rD: Disable\rR: Restart\rI: Subsystem Information\rQ: Query status\rX: AT Command Pass through\r"));
        break;
    }
}
Ejemplo n.º 8
0
void cmd_line_voltage(void)
{
	uint16_t voltage = plc_get_line_voltage();
	strcpy_P(cmd_line, PSTR("Actual line voltage: "));
	cmd_print_unsigned_fix(voltage);
	strcat_P(cmd_line, PSTR("V"));
}
Ejemplo n.º 9
0
void DLSD::seek_forward_files_count() {
	int n, cnt, scnt;
	char path[50];
	bool exists = true;
	for(n=FILES_CNT_START;n<=FILES_CNT_END;n++) {
		exists = false;
		cnt = _files_count[n];
		scnt = cnt;
		do {
			*(path) = '\0';
                	get_from_flash(&(sd_dir_table[n]), _filename);
               		strcat(path, _filename);
                	strcat(path, "/");
                	get_from_flash(&(sd_filename_table[n]), _filename);
                	if (n != 0)
                        	pad_filename(_filename, _files_count[n]);
                	strcat_P(_filename, sd_filename_ext);
                	strcat(path, _filename);
 	
			exists = _card.exists(_filename);
			cnt++;
		} while (exists);
		if (cnt > 1)
			cnt = cnt - 2;

		if (cnt > scnt) {
			Serial.print("Setting #");
			Serial.print(n, DEC);
			Serial.print(" to ");
			Serial.println(cnt, DEC);
			set_files_count(n, cnt);
		}
	}
}
Ejemplo n.º 10
0
/*
 * generate and transmit pathname block consisting of
 *  pathname (null terminated),
 *  file length, mode time and file mode in octal
 *  as provided by the Unix fstat call.
 *  N.B.: modifies the passed name, may extend it!
 */
int wctxpn(const char *name)
{

  char *p, *q;

//DSERIAL.println("\nwctxpn");

  strcpy(txbuf,name);
  p = q = txbuf + strlen(txbuf)+1;
  //Pete (El Supremo) fix bug - was 1024, should be TXBSIZE??
  while (q < (txbuf + TXBSIZE))
    *q++ = 0;
//  if (!Ascii && (in!=stdin) && *name && fstat(fileno(in), &f)!= -1)
  if (!Ascii)
    // I will have to figure out how to convert the uSD date/time format to a UNIX epoch
//    sprintf(p, "%lu %lo %o 0 %d %ld", fout.fileSize(), 0L,0600, Filesleft, Totalleft);
// Avoid sprintf to save memory for small boards.  This sketch doesn't know what time it is anyway
    ultoa(fout.fileSize(), p, 10);
    strcat_P(p, PSTR(" 0 0 0 "));
    q = p + strlen(p);
    ultoa(Filesleft, q, 10);
    strcat_P(q, PSTR(" "));
    q = q + strlen(q);
    ultoa(Totalleft, q, 10);

  Totalleft -= fout.fileSize();
//DSERIAL.print(F("wctxpn sf = "));
//DSERIAL.print(sf);
//DSERIAL.print(F("  length = "));
//DSERIAL.println(Totalleft);
  if (--Filesleft <= 0)
    Totalleft = 0;
  if (Totalleft < 0)
    Totalleft = 0;

  /* force 1k blocks if name won't fit in 128 byte block */
  //Pete (El Supremo) This can't be right??!
  if (txbuf[125])
//    blklen=1024;
    blklen = TXBSIZE;
  else {          /* A little goodie for IMP/KMD */
    blklen = 128;
    txbuf[127] = (fout.fileSize() + 127) >>7;
    txbuf[126] = (fout.fileSize() + 127) >>15;
  }
  return zsendfile(txbuf, 1+strlen(p)+(p-txbuf));
}
Ejemplo n.º 11
0
//************************************************************************
//*	this is for internal use only, not made pubic to the API
static void	ATS_PrintProperty(	int		propertyTagNum,
								char	*propertyName,
								char	*propertyValue)
{
char	lineBuffer[64];

	strcpy_P(lineBuffer, gTextMsg_info);
	switch(propertyTagNum)
	{
		case 0:
			strcat(lineBuffer, propertyName);
			break;
			
		case ATS_Manufacturer:
			strcat_P(lineBuffer, gTextMsg_Manufacturer);
			break;

		case ATS_CPU:
			strcat_P(lineBuffer, gTextMsg_CPUname);
			break;

		case ATS_GCC_version:
			strcat_P(lineBuffer, gTextMsg_GCC_VERSION);
			break;

		case ATS_LIBC_version:
			strcat_P(lineBuffer, gTextMsg_AVR_LIBC);
			break;

		case ATS_CompiledDate:
			strcat_P(lineBuffer, gTextMsg_COMPILED_DATE);
			break;

		case ATS_TestSuiteName:
			strcat_P(lineBuffer, gTextMsg_TEST_SUITE_NAME);
			break;

		case ATS_FreeMemory:
			strcat_P(lineBuffer, gTextMsg_memoryUsage);
			break;
	}

	while (strlen(lineBuffer) < 20)
	{
		strcat(lineBuffer, " ");
	}
	
	strcat_P(lineBuffer, gTextMsg_spaceEqual);
	if (propertyValue != 0)
	{
		strcat(lineBuffer, propertyValue);
	}
	Serial.println(lineBuffer);

}
Ejemplo n.º 12
0
Archivo: menu.cpp Proyecto: lsitec/PCR
void showUsageTime(MenuItem* mi)
{
    int usage_time = word(EEPROM.read(TIME_CTR_ADDR), EEPROM.read(TIME_CTR_ADDR+1));
    strcpy_P(screen.title, strConfClk);
    strcpy_P(screen.content[0], strNull);
    itoa(usage_time, screen.content[1], 10);
    strcat_P(screen.content[1], strHours);
    strcpy_P(screen.content[2], strNull);
}
Ejemplo n.º 13
0
/**
 @brief	make response header such as html, gif, jpeg, zip, etc.
 */
void make_http_response_head(
	uint8_t * buf, 	/**< pointer to response header to be made */
	uint8_t type, 	/**< response type */
	uint32_t len	/**< size of response file / document */
	)
{
	PGM_P head = 0;
	uint8_t tmp[16];

	switch (type) {

		case PTYPE_HTML :
			head = RES_HTMLHEAD_OK;
			break;

		case PTYPE_GIF :
			head = RES_GIFHEAD_OK;
			break;

		case PTYPE_TEXT :
			head = RES_TEXTHEAD_OK;
			break;

		case PTYPE_JPEG :
			head = RES_JPEGHEAD_OK;
			break;

		case PTYPE_FLASH :
			head = RES_FLASHHEAD_OK;
			break;

		case PTYPE_MPEG :
			head = RES_MPEGHEAD_OK;
			break;

		case PTYPE_PDF :
			head = RES_PDFHEAD_OK;
			break;

		case PTYPE_ZIP :
			head = RES_ZIPHEAD_OK;
			break;

		default:
#ifdef HTTP_DEBUG
			xSerialPrint_P(PSTR("\r\n\r\nHTTP RESPONSE HEADER UNKNOWN-\r\n"));
#endif
			break;
	}

	sprintf((char *)tmp,"%ld", len);

	strcpy_P((char *)buf, head);
	strcat((char *)buf, (const char *)tmp);
	strcat_P((char *)buf, PSTR("\r\n\r\n\0"));
}
Ejemplo n.º 14
0
Archivo: menu.cpp Proyecto: lsitec/PCR
void updateCustomProfile(int delta_x, int delta_y)
{
    if (delta_y < MNEG)
    {
        p_index = (p_index<NUM_P_PARAMS) ? p_index+1 : 0;
    }
    else if (delta_y > MPOS)
    {
        p_index = (p_index!=0) ? p_index-1 : NUM_P_PARAMS;
    }
    else if (delta_x < MNEG)
    {
        p_params[p_index] = (p_params[p_index]!=0) ? p_params[p_index]-1 : 9;
    }
    else if (delta_x > MPOS && p_index != NUM_P_PARAMS)
    {
        p_params[p_index] = (p_params[p_index]!=9) ? p_params[p_index]+1 : 0;
    }
    else if (delta_x > MPOS && p_index == NUM_P_PARAMS)
    {
        sendPack2Motors(PROFILES_MODE, DIGITAL, p_params[0], p_params[1]);
        delay(300);
        menu.start();
        return;
    }
    strcpy_P(screen.title, strCustomProfile);
    for (int i=0;i<NUM_P_PARAMS;i++)
    {
        if(i==p_index)
            strcpy_P(screen.content[i], sel_item);
        else
            strcpy_P(screen.content[i], unsel_item);

        itoa(p_params[i], menu_buffer, 10);
        strcat_P(screen.content[i], (char*)pgm_read_word(&(custom_prof_params[i])));
        strcat(screen.content[i], menu_buffer);
    }
    if(p_index==NUM_P_PARAMS)
        strcpy_P(screen.content[NUM_P_PARAMS], sel_item);
    else
        strcpy_P(screen.content[NUM_P_PARAMS], unsel_item);
    strcat_P(screen.content[NUM_P_PARAMS], ok);
}
Ejemplo n.º 15
0
void cmd_print_unsigned_float(uint16_t value)
{
	char temp[4];

	uint8_t high = value / 100;
	uint8_t low  = value % 100;

	strcat(cmd_line, itoa(high, temp, 10));
	strcat_P(cmd_line, PSTR("."));
	if (low>9)
	{
		strcat(cmd_line, itoa(low, temp, 10));
	}
	else
	{
		strcat_P(cmd_line, PSTR("0"));
		strcat(cmd_line, itoa(low, temp, 10));
	}
}
Ejemplo n.º 16
0
void cmd_current(void)
{
	int16_t current;

	current = battery_get_current();

	strcpy_P( cmd_line, PSTR("Battery current: "));
	cmd_print_signed_float(current);
	strcat_P( cmd_line, PSTR("A"));
}
Ejemplo n.º 17
0
void cmd_voltage(void)
{
	uint16_t voltage;

	voltage = battery_get_voltage();

	strcpy_P( cmd_line, PSTR("Battery voltage: "));
	cmd_print_unsigned_float(voltage);	
	strcat_P( cmd_line, PSTR("V"));
}
Ejemplo n.º 18
0
/**
* \brief Encode to base64 User : pass and prepare to check.
*
* \param result Encoded string.
*
* \return void
*/
void encodeUserPass(char * result)
{
    // + 1 for ':' + 1 for '\0'.
    char userPass[USER_PAS_LEN * 2 + 1 + 1];
    userPass[0] = CH_NONE;
    strcpy(userPass, DeviceData.User);
    strcat_P(userPass, PSTR(":"));
    strcat(userPass, DeviceData.Password);

    base64_encode(result, userPass, strlen(userPass));
}
Ejemplo n.º 19
0
void cmd_capacity(void)
{
	int16_t capacity;
	
	capacity  = battery_get_parameter_value(AH_ZAEHLER) * 3;

	strcpy_P( cmd_line, PSTR("Battery actual capacity: "));
	cmd_print_signed_float(capacity);
	strcat_P( cmd_line, PSTR("Ah\n\r"));

	cmd_line[0] = '\0';
}
Ejemplo n.º 20
0
Archivo: menu.cpp Proyecto: lsitec/PCR
void menuChange(MenuChangeEvent changed)
{
    if (changed.to.parent)
        strcpy_P(screen.title, changed.to.parent->name);
    else
        strcpy_P(screen.title, strMenu);

    strcpy_P(screen.content[0], sel_item);
    strcat_P(screen.content[0], changed.to.name);
    if (changed.to.active)
        strcat_P(screen.content[0], active_mark);

    strcpy_P(screen.content[1], strNull);
    strcpy_P(screen.content[2], strNull);

    if(changed.to.next)
    {
        strcpy_P(screen.content[1], unsel_item);
        strcat_P(screen.content[1], changed.to.next->name);
        if (changed.to.next->active)
            strcat_P(screen.content[1], active_mark);

        if(changed.to.next->next)
        {
            strcpy_P(screen.content[2], unsel_item);
            strcat_P(screen.content[2], changed.to.next->next->name);
            if (changed.to.next->next->active)
                strcat_P(screen.content[2], active_mark);
        }
    }
}
Ejemplo n.º 21
0
	bool WeatherClient::get_current_weather(weather& we, const char* city){
		 /**
		  * {"coord":{"lon":-3.7,"lat":40.42},
		  *  "sys":{"message":0.0447,"country":"ES","sunrise":1396245552,"sunset":1396291108},
		  *  "weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}],
		  *  "base":"cmc stations",
		  *  "main":{"temp":12.1,"humidity":63,"pressure":1016,"temp_min":11,"temp_max":14.44},
		  *  "wind":{"speed":2.06,"gust":4.11,"deg":153},
		  *  "clouds":{"all":56},
		  *  "dt":1396263911,
		  *  "id":3117735,
		  *  "name":"Madrid",
		  *  "cod":200}
		  */
		 char tmp[strlen(city) + 35];
		 tmp[0] = '\0';
		 strcat_P(tmp, PSTR("/data/2.5/weather?q="));
	  	 strcat(tmp, city);
		 strcat_P(tmp, PSTR("&units=metric"));
		 const char* queries[] = { "weather.0.description", "main.temp_min", "main.temp_max" };
		 return call_and_receive(tmp, queries, we);
	};
Ejemplo n.º 22
0
void onSdManagerMenu(const char *result)
{
  char lfn[SD_SCREEN_FILE_LENGTH];

  uint8_t index = m_posVert-1-s_pgOfs;
  if (result == STR_SD_INFO) {
    pushMenu(menuGeneralSdManagerInfo);
  }
  else if (result == STR_SD_FORMAT) {
    POPUP_CONFIRMATION(PSTR("Confirm Format?"));
  }
  else if (result == STR_DELETE_FILE) {
    f_getcwd(lfn, SD_SCREEN_FILE_LENGTH);
    strcat_P(lfn, PSTR("/"));
    strcat(lfn, reusableBuffer.sdmanager.lines[index]);
    f_unlink(lfn);
    strncpy(statusLineMsg, reusableBuffer.sdmanager.lines[index], 13);
    strcpy_P(statusLineMsg+min((uint8_t)strlen(statusLineMsg), (uint8_t)13), STR_REMOVED);
    showStatusLine();
    if ((uint16_t)m_posVert == reusableBuffer.sdmanager.count) m_posVert--;
    reusableBuffer.sdmanager.offset = s_pgOfs-1;
  }
#if defined(CPUARM)
  /* TODO else if (result == STR_LOAD_FILE) {
    f_getcwd(lfn, SD_SCREEN_FILE_LENGTH);
    strcat(lfn, "/");
    strcat(lfn, reusableBuffer.sdmanager.lines[index]);
    POPUP_WARNING(eeLoadModelSD(lfn));
  } */
  else if (result == STR_PLAY_FILE) {
    f_getcwd(lfn, SD_SCREEN_FILE_LENGTH);
    strcat(lfn, "/");
    strcat(lfn, reusableBuffer.sdmanager.lines[index]);
    audioQueue.playFile(lfn, PLAY_BACKGROUND, 255);
  }
#endif
#if defined(PCBTARANIS)
  else if (result == STR_ASSIGN_BITMAP) {
    strcpy(lfn, reusableBuffer.sdmanager.lines[index]);
    // TODO duplicated code for finding extension
    uint8_t len = strlen(lfn) - 4;
    memset(lfn+len, 0, sizeof(g_model.header.bitmap)-len);
    // TODO duplicated code
    memcpy(g_model.header.bitmap, lfn, sizeof(g_model.header.bitmap));
    LOAD_MODEL_BITMAP();
    memcpy(modelHeaders[g_eeGeneral.currModel].bitmap, g_model.header.bitmap, sizeof(g_model.header.bitmap));
    eeDirty(EE_MODEL);
  }
#endif
}
Ejemplo n.º 23
0
void show_animaiton_info_stopped(animation_names animation)
{
    if (!mcpu_is_initialized())
        return;

    char infotext[32];

    strcpy_P(infotext, PSTR("S: "));
    strcat_P(infotext, animation_string_names[animation]);

    dprintf("info: %s\n", infotext);

    mcpu_send_info_text(infotext);
}
Ejemplo n.º 24
0
void menu_can (void) {
    int i;
    char buffer[EE_CAN_ARRAY_SIZE+1];
    switch (CMD_buffer[3]) {
    case 'd':  //disable;
        usb_tx_string_PV(PSTR("CAN is off\r"));
        PWR_can_stop();
        PWR_is_5_needed();
        break;
    case 'e':  //enable
        usb_tx_string_PV(PSTR("CAN Starting\r"));
        CAN_elm_init();
        break;
    case 'r':  //reset
        usb_tx_string_PV(PSTR("CAN restarting\r"));
        reset_trigger_CAN();
        break;
    case 'q': //query
        menu_can_status();
        break;
    case 'i': //info
        usb_tx_string_P(PSTR("V2X uses the STN1110 CANbus interface from Scantool\rThe STN1110 is compliant with the ELM327 V1.3\r"));
        break;
    case 'x': //pass command
        strcat_P(CMD_buffer, PSTR("\r"));

        CAN_add_string_to_buffer(BUFFER_OUT, CMD_buffer+4);
        CAN_mark_for_processing(BUFFER_OUT);
        CAN_start_snoop();
        break;
    case 's':  //save string to eeprom
        //strcat_P(CMD_buffer, PSTR("\r"));
        eeprom_store_CAN_string(CMD_buffer+4);
        break;
    case 'w': //what is stored in EE?
        eeprom_read_CAN_string(buffer);
        usb_cdc_send_string(USB_CMD, buffer);
        break;
    case 'a': //load string and parse from eeprom
        CAN_EE_start();
        break;
    case '?':
    default:
        usb_tx_string_P(PSTR("*** CANbus Menu ***\rE: Enable\rD: Disable\rR: Restart\rS: Store config string to EE\rA: Execute config string in EE\rW: Display config string in EE\rI: Subsystem Information\rQ: Query status\r"));
        break;
    }
}
Ejemplo n.º 25
0
uint8_t REDFLY::scan(uint8_t chn, char *ssid, uint8_t *mode, uint8_t *rssi) //chn 0 = all
{
  uint8_t ret, len;

  memset(buffer, 0, sizeof(buffer));

  cmd(PSTR(CMD_NUMSCAN "1")); //return only one result on scan command

  if(ssid[0] != 0) //scan for ssid
  {
    uitoa(chn, (char*)&buffer[0]); //chn
    len = strlen((char*)buffer);
    strcat_P((char*)&buffer[len], PSTR(",")); //,
    len = strlen((char*)buffer);
    strcat((char*)&buffer[len], ssid); //ssid
    ret = cmd(buffer, sizeof(buffer), PSTR(CMD_SCAN), (char*)buffer);
  }
  else
  {
    ret = cmd(buffer, sizeof(buffer), PSTR(CMD_SCAN), chn);
  }

  if(ret == 0) //scan successful
  {
    memcpy(ssid, &buffer[2], 32); //SSID
    ssid[32] = 0; //32+1
    if(mode)
    {
      *mode = buffer[34];
    }
    if(rssi)
    {
      *rssi = buffer[35];
    }
  }
  else
  {
    if(rssi)
    {
      *rssi = 0;
    }
  }

  return ret;
}
static void lcd_menu_first_run_material_select_material()
{
    LED_GLOW();
    uint8_t count = eeprom_read_byte(EEPROM_MATERIAL_COUNT_OFFSET());

    lcd_scroll_menu(PSTR("MATERIAL"), count, lcd_material_select_callback, lcd_material_select_details_callback);
    CLEAR_PROGRESS_NR(17);
    lcd_lib_update_screen();

    if (lcd_lib_button_pressed)
    {
        digipot_current(2, motor_current_setting[2]);//Set E motor power to default.

        for(uint8_t e=0; e<EXTRUDERS; e++)
            lcd_material_set_material(SELECTED_SCROLL_MENU_ITEM(), e);
        SET_FIRST_RUN_DONE();
        lcd_change_to_menu(lcd_menu_first_run_material_select_confirm_material);
        strcat_P(card.longFilename, PSTR(" as material,"));
    }
}
Ejemplo n.º 27
0
void command_handle_help(char *cmd_output, char (*args)[CMD_MAX_ARGS_SIZE]) {
  strcpy_P(uart_buf, help_info);
  strcat(uart_buf, "\x1B[1B\x1B[2K\x0D");
  strcat_P(uart_buf, reset_info);
  strcat(uart_buf, "\x1B[1B\x1B[2K\x0D");
  strcat_P(uart_buf, show_version_info);
  strcat(uart_buf, "\x1B[1B\x1B[2K\x0D");
  strcat_P(uart_buf, show_state_info);
  strcat(uart_buf, "\x1B[1B\x1B[2K\x0D");
  strcat_P(uart_buf, show_voltage_info);
  strcat(uart_buf, "\x1B[1B\x1B[2K\x0D");
  strcat_P(uart_buf, set_sense_info);
  strcat(uart_buf, "\x1B[1B\x1B[2K\x0D");
  strcat_P(uart_buf, set_conf_info);
  strcat(uart_buf, "\x1B[1B\x1B[2K\x0D");
  strcat_P(uart_buf, show_conf_info);
  strcat(uart_buf, "\x1B[1B\x1B[2K\x0D");
  strcpy(cmd_output, uart_buf);
}
Ejemplo n.º 28
0
// Run at most one waiting stream operation.
static void stream_poll(void) {
  char output[64];
  output[0] = 0;
  for (uint8_t i = 0; i < NUM_STREAM_TABLE; i++) {
    if (!g_stream_table[i].stream_id) { continue; }

    if (g_stream_table[i].queued_runs) {
      g_stream_table[i].queued_runs--;

      const struct fw_command_struct* fw_command =
          &fw_command_table[g_stream_table[i].cmd_index];
      cmd_func_ptr cmd_func =
          (cmd_func_ptr) pgm_read_word(&fw_command->func);
      char* ptr = output;
      *ptr++ = '!';
      strcpy_P(ptr, PSTR("STM "));
      ptr += 4;
      uint8_to_hex(&ptr, g_stream_table[i].stream_id);
      *ptr++ = ' ';
      strncpy_P(ptr, fw_command->code, 3);
      ptr += 3;
      *ptr = 0;
      uint8_t err = (*cmd_func)(g_stream_table[i].extra_args, ptr,
                                sizeof(output) - (ptr - output), 1);
      if (err == 0xff) {
        // Nothing to do.
        return;
      } else if (err != 0) {
        // Yikes, error!  Report the error and stop the stream.
        g_stream_table[i].stream_id = 0;
        g_stream_table[i].extra_args[0] = 0;
      }

      strcat_P(output, PSTR(EOL));

      usb_serial_write((uint8_t*) output, strlen(output));
      return;
    }
  }
}
Ejemplo n.º 29
0
String TimeStamp::toString() const {
  char str[25];

  // snprintf_P(str, 25, PSTR("%s, %02d.%02d.%02d %02d:%02d:%02d"), getDayOfWeekString(), day, month, year, hours, minutes, seconds);

  strcpy(str, getDayOfWeekString());
  strcat_P(str, PSTR(", 00.00.00 00:00:00"));
  str[4]  += (day / 10);
  str[5]  += (day % 10);
  str[7]  += (month / 10);
  str[8]  += (month % 10);
  str[10] += (year / 10);
  str[11] += (year % 10);
  str[13] += (hours / 10);
  str[14] += (hours % 10);
  str[16] += (minutes / 10);
  str[17] += (minutes % 10);
  str[19] += (seconds / 10);
  str[20] += (seconds % 10);

  return String(str);
}
Ejemplo n.º 30
0
static void handle_line(char* line_buf) {
  char output[80];
  char *ptr = output;
  *ptr++ = '<';

  uint8_t len = strlen((const char*) line_buf);
  if (len == 0) { return; }
  if (line_buf[0] == MAGIC_OVERRUN_CODE) {
    strcpy_P(ptr, PSTR("ERR overrun"));
  } else {
    // Try to parse the command.
    if (len < 3) {
      strcpy_P(ptr, PSTR("ERR short cmd"));
    } else if (len >= 4 && line_buf[3] != ' ') {
      strcpy_P(ptr, PSTR("ERR cmd not followed by space"));
    } else {
      int8_t index = find_message_index(line_buf);
      if (index < 0) {
        strcpy_P(ptr, PSTR("ERR" STR_UNKNOWN_CMD));
      } else {
        const struct fw_command_struct* fw_command = &fw_command_table[index];
        memcpy(ptr, line_buf, 3);
        ptr += 3;
        *ptr = 0; // so that commands start with an empty string
        cmd_func_ptr cmd_func =
            (cmd_func_ptr) pgm_read_word(&fw_command->func);
        (*cmd_func)(
            &line_buf[3],
            ptr, sizeof(output) - (ptr - output) - 3, 0);
      }
    }
  }

  strcat_P(output, PSTR(EOL));
  usb_serial_write((const uint8_t*) output, strlen(output));
}