• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ snprintf_P函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中snprintf_P函数的典型用法代码示例。如果您正苦于以下问题:C++ snprintf_P函数的具体用法?C++ snprintf_P怎么用?C++ snprintf_P使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了snprintf_P函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: parse_cmd_i2c_read_word_data

int16_t parse_cmd_i2c_read_word_data(char *cmd, char *output, uint16_t len)
{
	uint8_t cadr;
	uint8_t dadr;
	sscanf_P(cmd, PSTR("%u %u"), &cadr, &dadr);
	if (cadr < 7 || cadr > 127)
		return ECMD_ERR_PARSE_ERROR;
	uint16_t val = i2c_read_word_data(cadr, dadr);
#ifdef ECMD_MIRROR_REQUEST
		return ECMD_FINAL(snprintf_P(output, len, PSTR("i2c rwd %d %d 0x%X"), cadr, dadr, val));
#else
		return ECMD_FINAL(snprintf_P(output, len, PSTR("0x%X"), val));
#endif
}
开发者ID:HansBaechle,项目名称:ethersex,代码行数:14,代码来源:ecmd.c


示例2: parse_cmd_i2c_lm75

int16_t
parse_cmd_i2c_lm75(char *cmd, char *output, uint16_t len)
{
	while(*cmd == ' ') cmd++;
	if (*cmd < '0' || *cmd > '7') return ECMD_ERR_PARSE_ERROR;
	int16_t temp = i2c_lm75_read_temp(I2C_SLA_LM75 + (cmd[0] - '0'));
	if (temp == 0xffff)
	return ECMD_FINAL(snprintf_P(output, len, PSTR("no sensor detected")));
#ifdef ECMD_MIRROR_REQUEST
	return ECMD_FINAL(snprintf_P(output, len, PSTR("lm75 %d %d.%d"), (cmd[0] - '0'), temp / 10, temp % 10));
#else
	return ECMD_FINAL(snprintf_P(output, len, PSTR("%d.%d"), temp / 10, temp % 10));
#endif
}
开发者ID:HansBaechle,项目名称:ethersex,代码行数:14,代码来源:ecmd.c


示例3: parse_cmd_i2c_write_byte

int16_t parse_cmd_i2c_write_byte(char *cmd, char *output, uint16_t len)
{
	uint8_t adr;
	uint8_t data;
	sscanf_P(cmd, PSTR("%u %x"), &adr, &data);
	if (adr < 7 || adr > 127)
		return ECMD_ERR_PARSE_ERROR;
	uint16_t ret = i2c_write_byte(adr, data);
#ifdef ECMD_MIRROR_REQUEST
	return ECMD_FINAL(snprintf_P(output, len, PSTR("i2c wbb %d 0x%X"), adr, ret));
#else
	return ECMD_FINAL(snprintf_P(output, len, PSTR("0x%X"), ret));
#endif
}
开发者ID:HansBaechle,项目名称:ethersex,代码行数:14,代码来源:ecmd.c


示例4: parse_cmd_fs_format

int16_t
parse_cmd_fs_format (char *cmd, char *output, uint16_t len)
{
  (void) cmd;
  (void) output;
  (void) len;

  if (fs_format (&fs) != FS_OK) 
    return ECMD_FINAL(snprintf_P(output, len, PSTR("fs: error while formating")));
  if (fs_init () != FS_OK) 
    return ECMD_FINAL(snprintf_P(output, len, PSTR("fs: error while initializing")));

  return ECMD_FINAL_OK;
}
开发者ID:1234tester,项目名称:ethersex,代码行数:14,代码来源:ecmd.c


示例5: parse_cmd_free

