本文整理汇总了C++中send_string函数的典型用法代码示例。如果您正苦于以下问题:C++ send_string函数的具体用法?C++ send_string怎么用?C++ send_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cgc_send_message
void cgc_send_message(message_t *m)
{
char buf[100];
cgc_sprintf(buf, "%08d - %s\n", m->id, m->topic);
send_string(buf);
send_string(m->body);
}
示例2: set_event
void set_event(uint8_t event_number)
{
uint8_t which_pin = events[event_number].pin;
actual_events[which_pin] = event_number;
switch(which_pin)
{
case EXP0_PC2:
case EXP1_PD4:
case EXP2_PD7:
case EXP3_PB0:
set_pin(which_pin, events[event_number].pin_state);
break;
case PWM0_PD6:
case PWM1_PD5:
// not implemented yet case PWM2_PB1:
// not implemented yet case PWM3_PD3:
run_pwm(which_pin, &events[event_number]);
break;
default:break;
}
int32_t time = current_time();
// event_time
char formatted_date[30];
timeToString(time, formatted_date);
send_string(formatted_date);
send_string(" ");
print_event(event_number);
}
示例3: openvpn_plugin_func_v1
OPENVPN_EXPORT int
openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle, const int type, const char *argv[], const char *envp[])
{
struct auth_pam_context *context = (struct auth_pam_context *) handle;
if (type == OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY && context->foreground_fd >= 0)
{
/* get username/password from envp string array */
const char *username = get_env ("username", envp);
const char *password = get_env ("password", envp);
if (username && strlen (username) > 0 && password)
{
if (send_control (context->foreground_fd, COMMAND_VERIFY) == -1
|| send_string (context->foreground_fd, username) == -1
|| send_string (context->foreground_fd, password) == -1)
{
fprintf (stderr, "AUTH-PAM: Error sending auth info to background process\n");
}
else
{
const int status = recv_control (context->foreground_fd);
if (status == RESPONSE_VERIFY_SUCCEEDED)
return OPENVPN_PLUGIN_FUNC_SUCCESS;
if (status == -1)
fprintf (stderr, "AUTH-PAM: Error receiving auth confirmation from background process\n");
}
}
}
return OPENVPN_PLUGIN_FUNC_ERROR;
}
示例4: atlsci_led
atlsci_led_ret_t atlsci_led(int sensor_type, int action)
{
char * led_on = "L,1"; //Turn on LEDs
char * led_off = "L,0"; //Turn off LEDs
char * led_query = "L,?"; //Query LEDs
uint8_t rx_buffer[STRING_SIZE] = {0};
int ret = set_sensor_address(i2c_context, sensor_type);
switch (action)
{
case ATLSCI_LED_ON: ret = send_string(i2c_context, led_on); break;
case ATLSCI_LED_OFF: ret = send_string(i2c_context, led_off); break;
case ATLSCI_LED_QUERY: ret = send_string(i2c_context, led_query); break;
default: ret = -1; break;
}
if (ret == MRAA_SUCCESS)
{
ret = mraa_i2c_read(i2c_context, rx_buffer, sizeof(rx_buffer));
if(action == ATLSCI_LED_QUERY)
printf("%s\n", rx_buffer);
return parse_atlsci_led(rx_buffer, action);
}
log_mraa_response("atlsci_led()", ret);
return parse_atlsci_led(rx_buffer, action);
}
示例5: main
int main(void)
{
/* Setup IO */
DDRD = (1 << DDD5) | (1 << DDD6) | (1 << DDD7);
DDRB = (1 << DDB0);
PORTC = (1 << PC2) | (1 << PC3) | (1 << PC4) | (1 << PC5);
PCMSK1 = (1 << PCINT10) | (1 << PCINT11) | (1 << PCINT12) | (1 << PCINT13);
UBRR0H = 0;
UBRR0L = 103;
UCSR0B = (1 << TXEN0);
send_string("Hello\n");
/* Duplicate */
for (;;)
{
send_string("Cloning\n");
clone(C, 2, B, 0);
clone(C, 3, D, 7);
clone(C, 4, D, 6);
clone(C, 5, D, 5);
send_string("Sleeping\n");
PCICR |= (1 << PCIE1);
intsleep(PWR_DOWN);
PCICR &= ~(1 << PCIE1);
send_string("Woke up\n");
}
}
示例6: main
int main(void)
{
int i;
/* Init the Display */
lcd_init(2);
/* Clear the screen */
lcd_putc('\f');
/* Send the message */
send_string(5, INITMESSAGE);
while (1)
{
/* Display on the first line after button press */
while(lcd.button == 1)
{ }
lcd_putc('\f');
send_string(1000, MESSAGE1);
while(lcd.button == 1)
{ }
lcd_putc('\f');
/* New line */
lcd_putc('\n');
send_string(5, MESSAGE2);
/* Add delay for button debouncing */
delay_ms(500);
}
return 0;
}
示例7: atlsci_temp_comp
/*
* Temperature compensation is only enable for pH, DO, and Conductivity sensor.
* ORP does not have this feature. The value that it takes is expressed in float value nn.n
*/
atlsci_temp_comp_ret_t atlsci_temp_comp(int sensor_type, atlsci_temp_comp_param param, float value)
{
atlsci_temp_comp_ret_t ret;
uint8_t rx_buffer[STRING_SIZE] = {0};
char cal_temp[TEMP_COMP_SIZE] = "T,";
int success = set_sensor_address(i2c_context, sensor_type);
char *pt_cal = cal_temp;
switch(param)
{
case SET_TEMPERATURE: sprintf(pt_cal + TEMP_COMP_INDEX, "%.1f", value);
success = send_string(i2c_context, cal_temp); break;
case QUERY_TEMPERATURE: success = send_string (i2c_context, cal_query); break;
default: return atlsci_temp_comp_fail(param);
}
if (success == MRAA_SUCCESS)
{
success = mraa_i2c_read(i2c_context, rx_buffer, sizeof(rx_buffer));
if(param == QUERY_TEMPERATURE)
printf("%s\n", rx_buffer);
//First bit of rx_buffer will be '1' if write is successful
ret.success = (int)rx_buffer[0];
}
else
{
log_mraa_response("atlsci_temp_comp()", success);
ret.success = -1;
}
return ret;
}
示例8: main
int main(void)
{
struct DataPackage* pkg;
uint8_t i;
uint8_t buffer[20];
rfm_init(RX_MODE);
init_uart();
DDRD &= ~(1<<PD2);
PORTD |= 1<<PD2;
while(1)
{
pkg = receivePackageBlocking();
if(pkg->pkgSize > 0)
{
send_string("RICHTIG\r\n");
/* for(i=0; i<pkg->pkgSize-DATA_PKG_HEAD_SIZE; i++)
{
itoa(pkg->pkgData[i], (char*)buffer, 16);
send_string(buffer);
send_string("\r\n");
}*/
}
else
{
send_string("FALSCH\r\n");
}
deleteDataPackage(pkg);
}
}
示例9: main
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // stop watchdog timer
lcd_init();
send_string("Manpreet Singh");
send_command(0xC0);
send_string("Minhas");
while(1){}
}
示例10: main
int main (int argc, char *argv[])
{
optarg = (char *)malloc(100*sizeof(char));
//fill optarg with the path to the serial transmitter
find_serial_transmitter();
FILE *log_file;
char buf[1000];
char *str_array[140]={"\0"};
int i=0;
//Open the FM stations log file that will become the device database
log_file = fopen("log.txt","r");
if (!log_file){
printf("ERROR: Could not open FM Stations log file for reading.\n");
return -1;
}
//create a connection over the virtual serial port
open_port();
//send the start sequence
perror("START SEQUENCE:\n");
send_string("$$$");
printf("\n\n");
//wait a while to make sure the device has detected the start sequence and is ready for data
usleep(5000000);
//parse the log file line by line
while (fgets(buf,1000, log_file)!=NULL)
{
//keep track of each line
str_array[i] = buf;
strip_newline( str_array[i], 210);
//prepare, parse, and transmit the data within each line
parse_line(line_prep(str_array[i]));
i++;
}
//close the log file
fclose(log_file);
//make sure the device has had enough time to write all the data before sending end sequence
usleep(4000000);
//send the end sequence
printf("END SEQUENCE:\n");
send_string("^^^");
printf("\n\n");
//terminate the virtual serial port connection
serialport_close(fd);
return 0;
}
示例11: parse_line
int parse_line(char * in_line){
int i = 0;
int initial_length = strlen(in_line);
printf("chars parsed: %d\n", initial_length);
char * token = strtok_single(in_line, " ");
/* walk through other tokens */
//The first call you use a char array which has the elements you want parsed.
//The second time you call it you pass it NULL as the first parameter to tell function
//to resume from the last spot in the string. Once the first call is made your char
//array receives the parsed string. If you don't put NULL you would lose your place
//and effectivly the last part of your string.
if (initial_length > 10){
if (initial_length >= 200){
//grid population
send_byte((uint8_t)*(token));
printf("%s ", token);
while(token){
i++;
token = strtok_single(NULL, " ");
if (i < 100) {
send_byte((uint8_t)*(token));
printf("%s ",token);
}
usleep(200000);
}
printf("\n");
}
else{
//Station line
//printf("callsign:%s\n", token);
send_string(token);
if (strlen(token) < 8)
{
int k=0;
for (k=0; k< 8-strlen(token); k++)
{
send_string(" ");
}
}
while(token){
i++;
token = strtok_single(NULL, " ");
if (i < 6) send_float(token);
//if (i < 6) printf("float:%s ",token);
usleep(200000);
}
}
}
else{
send_float(token);
//printf("num_stations: %s\n",token);
}
printf("\n");
return 0;
}
示例12: stdin
/*
handle_response -- accept a response from stdin (the gnu process) and pass the
information on to the relevant client.
*/
static void
handle_response (void)
{
char buf[GSERV_BUFSZ+1];
int offset=0;
int s;
int len = 0;
int result_len;
/* read in "n/m:" (n=client fd, m=message length) */
while (offset < GSERV_BUFSZ &&
((len = read(0,buf+offset,1)) > 0) &&
buf[offset] != ':') {
offset += len;
}
if (len < 0) {
perror(progname);
fprintf(stderr,"%s: unable to read\n",progname);
exit(1);
}
/* parse the response from emacs, getting client fd & result length */
buf[offset] = '\0';
sscanf(buf,"%d/%d", &s, &result_len);
while (result_len > 0) {
if ((len = read(0,buf,min2(result_len,GSERV_BUFSZ))) < 0) {
perror(progname);
fprintf(stderr,"%s: unable to read\n",progname);
exit(1);
}
buf[len] = '\0';
send_string(s,buf);
result_len -= len;
}
/* eat the newline */
while ((len = read(0,buf,1)) == 0)
;
if (len < 0)
{
perror(progname);
fprintf(stderr,"%s: unable to read\n",progname);
exit(1);
}
if (buf[0] != '\n')
{
fprintf(stderr,"%s: garbage after result\n",progname);
exit(1);
}
/* send the newline */
buf[1] = '\0';
send_string(s,buf);
close(s);
} /* handle_response */
示例13: docmd
static void docmd(char **cmd)
{
int i;
if (cmd[0] == NULL) {
help();
return;
}
if (cmd[1] && cmd[2]) {
printf("%s\n", lang_toolong);
help();
return;
}
if (strcmp(cmd[0], lang_look[0]) == 0
|| strcmp(cmd[0], lang_look[1]) == 0) {
send_string("descr\r\n");
return;
}
if (strcmp(cmd[0], lang_inv[0]) == 0
|| strcmp(cmd[0], lang_inv[1]) == 0) {
send_string("inv\r\n");
return;
}
if (strcmp(cmd[0], lang_get) == 0) {
call_with_arg(get, cmd[1], lang_getdrop_explain, lang_get);
return;
}
if (strcmp(cmd[0], lang_drop) == 0) {
call_with_arg(drop, cmd[1], lang_getdrop_explain, lang_drop);
return;
}
if (strcmp(cmd[0], lang_poke) == 0) {
if (cmd[1] && cmd[1][0] == '-')
cmd[1]++;
call_with_arg(poke, cmd[1], lang_poke_explain, lang_poke);
return;
}
for (i = 0; i < 6; i++) {
if (strcmp(cmd[0], lang_directions[i][0]) == 0
|| strcmp(cmd[0], lang_directions[i][1]) == 0) {
go(i);
return;
}
}
/* accept standard command "l" in any language, unless it is assigned
* another meaning */
if (strcmp(cmd[0], "l") == 0) {
send_string("descr\r\n");
return;
}
printf("%s\n", lang_huh);
help();
}
示例14: run_task
void run_task(uint8_t *Task)
{
switch(Task[2])
{
case '0':
send_string("boot");
break;
case '1':
page_address = Task[9] << 8;
page_address |= Task[8];
readFlashPage(page_address, 128);
send_buff(gBuffer, 128);
Task[2] = 0;
break;
case '2':
Task[2] = 0;
break;
case '3':
page_address = Task[9] << 8;
page_address |= Task[8];
for (uint16_t i = 0; i < SPM_PAGESIZE; i++)
gBuffer[i] = data_buffer[i + 16];
writeFlashPage(page_address,SPM_PAGESIZE);
send_string("page done");
Task[2] = 0;
break;
case '4':
eraseFlash();
send_string("erase ok");
Task[2] = 0;
break;
case '5':
Task[2] = 0;
break;
case '6':
fill_page();
send_buff(gBuffer, 256);
Task[2] = 0;
break;
case '7':
blink_led();
Task[2] = 0;
break;
case '8':
MCUCR |= 1<<IVCE;
MCUCR = 0<<IVSEL;
send_string("jump ok");
jump_to_app(); // Jump to application sector
Task[2] = 0;
break;
default:
Task[2] = 0;
}
}
示例15: service_request
Service* service_request (string service_name) {
int socket;
Service_description* s_description = NULL;
if (service_name == "" ||
!socket_initialization_client (&socket, SR_address, SR_port)) return NULL;
if (send_string (socket, "get_service") &&
receive_int (socket) != -1 &&
send_string (socket, service_name)) s_description = receive_service_description (socket);
close(socket);
return (s_description == NULL) ? NULL : new Service (s_description);
}