本文整理汇总了C++中FSTR函数的典型用法代码示例。如果您正苦于以下问题:C++ FSTR函数的具体用法?C++ FSTR怎么用?C++ FSTR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FSTR函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: setStatus
void MTD_FLASHMEM HTTPGPIOResponseHTML::flush()
{
setStatus(STR_200_OK);
addHeader(STR_Content_Type, STR_TEXTHTML);
char const* cmd = getRequest().query[FSTR("cmd")];
if (cmd && f_strcmp(cmd, FSTR("set")) == 0)
{
// set gpio
HTTPHelperConfiguration::GPIOSetValue(this);
}
else if (cmd && f_strcmp(cmd, FSTR("conf")) == 0)
{
// conf gpio
HTTPHelperConfiguration::GPIOConf(this);
}
char const* gpio = getRequest().query[STR_gpio];
if (gpio)
{
uint8_t gpion = strtol(gpio, NULL, 10);
addContent(GPIO(gpion).read()? STR_1 : STR_0);
}
HTTPResponse::flush();
}
开发者ID:wony365,项目名称:ESPWebFramework,代码行数:26,代码来源:fdvconfmanager.cpp
示例2: enumerate
static int enumerate(struct usb_host_device_t *device_p)
{
struct usb_descriptor_interface_t *int_desc_p;
std_printf(FSTR("Enumerating a MASS_STORAGE device.\r\n"));
int_desc_p = usb_desc_get_interface(device_p->descriptors.buf,
device_p->descriptors.size,
1,
0);
if (int_desc_p == NULL) {
return (-1);
}
if (usb_host_device_set_configuration(device_p, 1) != 0) {
return (-1);
}
get_max_lun(device_p);
scsi_get_inquiry(device_p);
if (scsi_test_unit_ready(device_p) != 0) {
std_printf(FSTR("device is not ready\r\n"));
}
return (0);
}
开发者ID:eerimoq,项目名称:simba,代码行数:29,代码来源:mass_storage.c
示例3: get_max_lun
static int get_max_lun(struct usb_host_device_t *device_p)
{
struct usb_setup_t setup;
uint8_t buf[1];
std_printf(FSTR("get number of LUN:s (logical units) from mass storage device\r\n"));
/* Initiate the setup datastructure. */
setup.request_type = (REQUEST_TYPE_DATA_DIRECTION_DEVICE_TO_HOST
| REQUEST_TYPE_TYPE_CLASS
| REQUEST_TYPE_RECIPIENT_INTERFACE);
setup.request = REQUEST_GET_MAX_LUN;
setup.u.base.value = 0;
setup.u.base.index = 0;
setup.length = 1;
if (usb_host_device_control_transfer(device_p,
&setup,
buf,
sizeof(buf)) != sizeof(buf))
{
return (-1);
}
std_printf(FSTR("LUN max = %d\r\n"), buf[0]);
/* Save the max LUN number. */
//device_p->max_lun = 0;
return (0);
}
开发者ID:eerimoq,项目名称:simba,代码行数:31,代码来源:mass_storage.c
示例4: cmd_set_bits_per_sample_cb
static int cmd_set_bits_per_sample_cb(int argc,
const char *argv[],
void *out_p,
void *in_p,
void *arg_p,
void *call_arg_p)
{
long bits_per_sample;
if (argc != 2) {
std_fprintf(out_p, FSTR("Usage: %s <number of bits>\r\n"),
argv[0]);
return (-EINVAL);
}
if (std_strtol(argv[1], &bits_per_sample) != 0) {
std_fprintf(out_p, FSTR("Usage: %s <number of bits>\r\n"),
argv[0]);
return (-EINVAL);
}
if ((bits_per_sample < 0) || (bits_per_sample > 12)) {
std_printf(FSTR("The number of bits per sample bust be "
"an interger from 0 to 12.\r\n"));
return (-EINVAL);
}
return (music_player_set_bits_per_sample(&music_player,
bits_per_sample));
}
开发者ID:eerimoq,项目名称:simba,代码行数:33,代码来源:main.c
示例5: main
int main()
{
int address;
int number_of_slaves;
sys_start();
i2c_module_init();
i2c_init(&i2c, &i2c_0_dev, I2C_BAUDRATE_100KBPS, -1);
i2c_start(&i2c);
std_printf(FSTR("Scanning the i2c bus for slaves...\r\n"
"\r\n"));
number_of_slaves = 0;
for (address = 0; address < 128; address++) {
if (i2c_scan(&i2c, address) == 1) {
std_printf(FSTR("Found slave with address 0x%x.\r\n"), address);
number_of_slaves++;
}
}
std_printf(FSTR("\r\n"
"Scan complete. Found %d slaves.\r\n"), number_of_slaves);
return (0);
}
开发者ID:eerimoq,项目名称:simba,代码行数:28,代码来源:main.c
示例6: cmd_list_cb
static int cmd_list_cb(int argc,
const char *argv[],
void *out_p,
void *in_p,
void *arg_p,
void *call_arg_p)
{
struct song_t *song_p;
int number;
if (argc != 1) {
std_fprintf(out_p, FSTR("Usage: %s\r\n"), argv[0]);
return (1);
}
/* Write the header. */
std_fprintf(out_p,
FSTR("NUMBER NAME LENGTH\r\n"));
/* Iterate over all songs in the ordered hash map. */
for (number = FIRST_SONG_NUMBER;
((song_p = hash_map_get(&song_map, number)) != NULL);
number++) {
std_fprintf(out_p,
FSTR("%6d %15s %4d:%02d\r\n"),
song_p->number,
song_p->name,
song_p->minutes,
song_p->seconds);
}
return (0);
}
开发者ID:eerimoq,项目名称:simba,代码行数:34,代码来源:main.c
示例7: FSTR
void MTD_FLASHMEM HTTPHelperConfiguration::setDateTime(HTTPTemplateResponse* response)
{
// set current date and time
char const* dateStr = response->getRequest().form[STR_date];
char const* timeStr = response->getRequest().form[STR_time];
if (dateStr && timeStr)
{
DateTime dt;
dt.decode(dateStr, FSTR("%d/%m/%Y"));
dt.decode(timeStr, FSTR("%H:%M:%S"));
DateTime::setCurrentDateTime(dt);
}
// set timezone and NTP server
char const* tzh = response->getRequest().form[STR_tzh];
char const* tzm = response->getRequest().form[STR_tzm];
char const* ntpsrv = response->getRequest().form[STR_ntpsrv];
if (tzh && tzm)
{
ConfigurationManager::setDateTimeParams(strtol(tzh, NULL, 10),
strtol(tzm, NULL, 10),
ntpsrv? ntpsrv : STR_);
ConfigurationManager::applyDateTime();
}
}
开发者ID:wony365,项目名称:ESPWebFramework,代码行数:25,代码来源:fdvconfmanager.cpp
示例8: storage_init
static int storage_init(fat16_read_t *read_p,
fat16_write_t *write_p,
void **arg_pp)
{
std_printf(FSTR("SD storage.\r\n"));
std_printf(FSTR("spi bitrate = %lu kbps\r\n"),
2 * 16 * SAMPLES_PER_SOCOND / 1024);
/* Initialize SPI for the SD card. */
spi_init(&spi,
&spi_device[0],
&pin_d53_dev,
SPI_MODE_MASTER,
SPI_SPEED_2MBPS,
0,
1);
sd_init(&sd, &spi);
if (sd_start(&sd) != 0) {
return (-1);
}
std_printf(FSTR("sd card started\r\n"));
*read_p = (fat16_read_t)sd_read_block;
*write_p = (fat16_write_t)sd_write_block;
*arg_pp = &sd;
return (0);
}
开发者ID:eerimoq,项目名称:simba,代码行数:32,代码来源:main.c
示例9: cmd_read_cb
static int cmd_read_cb(int argc,
const char *argv[],
void *out_p,
void *in_p,
void *arg_p,
void *call_arg_p)
{
int pin;
int value;
if (argc != 2) {
std_fprintf(out_p, FSTR("Usage: %s <pin>\r\n"), argv[0]);
return (-EINVAL);
}
/* Get pin. */
pin = board_pin_string_to_device_index(argv[1]);
if (pin == -1) {
std_fprintf(out_p, FSTR("%s: bad pin\r\n"), argv[1]);
return (-EINVAL);
}
value = pin_device_read(&pin_device[pin]);
if (value == 1) {
std_fprintf(out_p, FSTR("high\r\n"));
} else {
std_fprintf(out_p, FSTR("low\r\n"));
}
return (0);
}
开发者ID:eerimoq,项目名称:simba,代码行数:35,代码来源:pin.c
示例10: addHeader
// should be called only after setStatus, addHeader and addContent
void MTD_FLASHMEM HTTPResponse::flush()
{
// status line
m_httpHandler->getSocket()->writeFmt(FSTR("HTTP/1.1 %s\r\n"), m_status);
// HTTPResponse headers
addHeader(FSTR("Connection"), FSTR("close"));
// user headers
for (uint32_t i = 0; i != m_headers.getItemsCount(); ++i)
{
Fields::Item* item = m_headers[i];
m_httpHandler->getSocket()->writeFmt(FSTR("%s: %s\r\n"), APtr<char>(t_strdup(item->key)).get(), APtr<char>(t_strdup(item->value)).get());
}
// content length header
m_httpHandler->getSocket()->writeFmt(FSTR("%s: %d\r\n\r\n"), STR_Content_Length, m_content.getItemsCount());
// actual content
if (m_content.getItemsCount() > 0)
{
CharChunksIterator iter = m_content.getIterator();
CharChunkBase* chunk = iter.getCurrentChunk();
while (chunk)
{
m_httpHandler->getSocket()->write((uint8_t const*)chunk->data, chunk->getItems());
chunk = iter.moveToNextChunk();
}
m_content.clear();
}
}
开发者ID:krachlatte,项目名称:ESPWebFramework,代码行数:32,代码来源:fdvnetwork.cpp
示例11: getClientModeWiFiParams
void MTD_FLASHMEM HTTPHelperConfiguration::getClientModeWiFiParams(HTTPTemplateResponse* response)
{
char const* SSID;
char const* securityKey;
ConfigurationManager::getClientParams(&SSID, &securityKey);
response->addParamStr(FSTR("CLPSW"), securityKey);
response->addParamStr(FSTR("CLSSID"), SSID);
}
开发者ID:wony365,项目名称:ESPWebFramework,代码行数:8,代码来源:fdvconfmanager.cpp
示例12: scsi_get_inquiry
static int scsi_get_inquiry(struct usb_host_device_t *device_p)
{
struct cbw_t cbw;
struct csw_t csw;
struct scsi_cdb_inquiry_t *cdb_p;
struct scsi_cdb_inquiry_data_t inquiry_data;
std_printf(FSTR("get inquiry\r\n"));
device_p->max_packet_size = 512;
/* Initiate the Command Block Wrapper. */
memset(&cbw, 0, sizeof(cbw));
cbw.signature = CBW_SIGNATURE;
cbw.tag = (uint32_t)device_p;
cbw.data_transfer_length = sizeof(inquiry_data);
cbw.flags = 0x80;
cbw.lun = 0;
cbw.command_block_length = sizeof(*cdb_p);
cdb_p = (struct scsi_cdb_inquiry_t *)cbw.command_block;
cdb_p->operation_code = SCSI_CDB_OPERATION_CODE_INQUIRY;
cdb_p->allocation_length = sizeof(inquiry_data);
/* Write the Command Block Wrapper to the device. */
if (usb_host_device_write(device_p, 2, &cbw, sizeof(cbw))
!= sizeof(cbw)) {
std_printf(FSTR("failed to write the command block wrapper.\r\n"));
return (-1);
}
/* Read the data from the device. */
if (usb_host_device_read(device_p, 1, &inquiry_data, sizeof(inquiry_data))
!= sizeof(inquiry_data)) {
std_printf(FSTR("Failed to read data.\r\n"));
return (-1);
}
/* Read the Comand Status Wrapper from the device. */
if (usb_host_device_read(device_p, 1, &csw, sizeof(csw))
!= sizeof(csw)) {
return (-1);
}
if (csw.status != CSW_STATUS_PASSED) {
std_printf(FSTR("status = %d\r\n"), csw.status);
return (-1);
}
std_printf(FSTR("version = %d\r\n"), inquiry_data.version);
return (csw.data_residue);
}
开发者ID:eerimoq,项目名称:simba,代码行数:56,代码来源:mass_storage.c
示例13: print_exit_message
/**
* Print a message after a script has been executed.
*/
static void print_exit_message(int res, const char *prefix_p)
{
if (res == 1) {
std_printf(FSTR("%s exited normally.\r\n\r\n"), prefix_p);
} else if (res & PYEXEC_FORCED_EXIT) {
std_printf(FSTR("%s forced exit.\r\n\r\n"), prefix_p);
} else {
std_printf(FSTR("%s exited abnormally.\r\n\r\n"), prefix_p);
}
}
开发者ID:eerimoq,项目名称:pumbaa,代码行数:13,代码来源:main.c
示例14: usb_host_class_mass_storage_device_read
ssize_t usb_host_class_mass_storage_device_read(
struct usb_host_device_t *device_p,
void *buf_p,
size_t address,
size_t size)
{
struct cbw_t cbw;
struct csw_t csw;
struct scsi_cdb_read_t *cdb_p;
device_p->max_packet_size = 512;
/* Initiate the Command Block Wrapper. */
memset(&cbw, 0, sizeof(cbw));
cbw.signature = CBW_SIGNATURE;
cbw.tag = (uint32_t)device_p;
cbw.data_transfer_length = size;
cbw.flags = 0x80;
cbw.lun = 0;
cbw.command_block_length = sizeof(*cdb_p);
cdb_p = (struct scsi_cdb_read_t *)cbw.command_block;
cdb_p->operation_code = SCSI_CDB_OPERATION_CODE_READ_10;
cdb_p->logical_block_address = htonl(address / 512);
cdb_p->transfer_length = htons(size / 512);
/* Write the Command Block Wrapper to the device. */
if (usb_host_device_write(device_p, 2, &cbw, sizeof(cbw))
!= sizeof(cbw)) {
std_printf(FSTR("failed to write the command block wrapper.\r\n"));
return (-1);
}
/* Read the dat from the device. */
if (usb_host_device_read(device_p, 1, buf_p, size) != size) {
std_printf(FSTR("Failed to read data.\r\n"));
return (-1);
}
/* Read the Comand Status Wrapper from the device. */
if (usb_host_device_read(device_p, 1, &csw, sizeof(csw))
!= sizeof(csw)) {
return (-1);
}
if (csw.status != CSW_STATUS_PASSED) {
std_printf(FSTR("status = %d\r\n"), csw.status);
return (-1);
}
return (size - csw.data_residue);
}
开发者ID:eerimoq,项目名称:simba,代码行数:55,代码来源:mass_storage.c
示例15: thrd_set_name
/**
* The listener thread main function. The listener listens for
* connections from clients.
*/
static void *listener_main(void *arg_p)
{
struct http_server_t *self_p = arg_p;
struct http_server_listener_t *listener_p;
struct http_server_connection_t *connection_p;
struct inet_addr_t addr;
thrd_set_name(self_p->listener_p->thrd.name_p);
listener_p = self_p->listener_p;
if (socket_open_tcp(&listener_p->socket) != 0) {
log_object_print(NULL,
LOG_ERROR,
FSTR("Failed to open socket."));
return (NULL);
}
if (inet_aton(listener_p->address_p, &addr.ip) != 0) {
return (NULL);
}
addr.port = listener_p->port;
if (socket_bind(&listener_p->socket, &addr) != 0) {
log_object_print(NULL,
LOG_ERROR,
FSTR("Failed to bind socket."));
return (NULL);
}
if (socket_listen(&listener_p->socket, 3) != 0) {
log_object_print(NULL,
LOG_ERROR,
FSTR("Failed to listen on socket."));
return (NULL);
}
/* Wait for clients to connect. */
while (1) {
/* Allocate a connection. */
connection_p = allocate_connection(self_p);
/* Wait for a client to connect. */
socket_accept(&listener_p->socket,
&connection_p->socket,
&addr);
handle_accept(self_p, connection_p);
}
return (NULL);
}
开发者ID:eerimoq,项目名称:simba,代码行数:59,代码来源:http_server.c
示例16: strtol
void MTD_FLASHMEM HTTPHelperConfiguration::setAPWiFiParams(HTTPTemplateResponse* response)
{
char const* APCH = response->getRequest().form[FSTR("APCH")];
char const* APSEC = response->getRequest().form[FSTR("APSEC")];
if (APCH && APSEC)
ConfigurationManager::setAccessPointParams(response->getRequest().form[FSTR("APSSID")],
response->getRequest().form[FSTR("APPSW")],
strtol(APCH, NULL, 10),
(WiFi::SecurityProtocol)strtol(APSEC, NULL, 10),
response->getRequest().form[FSTR("APHSSID")] != NULL);
}
开发者ID:wony365,项目名称:ESPWebFramework,代码行数:12,代码来源:fdvconfmanager.cpp
示例17: if
void MTD_FLASHMEM MultipartFormDataProcessor::handle_DecodingHeaders(char c) {
static char const EOH[4] = {0x0D, 0x0A, 0x0D, 0x0A};
if (c == EOH[substate]) {
++substate;
if (substate == 2) {
// useful if this is not an EOH to separate headers
headers->append(0x0D, 1);
} else if (substate == 4) {
// end of headers
headers->append(0, 1); // add string terminating zero
// look for "name" parameter
CharChunksIterator keyBegin;
extractParameter(FSTR(" name="), headers->getIterator(), &keyBegin, &nameBegin, &nameEnd);
// look for "filename" parameter
CharChunksIterator filenameBegin, filenameEnd;
if (extractParameter(FSTR(" filename="), headers->getIterator(), &keyBegin, &filenameBegin, &filenameEnd)) {
//// this is a file
// add "filename" to form fields
filenameBegin = getFilename(filenameBegin,
filenameEnd); // some browsers send a full path instead of a simple file name (IE)
formfields->add(keyBegin + 1, keyBegin + 9, filenameBegin, filenameEnd);
// extract Content-Type parameter
CharChunksIterator contentTypeBegin, contentTypeEnd;
if (extractParameter(FSTR("Content-Type:"), filenameEnd, &keyBegin, &contentTypeBegin, &contentTypeEnd)) {
// add "Content-Type" to form fields
formfields->add(keyBegin, keyBegin + 12, contentTypeBegin, contentTypeEnd);
// create file
file.create(APtr<char>(t_strdup(filenameBegin, filenameEnd)).get(),
APtr<char>(t_strdup(contentTypeBegin, contentTypeEnd)).get());
state = GettingFile;
} else {
// missing content-type, cannot get as file!
state = GettingValue;
}
} else {
//// this is a normal field
valueStorage = chunksFactory.add();
state = GettingValue;
}
substate = 0;
}
} else {
// add to headers buffer
headers->append(c, HEADERS_CHUNK_SIZE);
substate = 0;
}
}
开发者ID:venugopalsomu,项目名称:ESPWebFramework,代码行数:53,代码来源:fdvnetwork.cpp
示例18: test_sine_440_hz
static int test_sine_440_hz(struct harness_t *harness_p)
{
#if !defined(SKIP_TEST_SINE_440_HZ)
int i;
float sample;
int samples_per_second = (membersof(dac_gen_sine) * 440);
struct dac_driver_t dac;
int total_number_of_samples;
BTASSERT(dac_init(&dac,
&dac_0_dev,
&pin_0_dev,
NULL,
samples_per_second) == 0);
/* Samples are in the range -1.0 to 1.0. Convert them to the range
0 to AMPLITUDE_MAX. */
for (i = 0; i < membersof(samples); i++) {
sample = dac_gen_sine[i % membersof(dac_gen_sine)];
samples[i] = AMPLITUDE_MAX * ((sample + 1.0) / 2.0);
}
std_printf(FSTR("Converting %d samples.\r\n"), (int)membersof(samples));
BTASSERT(dac_convert(&dac, (uint32_t *)samples, membersof(samples) / 2) == 0);
/* Converting the signal on the DAC0-pin for 5 seconds. */
total_number_of_samples = (5 * samples_per_second);
std_printf(FSTR("Converting %d samples.\r\n"),
total_number_of_samples);
for (i = 0; i < total_number_of_samples; i += membersof(samples)) {
BTASSERT(dac_async_convert(&dac,
(uint32_t *)samples,
membersof(samples) / 2) == 0);
std_printf(FSTR("Samples left = %d\r\n"), total_number_of_samples - i);
}
std_printf(FSTR("Waiting for last samples to be converted\r\n"));
BTASSERT(dac_async_wait(&dac) == 0);
return (0);
#else
(void)dac_gen_sine;
return (1);
#endif
}
开发者ID:wuwx,项目名称:simba,代码行数:52,代码来源:main.c
示例19: settings_module_init
int settings_module_init(void)
{
/* Return immediately if the module is already initialized. */
if (module.initialized == 1) {
return (0);
}
module.initialized = 1;
#if CONFIG_FS_CMD_SETTINGS_LIST == 1
fs_command_init(&module.cmd_list,
FSTR("/oam/settings/list"),
cmd_list_cb,
NULL);
fs_command_register(&module.cmd_list);
#endif
#if CONFIG_FS_CMD_SETTINGS_RESET == 1
fs_command_init(&module.cmd_reset,
FSTR("/oam/settings/reset"),
cmd_reset_cb,
NULL);
fs_command_register(&module.cmd_reset);
#endif
#if CONFIG_FS_CMD_SETTINGS_READ == 1
fs_command_init(&module.cmd_read,
FSTR("/oam/settings/read"),
cmd_read_cb,
NULL);
fs_command_register(&module.cmd_read);
#endif
#if CONFIG_FS_CMD_SETTINGS_WRITE == 1
fs_command_init(&module.cmd_write,
FSTR("/oam/settings/write"),
cmd_write_cb,
NULL);
fs_command_register(&module.cmd_write);
#endif
return (settings_port_module_init());
}
开发者ID:eerimoq,项目名称:simba,代码行数:51,代码来源:settings.c
示例20: test_create_multiple_files
static int test_create_multiple_files(struct harness_t *harness_p)
{
struct fat16_file_t file;
char filename[32];
int i;
for (i = 0; i < 32; i++) {
std_sprintf(filename, FSTR("FILE%d.TXT"), i);
std_printf(FSTR("Creating file with name '%s'.\r\n"), filename);
BTASSERT(fat16_file_open(&fs, &file, filename, O_CREAT | O_WRITE) == 0);
BTASSERT(fat16_file_close(&file) == 0);
}
return (0);
}
开发者ID:eerimoq,项目名称:simba,代码行数:15,代码来源:main.c
注:本文中的FSTR函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论