int16_t
parse_cmd_free(char *cmd, char *output, uint16_t len)
{
  /* trick: use bytes on cmd as "connection specific static variables" */
  if (cmd[0] != ECMD_STATE_MAGIC)
  {                             /* indicator flag: real invocation:  0 */
    cmd[0] = ECMD_STATE_MAGIC;  /*                 continuing call: 23 */
    cmd[1] = 0;                 /* counter for output lines */
  }

  /* Docu March 2009: http://www.nongnu.org/avr-libc/user-manual/malloc.html
   * Stack size: RAMEND-SP
   * Heap size: __brkval-__heap_start
   * Space between stack and heap: SP-__brkval
   * Caution: __brkval is 0 when malloc was not called yet (use __heap_start instead)
   * 
   * Size of network packet frames is stored in NET_MAX_FRAME_LENGTH
   */

  size_t f =
    (size_t) (__brkval ? (size_t) __brkval : (size_t) & __heap_start);

  /* we want an output like this:
   * free: 16234/32768
   * heap: 10234
   * net: 500
   */
  switch (cmd[1]++)
  {
    case 0:
      return ECMD_AGAIN(snprintf_P(output, len,
                                   PSTR("free: %u/%u"),
                                   SP - f, RAM_SIZE));
#ifndef UIP_SUPPORT
    default:
      return ECMD_FINAL(snprintf_P(output, len,
                                   PSTR("heap: %u"),
                                   f - (size_t) & __heap_start));
#else
    case 1:
      return ECMD_AGAIN(snprintf_P(output, len,
                                   PSTR("heap: %u"),
                                   f - (size_t) & __heap_start));
    default:
      return ECMD_FINAL(snprintf_P(output, len,
                                   PSTR("net: " xstr(NET_MAX_FRAME_LENGTH))));
#endif
  }
}
开发者ID:AnDann,项目名称:ethersex,代码行数:49,代码来源:parser.c


示例6: parse_cmd_i2c_write_word_data

int16_t parse_cmd_i2c_write_word_data(char *cmd, char *output, uint16_t len)
{
	uint8_t cadr;
	uint8_t dadr;
	uint16_t data;
	sscanf_P(cmd, PSTR("%u %u %x"), &cadr, &dadr, &data);
	if (cadr < 7 || cadr > 127)
		return ECMD_ERR_PARSE_ERROR;
	uint16_t ret = i2c_write_word_data(cadr, dadr, data);
#ifdef ECMD_MIRROR_REQUEST
	return ECMD_FINAL(snprintf_P(output, len, PSTR("i2c wwd %d %d 0x%02X"), cadr, dadr, ret));
#else
	return ECMD_FINAL(snprintf_P(output, len, PSTR("0x%02X"), ret));
#endif
}
开发者ID:Wiiilmaa,项目名称:ethersex,代码行数:15,代码来源:ecmd.c


示例7: parse_cmd_i2c_max7311_getINw

int16_t parse_cmd_i2c_max7311_getINw(char *cmd, char *output, uint16_t len)
{
  uint8_t adr;
  uint16_t data;
  uint8_t ret;
  sscanf_P(cmd, PSTR("%hhu"), &adr);
  if (adr > 0x6F)
    return ECMD_ERR_PARSE_ERROR;
  ret = i2c_max7311_getINw(adr, &data);
  if (ret == 0) {
    return ECMD_FINAL(snprintf_P(output, len, PSTR("%X"), data));
  }else{
    return ECMD_FINAL(snprintf_P(output, len, PSTR("no sensor detected")));
  }
}
开发者ID:HansBaechle,项目名称:ethersex,代码行数:15,代码来源:ecmd.c


示例8: parse_cmd_i2c_ds1631_stop

int16_t parse_cmd_i2c_ds1631_stop(char *cmd, char *output, uint16_t len)
{
	uint8_t adr;
	sscanf_P(cmd, PSTR("%u"), &adr);
	if (adr > 7)
		return ECMD_ERR_PARSE_ERROR;
	uint16_t temp = i2c_ds1631_start_stop(I2C_SLA_DS1631 + adr,0);
	if (temp == 0xffff)
		return ECMD_FINAL(snprintf_P(output, len, PSTR("no sensor detected")));
#ifdef ECMD_MIRROR_REQUEST
	return ECMD_FINAL(snprintf_P(output, len, PSTR("ds1631 stop %d ok"),adr));
#else
	return ECMD_FINAL(snprintf_P(output, len, PSTR("ok")));
#endif
}
开发者ID:HansBaechle,项目名称:ethersex,代码行数:15,代码来源:ecmd.c


示例9: cTR_CC06

