本文整理匯總了C++中ECMD_FINAL函數的典型用法代碼示例。如果您正苦於以下問題:C++ ECMD_FINAL函數的具體用法?C++ ECMD_FINAL怎麽用?C++ ECMD_FINAL使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ECMD_FINAL函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: parse_cmd_sram_memtest
int16_t
parse_cmd_sram_memtest(char *cmd, char *output, uint16_t len)
{
if (sram_memtest())
return ECMD_FINAL_OK;
else
return ECMD_FINAL( snprintf_P(output, len,
PSTR("memtest error: see debugging output for more information")));
}
示例2: parse_cmd_ntp_status
int16_t parse_cmd_ntp_status(char *cmd, char *output, uint16_t len)
{
uint32_t last_sync = clock_last_sync();
int16_t last_delta = clock_last_delta();
uint16_t ntp_timer = clock_last_ntp();
uint16_t dcf_counter = clock_dcf_count();
uint16_t ntp_counter = clock_ntp_count();
return ECMD_FINAL(snprintf_P(output,len,PSTR("Update:%lu\ndelta:%d\nOCR1A:%u\nDCF/NTP:%d/%d\nResyn:%d"), last_sync, last_delta, OCR1A, dcf_counter, ntp_counter, ntp_timer));
}
示例3: parse_cmd_sht_temp
int16_t
parse_cmd_sht_temp(char *cmd, char *output, uint16_t len)
{
uint16_t raw_temp = 0;
int8_t ret;
// the longest error message is 9 bytes + \0, all possible temp/hex values fit
if (len < 10)
return ECMD_FINAL(ECMD_ERR_PARSE_ERROR);
ret = sht_get(&raw_temp, NULL);
if (ret == SHT_OK)
return
ECMD_FINAL(itoa_fixedpoint(sht_convert_temp(&raw_temp), 2, output, len));
else
return ECMD_FINAL(output_sht_error(ret, output));
}
示例4: parse_cmd_sd_rm
int16_t
parse_cmd_sd_rm(char *cmd, char *output, uint16_t len)
{
while (*cmd == ' ')
cmd++;
return (vfs_sd_unlink(cmd) == 0 ?
ECMD_FINAL_OK : ECMD_FINAL(snprintf_P(output, len, PSTR("write error"))));
}
示例5: parse_cmd_version
int16_t
parse_cmd_version(char *cmd, char *output, uint16_t len)
{
(void) cmd;
strncpy_P(output, pstr_E6_VERSION_STRING_LONG, len);
return ECMD_FINAL(strlen(output));
}
示例6: parse_cmd_date
int16_t parse_cmd_date(char *cmd, char *output, uint16_t len)
{
struct clock_datetime_t date;
clock_current_localtime(&date);
return ECMD_FINAL(snprintf_P(output, len, PSTR("%s %02d.%02d.%04d %02d:%02d:%02d"),
weekdays[date.dow],
date.day, date.month, date.year + 1900,
date.hour, date.min, date.sec, date.day));
}
示例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) {
#ifdef ECMD_MIRROR_REQUEST
return ECMD_FINAL(snprintf_P(output, len, PSTR("max7311 getINw %u 0x%X"), adr, data));
#else
return ECMD_FINAL(snprintf_P(output, len, PSTR("%X"), data));
#endif
}else{
return ECMD_FINAL(snprintf_P(output, len, PSTR("no sensor detected")));
}
}
示例8: parse_cmd_sd_info
int16_t
parse_cmd_sd_info(char *cmd, char *output, uint16_t len)
{
struct sd_raw_info info;
if (sd_raw_get_info(&info) == 0)
return ECMD_FINAL(snprintf_P(output, len, PSTR("read error")));
uint16_t cap = info.capacity / 1000000UL;
return ECMD_FINAL(snprintf_P(output, len,
PSTR("%3s %6s %d/20%02d %uMB %d %d %d"),
&info.oem, &info.product,
info.manufacturing_month,
info.manufacturing_year,
cap,
info.flag_copy,
info.flag_write_protect,
info.format));
}
示例9: parse_cmd_rfm12_status
int16_t
parse_cmd_rfm12_status(char *cmd, char *output, uint16_t len)
{
uint16_t s;
rfm12_prologue(RFM12_MODUL_IP);
s = rfm12_get_status();
rfm12_epilogue();
return ECMD_FINAL(snprintf_P(output, len, PSTR("rfm12 status: %04x"), s));
}
示例10: parse_cmd_yport_stats
int16_t parse_cmd_yport_stats(char *cmd, char *output, uint16_t len)
{
int16_t chars = snprintf_P(output, len,
PSTR("rx fe=%u, ov=%u, pe=%u, bf=%u"),
yport_rx_frameerror,
yport_rx_overflow,
yport_rx_parityerror,
yport_rx_bufferfull);
return ECMD_FINAL(chars);
}
示例11: parse_cmd_date
int16_t parse_cmd_date(char *cmd, char *output, uint16_t len)
{
char *weekdays = "Sun\0Mon\0Tue\0Wed\0Thu\0Fri\0Sat";
struct clock_datetime_t date;
clock_current_localtime(&date);
return ECMD_FINAL(snprintf_P(output, len, PSTR("%.2d:%.2d:%.2d %.2d.%.2d.%.2d %s"),
date.hour, date.min, date.sec, date.day, date.month, date.year % 100,
weekdays + date.dow * 4));
}
示例12: output_sht_error
// output error messages to ECMDs output buffer
static int16_t
output_sht_error(int8_t returncode, char *output)
{
switch (returncode)
{
case SHT_ERR_CRC:
#define SHT_ERR_CRC_MSG "crc error"
strcpy_P(output, PSTR(SHT_ERR_CRC_MSG));
return ECMD_FINAL(sizeof(SHT_ERR_CRC_MSG));
case SHT_ERR_TIMEOUT:
#define SHT_ERR_TIMEOUT_MSG "timeout"
strcpy_P(output, PSTR(SHT_ERR_TIMEOUT_MSG));
return ECMD_FINAL(sizeof(SHT_ERR_TIMEOUT_MSG));
case SHT_ERR_PROTOCOL:
default:
#define SHT_ERR_PROTOCOL_MSG "no sht"
strcpy_P(output, PSTR(SHT_ERR_PROTOCOL_MSG));
return ECMD_FINAL(sizeof(SHT_ERR_PROTOCOL_MSG));
}
}
示例13: parse_cmd_i2c_max7311_set
int16_t parse_cmd_i2c_max7311_set(char *cmd, char *output, uint16_t len)
{
uint8_t adr;
uint8_t bit;
uint8_t state;
uint8_t ret;
sscanf_P(cmd, PSTR("%hhu %hhu %hhu"), &adr, &bit, &state);
if (adr > 0x6F || bit > 15)
return ECMD_ERR_PARSE_ERROR;
ret = i2c_max7311_set(adr, bit, state);
if (ret == 0) {
#ifdef ECMD_MIRROR_REQUEST
return ECMD_FINAL(snprintf_P(output, len, PSTR("max7311 set %u %u %u"), adr, bit, state));
#else
return ECMD_FINAL_OK;
#endif
}else{
return ECMD_FINAL(snprintf_P(output, len, PSTR("no sensor detected")));
}
}
示例14: parse_cmd_irmp_receive
int16_t
parse_cmd_irmp_receive (char *cmd, char *output, uint16_t len)
{
irmp_data_t irmp_data;
return (irmp_read (&irmp_data)
? ECMD_FINAL (sprintf_P (output, PSTR ("%d:%04X:%04X:%02X\n"),
irmp_data.protocol,
irmp_data.address,
irmp_data.command,
irmp_data.flags)) : ECMD_FINAL_OK);
}
示例15: parse_cmd_get
int16_t
parse_cmd_get(char *cmd, char *output, uint16_t len)
{
uint8_t pos;
sscanf_P(cmd, PSTR("%hhu"), &pos);
if (pos >= ECMD_SCRIPT_MAX_VARIABLES)
{
return to_many_vars_error_message(output, len);
}
return ECMD_FINAL(snprintf_P(output, len, PSTR("%s"), vars[pos].value));
}