本文整理汇总了C++中send_command函数的典型用法代码示例。如果您正苦于以下问题:C++ send_command函数的具体用法?C++ send_command怎么用?C++ send_command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send_command函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
if (argc != 2 || !strlen(argv[1]))
{
fprintf(stderr, "%s [client name]\n", argv[0]);
return 1;
}
if (!set_program_name(argv[0]) || !initialize_client())
{
fprintf(stderr, "%s: could not initialize client\n", argv[0]);
client_cleanup();
return 1;
}
load_internal_plugins();
if (!start_message_queue())
{
fprintf(stderr, "%s: could not start message queue\n", argv[0]);
client_cleanup();
return 1;
}
if (!register_resource_client(NULL))
{
fprintf(stderr, "%s: could not register client\n", argv[0]);
stop_message_queue();
client_cleanup();
return 1;
}
command_handle new_service = register_service(argv[1], PARAM_ECHO_TYPE);
command_reference service_status = 0;
if ( !new_service || !(service_status = send_command(new_service)) ||
!(wait_command_event(service_status, event_complete, local_default_timeout()) & event_complete) )
{
fprintf(stderr, "%s: could not register service\n", argv[0]);
if (new_service) destroy_command(new_service);
if (service_status) clear_command_status(service_status);
stop_message_queue();
client_cleanup();
return 1;
}
destroy_command(new_service);
clear_command_status(service_status);
set_log_client_name(argv[1]);
if (!stop_message_queue())
{
client_cleanup();
return 1;
}
set_queue_event_hook(&message_queue_hook);
result outcome = inline_message_queue();
client_cleanup();
return outcome? 0 : 1;
}
示例2: send_command
void
PrimeSession::modify_cursor_left_edge (void)
{
send_command (PRIME_MODIFY_CURSOR_LEFT_EDGE);
}
示例3: radio_change_state
// change radio state, e.g. from receive to ready
void radio_change_state(uint8_t next_state)
{
radio_buffer.data[0] = next_state;
send_command(CMD_CHANGE_STATE, radio_buffer.data, 1, 0);
}
示例4: radio_fifo_info
// retrieve radio FIFO information
void radio_fifo_info(uint8_t reset_fifo)
{
radio_buffer.data[0] = reset_fifo;
send_command(CMD_FIFO_INFO, radio_buffer.data, 1, sizeof(radio_buffer.fifo_info));
}
示例5: radio_get_modem_status
// retrieve radio modem status information
void radio_get_modem_status(uint8_t clr_pending)
{
radio_buffer.data[0] = clr_pending;
send_command(CMD_GET_MODEM_STATUS, radio_buffer.data, 1, sizeof(radio_buffer.modem_status));
}
示例6: test_xml
void
test_xml(void)
{
assert_send_command("table_create Users TABLE_HASH_KEY ShortText");
assert_send_command("column_create Users age COLUMN_SCALAR UInt32");
assert_send_command("column_create Users comment COLUMN_SCALAR Text");
cut_assert_equal_string(
cut_take_printf("<COLUMN_LIST>\n"
"<HEADER>\n"
"<PROPERTY>\n"
"<TEXT>id</TEXT>\n"
"<TEXT>UInt32</TEXT></PROPERTY>\n"
"<PROPERTY>\n"
"<TEXT>name</TEXT>\n"
"<TEXT>ShortText</TEXT></PROPERTY>\n"
"<PROPERTY>\n"
"<TEXT>path</TEXT>\n"
"<TEXT>ShortText</TEXT></PROPERTY>\n"
"<PROPERTY>\n"
"<TEXT>type</TEXT>\n"
"<TEXT>ShortText</TEXT></PROPERTY>\n"
"<PROPERTY>\n"
"<TEXT>flags</TEXT>\n"
"<TEXT>ShortText</TEXT></PROPERTY>\n"
"<PROPERTY>\n"
"<TEXT>domain</TEXT>\n"
"<TEXT>ShortText</TEXT></PROPERTY>\n"
"<PROPERTY>\n"
"<TEXT>range</TEXT>\n"
"<TEXT>ShortText</TEXT></PROPERTY>\n"
"<PROPERTY>\n"
"<TEXT>source</TEXT>\n"
"<TEXT>ShortText</TEXT></PROPERTY></HEADER>\n"
"<COLUMN>\n"
"<INT>%u</INT>\n"
"<TEXT>_key</TEXT>\n"
"<TEXT></TEXT>\n"
"<TEXT></TEXT>\n"
"<TEXT>COLUMN_SCALAR</TEXT>\n"
"<TEXT>Users</TEXT>\n"
"<TEXT>ShortText</TEXT>\n"
"<SOURCES></SOURCES></COLUMN>\n"
"<COLUMN>\n"
"<INT>%u</INT>\n"
"<TEXT>comment</TEXT>\n"
"<TEXT>%s.0000102</TEXT>\n"
"<TEXT>var</TEXT>\n"
"<TEXT>COLUMN_SCALAR|PERSISTENT</TEXT>\n"
"<TEXT>Users</TEXT>\n"
"<TEXT>Text</TEXT>\n"
"<SOURCES></SOURCES></COLUMN>\n"
"<COLUMN>\n"
"<INT>%u</INT>\n"
"<TEXT>age</TEXT>\n"
"<TEXT>%s.0000101</TEXT>\n"
"<TEXT>fix</TEXT>\n"
"<TEXT>COLUMN_SCALAR|PERSISTENT</TEXT>\n"
"<TEXT>Users</TEXT>\n"
"<TEXT>UInt32</TEXT>\n"
"<SOURCES></SOURCES></COLUMN></COLUMN_LIST>",
grn_obj_id(context, get("Users")),
grn_obj_id(context, get("Users.comment")), database_path,
grn_obj_id(context, get("Users.age")), database_path),
send_command("column_list Users --output_type xml"));
}
示例7: process_events
static void process_events(PluginData* data, PDReader* reader, PDWriter* writer) {
uint32_t event;
while ((event = PDRead_get_event(reader))) {
switch (event) {
//case PDEventType_getExceptionLocation : setExceptionLocation(plugin, writer); break;
//case PDEventType_getCallstack : set_callstack(plugin, writer); break;
case PDEventType_GetRegisters:
{
get_registers(data);
break;
}
case PDEventType_GetCallstack:
{
if (should_send_command(data))
set_callstack(data, reader, writer);
break;
}
case PDEventType_GetDisassembly:
{
if (should_send_command(data))
get_disassembly(data, reader, writer);
break;
}
case PDEventType_GetMemory:
{
if (should_send_command(data))
get_memory(data, reader, writer);
break;
}
case PDEventType_MenuEvent:
{
on_menu(data, reader);
break;
}
case PDEventType_SetBreakpoint:
{
set_breakpoint(data, reader, writer);
// if we add a breakpoint to VICE it will always stop but if we are already running when
// adding the breakpoint we just force VICE to run again
if (data->state == PDDebugState_Running)
send_command(data, "ret\n");
break;
}
case PDEventType_DeleteBreakpoint:
{
del_breakpoint(data, reader, writer);
break;
}
case PDEventType_SetExecutable:
{
//if (should_send_command(data))
set_executable(data, reader);
break;
}
}
}
}
示例8: gdbr_write_registers
int gdbr_write_registers(libgdbr_t* g, char* registers) {
// read current register set
gdbr_read_registers(g);
unsigned int x, len = strlen(registers);
char* buff = calloc(len, sizeof(char));
if (!buff)
return -1;
memcpy(buff, registers, len);
char* reg = strtok(buff, ",");
while ( reg != NULL ) {
char* name_end = strchr(reg, '=');
if (name_end == NULL) {
printf("Malformed argument: %s\n", reg);
free(buff);
return -1;
}
*name_end = '\0'; // change '=' to '\0'
// time to find the current register
int i = 0;
while ( g->registers[i].size > 0) {
if (strcmp(g->registers[i].name, reg) == 0) {
const uint64_t register_size = g->registers[i].size;
const uint64_t offset = g->registers[i].offset;
char* value = malloc (register_size * 2);
if (!value) {
free (buff);
return -1;
}
memset (value, '0', register_size * 2);
name_end++;
// be able to take hex with and without 0x
if (name_end[1] == 'x' || name_end[1] == 'X') name_end += 2;
const int val_len = strlen (name_end); // size of the rest
strcpy (value+(register_size * 2 - val_len), name_end);
for (x=0; x < register_size; x++) {
g->data[offset + register_size - x - 1] = hex2char(&value[x * 2]);
}
free(value);
}
i++;
}
reg = strtok(NULL, " ,");
}
free(buff);
uint64_t buffer_size = g->data_len * 2 + 8;
int ret;
char* command = calloc(buffer_size, sizeof(char));
if (!command)
return -1;
snprintf (command, buffer_size, "%s", CMD_WRITEREGS);
pack_hex (g->data, g->data_len, command+1);
ret = send_command (g, command);
if (ret < 0) {
free (command);
return ret;
}
read_packet (g);
free (command);
handle_G (g);
return 0;
}
示例9: main
int main(int argc, char **argv)
{
/* local client data */
int sockfd; /* file descriptor for endpoint */
struct sockaddr_in client_sockaddr; /* address/port pair */
struct in_addr client_addr; /* network-format address */
char client_dotted[INET_ADDRSTRLEN];/* human-readable address */
int client_port; /* local port */
/* remote server data */
char *server_dotted; /* human-readable address */
int server_port; /* remote port */
/* the request */
char *filename; /* filename to request */
/* read arguments */
if (argc != 5) {
fprintf(stderr, "client: wrong number of arguments\n");
client_usage();
exit(1);
}
server_dotted = argv[1];
server_port = atoi(argv[2]);
client_port = atoi(argv[3]);
filename = argv[4];
if (!client_arguments_valid(
server_dotted, server_port,
client_port, filename)) {
client_usage();
exit(1);
}
/* get the primary IP address of this host */
get_primary_addr(&client_addr);
inet_ntop(AF_INET, &client_addr, client_dotted, INET_ADDRSTRLEN);
/* construct an endpoint address with primary address and desired port */
memset(&client_sockaddr, 0, sizeof(client_sockaddr));
client_sockaddr.sin_family = PF_INET;
memcpy(&client_sockaddr.sin_addr,&client_addr,sizeof(struct in_addr));
client_sockaddr.sin_port = htons(client_port);
/* make a socket*/
sockfd = socket(PF_INET, SOCK_DGRAM, 0);
if (sockfd<0) {
perror("can't open socket");
exit(1);
}
/* bind it to an appropriate local address and port */
if (bind(sockfd, (struct sockaddr *) &client_sockaddr,
sizeof(client_sockaddr))<0) {
perror("can't bind local address");
exit(1);
}
fprintf(stderr, "client: Receiving on %s, port %d\n",
client_dotted, client_port);
/* send a command */
send_command(sockfd, server_dotted, server_port, filename, 0, MAXINT);
fprintf(stderr, "client: requesting %s blocks %d-%d\n",
filename, 0, MAXINT);
/* receive the whole document and make naive assumptions */
int done = FALSE; // set to TRUE when you think you're done
int init = TRUE;
/* create a bit array to test which blocks have been received */
struct bits blocksRecv;
/* open a file to write to in the current directory */
FILE *download = fopen(filename, "w");
fclose(download);
int outfd = open(filename, O_RDWR);
while (!done) {
int retval;
again:
if ((retval = select_block(sockfd, 0, 20000))==0) {
/* timeout */
struct range nBlocks[12];
int currentRange = 0;
int i;
int check = 0;
int numBlocks = blocksRecv.nbits;
for(i = 0; i < numBlocks; i++){
/* look for the start of a missed block */
if(check == 0 && bits_testbit(&blocksRecv, i)){
nBlocks[currentRange].first_block = i;
nBlocks[currentRange].last_block = numBlocks-1;
check++;
}
/* look for the end of a missed block */
else if(check == 1 && !(bits_testbit(&blocksRecv, i))){
nBlocks[currentRange].last_block = i-1;
//.........这里部分代码省略.........
示例10: dus3000_read
static int dus3000_read(struct tslib_module_info *m, struct ts_sample *samples, int maxSamples)
{
struct tslib_dus3000 *const d = (struct tslib_dus3000 *)m;
const int fd = m->dev->fd;
int i = 0;
for (i = 0; i < maxSamples; ) {
// - Read until we have at least four bytes, which is <= minimum reply length and also
// sufficient to determine the final length of all kinds of replies
// then... code:
if (!read_to_pos(fd, d, 4)) {
break;
}
if (d->rxPosition >= 4) {
if (d->rxBuffer[0] == 0x01) {
if (!read_to_pos(fd, d, 6)) {
break;
}
// read finger up / down and coordinates
samples[i].pressure = d->rxBuffer[1] ? 255 : 0;
samples[i].x = ((int)d->rxBuffer[2]) | (((int)d->rxBuffer[3]) << 8);
samples[i].y = ((int)d->rxBuffer[4]) | (((int)d->rxBuffer[5]) << 8);
i++;
d->rxPosition = 0; // message complete
} else if (d->rxBuffer[0] == 0x02 && d->rxBuffer[1] == 0x4c) {
const ssize_t fullRequiredLength = 3 + d->rxBuffer[2];
if (!read_to_pos(fd, d, fullRequiredLength)) {
break;
}
d->rxPosition = 0; // message complete
switch (d->rxBuffer[3]) {
case tr_id_vers_info: // "acquisition of version information" response
// get rest of message. length is stored in m_RxBuf[2]
#ifdef DEBUG
d->rxBuffer[fullRequiredLength] = '\0';
fprintf(stderr, "Version information: %s\n", d->rxBuffer + 3);
#endif
break;
case tr_id_firmw_info: // "firmware detailed information" response
#ifdef DEBUG
d->rxBuffer[fullRequiredLength] = '\0';
fprintf(stderr, "Firmware information: %s\n", d->rxBuffer);
#endif
break;
case tr_id_adj_offset: // "adjust offset" response
if (d->state == AdjustOffset && d->rxBuffer[4] != 0) {
#ifdef DEBUG
fprintf(stderr, "Adjust offset succeeded!\n");
#endif
} else {
// abort calibration if command transmission failed
continue;
}
if (!send_command(fd, tm_calibrate_offset)) {
fprintf(stderr,
"Calibrate offset command transmission failed!\n");
continue;
}
d->state = CalibrateOffset;
break;
case tr_id_cal_offset: // "calibrate offset" response
if (d->state == CalibrateOffset && d->rxBuffer[4] != 0) {
#ifdef DEBUG
fprintf(stderr, "Calibrate offset succeeded!\n");
#endif
} else {
// abort calibration if command transmission failed
fprintf(stderr, "Calibrate offset failed!\n");
continue;
}
// calibration done, restart coordinate transmission
if (!send_command(fd, tm_coordinates_on)) {
fprintf(stderr,
"Enable coordinates command transmission failed!\n");
continue;
}
d->state = Coordinates;
#ifdef DEBUG
fprintf(stderr, "Calibration finished!\n");
#endif
break;
} // switch
} else {
fprintf(stderr,
"DUS3000: unknown response 0x %02x %02x %02x %02x - resynchronizing!\n",
d->rxBuffer[0], d->rxBuffer[1], d->rxBuffer[2], d->rxBuffer[3]);
// stop coordinate transmission, flush buffers, and re-enable
send_command(fd, tm_coordinates_off);
usleep (50000); // let all pending data arrive in our buffer
tcflush(fd, TCIOFLUSH); // clear buffers
d->rxPosition = 0;
//.........这里部分代码省略.........
示例11: send_write_command
void send_write_command(unsigned char *command, int command_length)
{
send_command(command, command_length);
}
示例12: send_read_command
void send_read_command(unsigned char command)
{
send_command(&command, 1);
}
示例13: radio_part_info
// retrieve radio device information (e.g. chip model)
void radio_part_info(void)
{
send_command(CMD_PART_INFO, 0, 0, sizeof(radio_buffer.part_info));
}
示例14: launch_vice_with_config
static void launch_vice_with_config(PluginData* data) {
int r, cmdIndex = 1;
uv_process_options_t options = { 0 };
log_debug("spawning vice...\n", "");
char* args[10];
args[0] = (char*)data->config.vice_exe;
// TODO: Must generate the breakpoint file from the json one
args[cmdIndex++] = "-remotemonitor";
if (data->config.breakpoint_file) {
//args[cmdIndex++] = "-moncommands";
//args[cmdIndex++] = "examples/c64_vice/test_mon.txt";
}
//args[cmdIndex++] = (char*)data->config.prg_file;
args[cmdIndex++] = NULL;
options.exit_cb = 0;
options.file = data->config.vice_exe;
options.args = args;
if ((r = uv_spawn(uv_default_loop(), &data->process, &options))) {
MESSAGE_FUNCS->error("Unable to launch VICE", uv_strerror(r));
return;
}
sleepMs(3000);
connect_to_local_host(data);
// if connected we load the image and make sure we get a reply back
if (VICEConnection_isConnected(data->conn)) {
log_debug("connected to vice...\n", "");
if (!load_image(data, data->config.prg_file)) {
return;
}
log_debug("image loaded ...\n", "");
// parse the
parse_mon_file(data, data->config.breakpoint_file);
log_debug("start from basic...\n", "");
// start vice!
log_debug("started from basic\n", "");
uint16_t address = 0; //get_basic_start(data);
parse_mon_file(data, data->config.breakpoint_file);
if (address != 0) {
log_debug("start from %x\n", address);
send_command(data, "g %x\n", address);
}
return;
}
log_debug("unable to make connection with vice\n", "");
}
示例15: radio_func_info
// retrieve radio function revision information
void radio_func_info(void)
{
send_command(CMD_FUNC_INFO, 0, 0, sizeof(radio_buffer.func_info));
}