//------------------------------------------------------------------------------------
static int cTR_CC06(void)
{

	// Aplico un pulso de cierre de regulacion y salgo a
	// esperar 1 minuto por otro ciclo.
	pv_DCsetValvulas(V_CERRAR, V_CERRAR);
	snprintf_P( cons_printfBuff,sizeof(cons_printfBuff),PSTR(" fuzzy_VALVES: A-CLOSE, B-CLOSE\r\n\0"));
	u_debugPrint(D_CONSIGNA, cons_printfBuff, sizeof(cons_printfBuff) );

	snprintf_P( cons_printfBuff,sizeof(cons_printfBuff),PSTR(" fuzzy END\r\n\0"));
	u_debugPrint(D_CONSIGNA, cons_printfBuff, sizeof(cons_printfBuff) );

	pv_consignaPrintExitMsg(6);
	return(ccST_01);
}
开发者ID:ppeluffo,项目名称:sp5KV5_3CH,代码行数:16,代码来源:sp5KV5_3CH_tkConsignaCONT.c


示例10: parse_cmd_lcd_backlight

int16_t parse_cmd_lcd_backlight(char *cmd, char *output, uint16_t len)
{
  if (strlen(cmd) < 1) 
#ifdef HD44780_BACKLIGHT_INV
    return ECMD_FINAL(snprintf_P(output, len, back_light ? PSTR("off") : PSTR("on")));
#else
    return ECMD_FINAL(snprintf_P(output, len, back_light ? PSTR("on") : PSTR("off")));
#endif
  if (!strncmp_P(cmd + 1, PSTR("on"), 2))
#ifdef HD44780_BACKLIGHT_INV
    hd44780_backlight(0);
#else
    hd44780_backlight(1);
#endif
  else if (!strncmp_P(cmd + 1, PSTR("off"), 3)) 
开发者ID:S-Metz,项目名称:ethersex,代码行数:15,代码来源:ecmd.c


示例11: parse_cmd_fs_mkfile

int16_t
parse_cmd_fs_mkfile (char *cmd, char *output, uint16_t len)
{
  /* ignore leading spaces */
  while (*cmd == ' ')
    cmd ++;

  fs_status_t ret = fs_create (&fs, cmd);
  
  if (ret != FS_OK)
    return ECMD_FINAL(snprintf_P(output, len, PSTR("fs_create: returned 0x%02x"), ret));

  fs_inode_t i = fs_get_inode (&fs, cmd);
  return ECMD_FINAL(snprintf_P(output, len, PSTR("fs_create: inode 0x%04x"), i));
}
开发者ID:EtherGraf,项目名称:ethersex,代码行数:15,代码来源:ecmd.c


示例12: powerport_page_print_page

void powerport_page_print_page(eds_powerport_page_block_t *p)
{
	char s[40];
	canix_frame message;

	// LCD Bildschirm loeschen
	lcd_clrscr();

	// 1. Zeile
	snprintf_P(s,sizeof(s), PSTR("%s"), p->line0); 
	lcd_gotoxy(0,0);
	lcd_puts(s);

	snprintf_P(s,sizeof(s), PSTR("%s"), p->line1); 
	lcd_gotoxy(0,1);
	lcd_puts(s);

	// In powerport_page_state wird spaeter der State gespeichert; sollte
	// keine Meldung eintreffen, so nuetzt es nichts, wenn der User OK
	// drueckt - man weiss ja den State nicht und kann ihn nicht aendern!
	// Das erkennt man am Wert -1
	powerport_page_state = -1;
	powerport_page_timer = -1;

	// nun den Status des Powerports erfragen und (asynchron)
	// in powerport_page_can_callback weitermachen

	message.src = canix_selfaddr();
	message.dst = HCAN_MULTICAST_CONTROL;
	message.proto = HCAN_PROTO_SFP;
	message.data[0] = HCAN_SRV_HES;
	message.data[1] = HCAN_HES_POWER_GROUP_STATE_QUERY;
	message.data[2] = p->gruppe;
	message.size = 3;
	canix_frame_send_with_prio(&message, HCAN_PRIO_HI);

	canix_sleep_100th(1);

	message.src = canix_selfaddr();
	message.dst = HCAN_MULTICAST_CONTROL;
	message.proto = HCAN_PROTO_SFP;
	message.data[0] = HCAN_SRV_HES;
	message.data[1] = HCAN_HES_POWER_GROUP_TIMER_QUERY;
	message.data[2] = p->gruppe;
	message.size = 3;
	canix_frame_send_with_prio(&message, HCAN_PRIO_HI);

}
开发者ID:hcanIngo,项目名称:openHCAN,代码行数:48,代码来源:powerport_page.c


示例13: anTR_02

/*------------------------------------------------------------------------------------*/
static int anTR_02(void)
{

	// Tengo un mensaje que debo polear.
	AN_flags.msgPollNow = FALSE;

	AN_flags.start2poll = FALSE;

	// Es service: no salvo en EE
	AN_flags.saveFrameInBD = FALSE;

	// Para no tener problemas con el timer
	AN_counters.secs4poll = 60;
	AN_counters.secs4save = 60;

	// Por las dudas, siempre prendo
	pv_PrenderSensores();
	AN_counters.cTimer = SECS2PWRSETTLE;

	// Aqui los sensores deben estar prendidos.
	// Si por alguna razon los sensores estan apagados los prendo.
	if ( ! sensoresPrendidos ) {
		snprintf_P( aIn_printfBuff,sizeof(aIn_printfBuff),PSTR("WARN: Sensores apagados !!!\r\n\0"));
		FreeRTOS_write( &pdUART1, aIn_printfBuff, sizeof(aIn_printfBuff) );
		pv_PrenderSensores();
	}

	pv_AINprintExitMsg(2);
	return(anST_A02);
}
开发者ID:ppeluffo,项目名称:sp5KV5_3CH,代码行数:31,代码来源:sp5KV5_3CH_tkAnalogIn.c


示例14: parse_cmd_free

int16_t parse_cmd_free(char *cmd, char *output, uint16_t len)
{
	/* Docu March 2009: http://www.nongnu.org/avr-libc/user-manual/malloc.html
	Stack size: RAMEND-SP
	Heap size: __brkval-__heap_start
	Space between stack and heap: SP-__brkval
	Caution: __brkval is 0 when malloc was not called yet (use __heap_start instead)

	Size of network packet frames is stored in NET_MAX_FRAME_LENGTH
	*/

	extern char *__brkval;
	extern unsigned char __heap_start;
	size_t f = (size_t)(__brkval ? (size_t)__brkval : (size_t)&__heap_start);
	size_t allram = RAMEND;

	/* we want an output like this:
	free: 16234/32768
	heap: 10234
	net: 500
	*/
	return ECMD_FINAL(snprintf_P(output, len,
		PSTR("free: %d/%d\nheap: %d\nnet: " xstr(NET_MAX_FRAME_LENGTH)),
		SP-f, allram, f-(size_t)&__heap_start));
}
开发者ID:stettberger,项目名称:IR77,代码行数:25,代码来源:parser.c


示例15: protocolFormat

char * protocolFormat(MyMessage &message)
{
	snprintf_P(_fmtBuffer, MY_GATEWAY_MAX_SEND_LENGTH, PSTR("%d;%d;%d;%d;%d;%s\n"), message.sender,
	           message.sensor, (uint8_t)mGetCommand(message), (uint8_t)mGetAck(message), message.type,
	           message.getString(_convBuffer));
	return _fmtBuffer;
}
开发者ID:henrikekblad,项目名称:Arduino,代码行数:7,代码来源:MyProtocolMySensors.cpp


示例16: rolladen_page_print_page

void rolladen_page_print_page(eds_rolladen_page_block_t *p)
{
	char s[32];

	// LCD Bildschirm loeschen
	lcd_clrscr();

	// 1. Zeile
	snprintf_P(s,sizeof(s)-1, PSTR("%s"), p->line0);
	lcd_gotoxy(0,0);
	lcd_puts(s);

	snprintf_P(s,sizeof(s)-1, PSTR("%s"), p->line1);
	lcd_gotoxy(0,1);
	lcd_puts(s);
}
开发者ID:hcanIngo,项目名称:openHCAN,代码行数:16,代码来源:rolladen_page.c


示例17: snprintf_P

void MySensor::debugPrint(const char *fmt, ... ) {
	char fmtBuffer[300];
	if (isGateway) {
		// prepend debug message to be handled correctly by gw (C_INTERNAL, I_LOG_MESSAGE)
		snprintf_P(fmtBuffer, 299, PSTR("0;0;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE);
#ifdef __Raspberry_Pi
		printf(fmtBuffer);
#else
		Serial.print(fmtBuffer);
#endif
	}
	va_list args;
	va_start (args, fmt );
	va_end (args);
	if (isGateway) {
		// Truncate message if this is gateway node
		vsnprintf_P(fmtBuffer, 60, fmt, args);
		fmtBuffer[59] = '\n';
		fmtBuffer[60] = '\0';
	} else {
		vsnprintf_P(fmtBuffer, 299, fmt, args);
	}
	va_end (args);
#ifdef __Raspberry_Pi
	printf(fmtBuffer);
	fflush(stdout);
#else
	Serial.print(fmtBuffer);
	Serial.flush();
#endif
	//Serial.write(freeRam());
}
开发者ID:amleivar,项目名称:Raspberry,代码行数:32,代码来源:MySensor.cpp


示例18: CommandExecLogMem

CommandStatusIdType CommandExecLogMem(char* OutMessage)
{
    snprintf_P(OutMessage, TERMINAL_BUFFER_SIZE,
        PSTR("%S,%S"), PSTR(COMMAND_LOGMEM_LOADBIN), PSTR(COMMAND_LOGMEM_CLEAR) );

    return COMMAND_INFO_OK_WITH_TEXT_ID;
}
开发者ID:MarxGonzalez,项目名称:ChameleonMini,代码行数:7,代码来源:Commands.c


示例19: parse_cmd_pin_get

int16_t parse_cmd_pin_get(char *cmd, char *output, uint16_t len)
{
  uint16_t port, pin;

  uint8_t ret = sscanf_P(cmd, PSTR("%u %u"), &port, &pin);
  /* Fallback to named pins */
  if ( ret != 2 && *cmd) {
    uint8_t pincfg = named_pin_by_name(cmd + 1);
    if (pincfg != 255) {
        port = pgm_read_byte(&portio_pincfg[pincfg].port);
        pin = pgm_read_byte(&portio_pincfg[pincfg].pin);
        ret = 2;
    }
  }
  if (ret == 2 && port < IO_PORTS && pin < 8) {
    uint8_t pincfg = named_pin_by_pin(port, pin);
    uint8_t active_high = 1;
    if (pincfg != 255)  
      active_high = pgm_read_byte(&portio_pincfg[pincfg].active_high);
    return ECMD_FINAL(snprintf_P(output, len,
                      XOR_LOG(vport[port].read_pin(port) & _BV(pin), !(active_high))
                      ? PSTR("on") : PSTR("off")));
  } else
    return ECMD_ERR_PARSE_ERROR;
}
开发者ID:HansBaechle,项目名称:ethersex,代码行数:25,代码来源:ecmd_np.c


示例20: if

//------------------------------------------------------------------------------
bool HttpClient::createPostRequest(char* buffer, size_t bufferSize,
    const char* host, const char* path, const char* content, uint8_t flags) {
    // check flags
    if ((flags & F_KEEP_ALIVE) == (flags & F_CLOSE)) {
        return false;
    }
    else if ((flags & F_HEAD) == (flags & F_POST)) {
        return false;
    }
    // determine request type
    PGM_P request;
    if (flags & F_HEAD) {
        request = HTTP_REQUEST_HEAD;
    }
    else if (flags & F_POST) {
        request = HTTP_REQUEST_POST;
    }
    // determine connection type
    bool keepAlive = (flags & F_KEEP_ALIVE);
    PGM_P connection = keepAlive ? HTTP_FIELD_KEEP_ALIVE : HTTP_FIELD_CLOSE;
    // print the request to the buffer
    memset(buffer, 0x00, bufferSize);
    snprintf_P(
        buffer,
        bufferSize,
        request,
        path,
        host,
        connection,
        strlen(content),
        content
    );
    return true;
}
开发者ID:Dembrant,项目名称:avr-libraries,代码行数:35,代码来源:HttpClient.cpp



注:本文中的snprintf_P函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ snprintfz函数代码示例发布时间:2022-05-30
下一篇:
C++ snprintf函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap