本文整理汇总了C++中snprintf_P函数的典型用法代码示例。如果您正苦于以下问题:C++ snprintf_P函数的具体用法?C++ snprintf_P怎么用?C++ snprintf_P使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了snprintf_P函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
示例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
}
示例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
}
示例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;
}
示例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
}
}
示例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
}
示例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")));
}
}
示例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
}
示例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);
}
示例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))
示例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));
}
示例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);
}
示例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);
}
示例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));
}
示例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;
}