• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ send_message函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中send_message函数的典型用法代码示例。如果您正苦于以下问题:C++ send_message函数的具体用法?C++ send_message怎么用?C++ send_message使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了send_message函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char** argv) {
#ifndef _USING_FCGI_
    FILE* fin, *fout;
#else
    FCGI_FILE *fin, *fout;
#endif
    int i, retval;
    char req_path[MAXPATHLEN], reply_path[MAXPATHLEN];
    char log_path[MAXPATHLEN], path[MAXPATHLEN];
    unsigned int counter=0;
    char* code_sign_key;
    int length = -1;
    log_messages.pid = getpid();
    bool debug_log = false;

    for (i=1; i<argc; i++) {
        if (!strcmp(argv[i], "--batch")) {
            batch = true;
            continue;
        } else if (!strcmp(argv[i], "--mark_jobs_done")) {
            mark_jobs_done = true;
        } else if (!strcmp(argv[i], "--debug_log")) {
            debug_log = true;
#ifdef GCL_SIMULATOR
        } else if (!strcmp(argv[i], "--simulator")) {
            if(!argv[++i]) {
                log_messages.printf(MSG_CRITICAL, "%s requires an argument\n\n", argv[--i]);
                usage(argv[0]);
                exit(1);
            }
            simtime = atof(argv[i]);
#endif
        } else if(!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
            usage(argv[0]);
            exit(0);
        } else if(!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
            printf("%s\n", SVN_VERSION);
            exit(0);
        } else if (strlen(argv[i])) {
            log_messages.printf(MSG_CRITICAL, "unknown command line argument: %s\n\n", argv[i]);
            usage(argv[0]);
            exit(1);
        }
    }

    // install a signal handler that catches SIGTERMS sent by Apache if the CGI
    // times out.
    //
    signal(SIGTERM, sigterm_handler);

    if (debug_log) {
        if (!freopen("debug_log", "w", stderr)) {
            fprintf(stderr, "Can't redirect stderr\n");
            exit(1);
        }
    } else {
        char *stderr_buffer;
        get_log_path(path, "scheduler.log");
#ifndef _USING_FCGI_
        char buf[256];
        if (!freopen(path, "a", stderr)) {
            fprintf(stderr, "Can't redirect stderr\n");
            sprintf(buf, "Server can't open log file (%s)", path);
            send_message(buf, 3600);
            exit(1);
        }
#else
        FCGI_FILE* f = FCGI::fopen(path, "a");
        if (f) {
            log_messages.redirect(f);
        } else {
            char buf[256];
            fprintf(stderr, "Can't redirect FCGI log messages\n");
            sprintf(buf, "Server can't open log file for FCGI (%s)", path);
            send_message(buf, 3600);
            exit(1);
        }
#endif
        // install a larger buffer for stderr.  This ensures that
        // log information from different scheduler requests running
        // in parallel aren't intermingled in the log file.
        //
        if (config.scheduler_log_buffer) {
            stderr_buffer = (char*)malloc(config.scheduler_log_buffer);
            if (!stderr_buffer) {
                log_messages.printf(MSG_CRITICAL,
                                    "Unable to allocate stderr buffer\n"
                                   );
            } else {
#ifdef _USING_FCGI_
                retval = setvbuf(
                             f->stdio_stream, stderr_buffer, _IOFBF,
                             config.scheduler_log_buffer
                         );
#else
                retval = setvbuf(
                             stderr, stderr_buffer, _IOFBF, config.scheduler_log_buffer
                         );
#endif
                if (retval) {
//.........这里部分代码省略.........
开发者ID:zonca,项目名称:boinc,代码行数:101,代码来源:sched_main.cpp


示例2: switch


//.........这里部分代码省略.........
                }
                break;
            }

            case MAV_CMD_DO_START_MAG_CAL:
            case MAV_CMD_DO_ACCEPT_MAG_CAL:
            case MAV_CMD_DO_CANCEL_MAG_CAL:
                result = tracker.compass.handle_mag_cal_command(packet);
                break;

            default:
                break;
        }
        mavlink_msg_command_ack_send(
            chan,
            packet.command,
            result);
        
        break;
    }
         
    // When mavproxy 'wp sethome' 
    case MAVLINK_MSG_ID_MISSION_WRITE_PARTIAL_LIST:
    {
        // decode
        mavlink_mission_write_partial_list_t packet;
        mavlink_msg_mission_write_partial_list_decode(msg, &packet);
        if (packet.start_index == 0)
        {
            // New home at wp index 0. Ask for it
            waypoint_receiving = true;
            waypoint_request_i = 0;
            waypoint_request_last = 0;
            send_message(MSG_NEXT_WAYPOINT);
            waypoint_receiving = true;
        }
        break;
    }

    // XXX receive a WP from GCS and store in EEPROM if it is HOME
    case MAVLINK_MSG_ID_MISSION_ITEM:
    {
        // decode
        mavlink_mission_item_t packet;
        uint8_t result = MAV_MISSION_ACCEPTED;

        mavlink_msg_mission_item_decode(msg, &packet);

        struct Location tell_command = {};

        switch (packet.frame)
        {
        case MAV_FRAME_MISSION:
        case MAV_FRAME_GLOBAL:
        {
            tell_command.lat = 1.0e7f*packet.x;                                     // in as DD converted to * t7
            tell_command.lng = 1.0e7f*packet.y;                                     // in as DD converted to * t7
            tell_command.alt = packet.z*1.0e2f;                                     // in as m converted to cm
            tell_command.options = 0;                                     // absolute altitude
            break;
        }

#ifdef MAV_FRAME_LOCAL_NED
        case MAV_FRAME_LOCAL_NED:                         // local (relative to home position)
        {
            tell_command.lat = 1.0e7f*ToDeg(packet.x/
开发者ID:StewLG,项目名称:ardupilot,代码行数:67,代码来源:GCS_Mavlink.cpp


示例3: down_click_handler

void down_click_handler(ClickRecognizerRef recognizer, void *context) 
{
     send_message(DOWN);
}
开发者ID:loganisitt,项目名称:Pebblesss-watchapp,代码行数:4,代码来源:main.c


示例4: process_worker_request


//.........这里部分代码省略.........
                buf = malloc((strlen("OK ") + strlen(msg->args) + 1)  * sizeof *buf);
                if (buf == NULL) {
                    status = errno;
                    answer = create_error_message(WORKER, wd->id, WORKER, msg->origin_id, msg->thread_id, ANSWER, OPN, status);
                    break;
                }
                sprintf(buf, "OK %s", msg->args);
                answer = create_message(WORKER, wd->id, WORKER, msg->origin_id, msg->thread_id, ANSWER, OPN, 2, buf);
            }
            break;

        case WRT:
            fn = strtok(msg->args, " ");
            size = strtok(NULL, " ");
            wrt_buf = strtok(NULL, "\0");
            
            status = write_file(wd->lfs, fn, atoi(size), wrt_buf, msg->thread_id);
            if (status < 0) {
                answer = create_error_message(WORKER, wd->id, WORKER, msg->origin_id, msg->thread_id, ANSWER, WRT, status);
            }
            else {
                answer = create_message(WORKER, wd->id, WORKER, msg->origin_id, msg->thread_id, ANSWER, WRT, 1, "OK");
            }
            break;

        case REA:
            fn = strtok(msg->args, " ");
            size = strtok(NULL, " ");
            
            rea_buf = malloc(atoi(size) * sizeof *rea_buf);
            if (rea_buf == NULL) {
                status = errno;
                answer = create_error_message(WORKER, wd->id, WORKER, msg->origin_id, msg->thread_id, ANSWER, REA, status);
                break;
            }
            status = read_file(wd->lfs, fn, atoi(size), rea_buf, msg->thread_id);
            if (status < 0) {
                answer = create_error_message(WORKER, wd->id, WORKER, msg->origin_id, msg->thread_id, ANSWER, REA, status);
                free(rea_buf);
                rea_buf = NULL;
                break;
            }
            else {
                //buf will be "OK read_size read_characters\0"
                buf = malloc((strlen("OK") + strlen(size) + strlen(rea_buf) + 3) * sizeof *buf);
                if (buf == NULL) {
                    status = errno;
                    answer = create_error_message(WORKER, wd->id, WORKER, msg->origin_id, msg->thread_id, ANSWER, REA, status);
                    free(rea_buf);
                    rea_buf = NULL;
                    break;
                }

                sprintf(buf, "OK %d %s", status, rea_buf);
                answer = create_message(WORKER, wd->id, WORKER, msg->origin_id, msg->thread_id, ANSWER, REA, 3, buf);
            }
            free(rea_buf);
            rea_buf = NULL;
            break;

        case CLO:
            status = close_file(wd->lfs, msg->args);
            if (status != 0) {
                answer = create_error_message(WORKER, wd->id, WORKER, msg->origin_id, msg->thread_id, ANSWER, CLO, status);
            } else {
             //We return "OK filename", because the worker who requested the close needs the filename to erase the FD from his data
                buf = malloc((strlen(msg->args) + strlen("OK ") + 1) * sizeof *buf);
                if (buf == NULL) {
                    status = errno;
                    answer = create_error_message(WORKER, wd->id, WORKER, msg->origin_id, msg->thread_id, ANSWER, CLO, status);
                    break;
                }
                sprintf(buf, "OK %s", msg->args);
                answer = create_message(WORKER, wd->id, WORKER, msg->origin_id, msg->thread_id, ANSWER, CLO, 2, buf);
            }

            break;

        case BYE:
            status = close_thread_files(wd->lfs, msg->thread_id);
            if (status != 0) {
                answer = create_error_message(WORKER, wd->id, WORKER, msg->origin_id, msg->thread_id, ANSWER, BYE, status);
            } else {
                answer = create_message(WORKER, wd->id, WORKER, msg->origin_id, msg->thread_id, ANSWER, BYE, 1, "OK");
            }
            break;


        default:
            break;
    }

    send_message(answer);
    delete_message(answer);
    if (buf != NULL) {
        free(buf);
        buf = NULL;
    }
    return 0;
}
开发者ID:facutuesca,项目名称:DistributedFS,代码行数:101,代码来源:worker.c


示例5: sync_meta

static int sync_meta(csiebox_server *server, int conn_fd, csiebox_protocol_meta *meta)/*{{{*/
{
	char full_path[PATH_MAX];
	recv_message(conn_fd, full_path, sizeof(full_path));
	// make a short path
	char *client_path = make_path(full_path);
	char *cur_dir = get_user_homedir(server, server->client[conn_fd]);
	if (chdir(cur_dir) == -1) {
		fprintf(stderr, "change to user directory error\n");
		return 0;
	}
	// start to traverse
	int file_check = 0;
	char *object = strtok(client_path, "/");
	while(object != NULL){
		strcat(cur_dir, "/");
		strcat(cur_dir, object);
		struct stat object_stat;
		memset(&object_stat, 0, sizeof(object_stat));
		int open_success = lstat(cur_dir, &object_stat);
		// if file not exist
		if (open_success == -1){
			if (S_ISDIR(meta->message.body.stat.st_mode)) {
				mkdir(cur_dir, meta->message.body.stat.st_mode);
				fprintf(stderr, "sync meta : create dir\n");
				// dir utime
				struct utimbuf meta_time;
				memset(&meta_time, 0, sizeof(meta_time));
				meta_time.actime = meta->message.body.stat.st_atime;
				meta_time.modtime = meta->message.body.stat.st_mtime;
				utime(cur_dir, &meta_time);
				fprintf(stderr, "create dir\n");
			}
			if (S_ISREG(meta->message.body.stat.st_mode)) {
				int fd = creat(cur_dir, meta->message.body.stat.st_mode);
				// file utime
				struct utimbuf meta_time;
				memset(&meta_time, 0, sizeof(meta_time));
				meta_time.actime = meta->message.body.stat.st_atime;
				meta_time.modtime = meta->message.body.stat.st_mtime;
				utime(cur_dir, &meta_time);
				fprintf(stderr, "sync meta : create file\n");
				close(fd);
				file_check = 1;
			}
			if (S_ISLNK(meta->message.body.stat.st_mode)) {
				fprintf(stderr, "sync meta : is symbolic link\n");
				file_check = 1;
			}
			object = strtok(NULL, "/");
		}
		// file exist
		else {
			// is directory
			if (S_ISDIR(object_stat.st_mode)){
				if (chdir(cur_dir) == -1) {
					fprintf(stderr, "chdir error\n");
					return 0;
				}
			}
			else {
			// is file
				// file chmod
				chmod(cur_dir, meta->message.body.stat.st_mode);
				chown(cur_dir, meta->message.body.stat.st_uid, meta->message.body.stat.st_gid);
				// check if is same
				uint8_t content_hash[MD5_DIGEST_LENGTH];
				memset(content_hash, 0, sizeof(content_hash));
				md5_file(cur_dir, content_hash);
				if (memcmp(content_hash, meta->message.body.hash, MD5_DIGEST_LENGTH) != 0) file_check = 1;
				// file utime
				struct utimbuf meta_time;
				memset(&meta_time, 0, sizeof(meta_time));
				meta_time.actime = meta->message.body.stat.st_atime;
				meta_time.modtime = meta->message.body.stat.st_mtime;
				utime(cur_dir, &meta_time);
			}
			object = strtok(NULL, "/");
			// dir chmod
			if (object == NULL) {
				chmod(cur_dir, meta->message.body.stat.st_mode);
				chown(cur_dir, meta->message.body.stat.st_uid, meta->message.body.stat.st_gid);
				struct utimbuf meta_time;
				// dir utime
				memset(&meta_time, 0, sizeof(meta_time));
				meta_time.actime = meta->message.body.stat.st_atime;
				meta_time.modtime = meta->message.body.stat.st_mtime;
				utime(cur_dir, &meta_time);
			}
		}
	}
	// send back message
	csiebox_protocol_header header;
	memset(&header, 0, sizeof(header));
	header.res.magic = CSIEBOX_PROTOCOL_MAGIC_RES;
	header.res.op = CSIEBOX_PROTOCOL_OP_SYNC_META;
	header.res.status = (file_check == 1)? CSIEBOX_PROTOCOL_STATUS_MORE : CSIEBOX_PROTOCOL_STATUS_OK;
	header.res.datalen = 0;
	send_message(conn_fd, &header, sizeof(header));
	fprintf(stderr, "sync meta : success\n");
//.........这里部分代码省略.........
开发者ID:qhan1028,项目名称:SP2015,代码行数:101,代码来源:csiebox_server.c


示例6: sap_transfer_apdu_rsp

int sap_transfer_apdu_rsp(void *sap_device, uint8_t result, uint8_t *apdu,
					uint16_t length)
{
	struct sap_connection *conn = sap_device;
	char buf[SAP_BUF_SIZE];
	struct sap_message *msg = (struct sap_message *) buf;
	struct sap_parameter *param = (struct sap_parameter *) msg->param;
	size_t size = sizeof(struct sap_message);

   DBG("1 size(%d)", size);

	if (!conn)
		return -EINVAL;

	DBG("state %d pr 0x%02x", conn->state, conn->processing_req);

	if (conn->processing_req != SAP_TRANSFER_APDU_REQ)
	{
      DBG("returned !SAP_TRANSFER_APDU_REQ");
		return 0;
	}

	if (result == SAP_RESULT_OK && (!apdu || (apdu && length == 0x00)))
	{
      DBG("returned EINVAL");
		return -EINVAL;
	}

   DBG("original APDU length(%d)", length);

	memset(buf, 0, sizeof(buf));
	msg->id = SAP_TRANSFER_APDU_RESP;
	msg->nparam = 0x01;
	size += add_result_parameter(result, param);

   DBG("2 size(%d)", size);

	/* Add APDU response. */
	if (result == SAP_RESULT_OK) {
      DBG("result OK");
		msg->nparam++;
		param = (struct sap_parameter *) &buf[size];
		param->id = SAP_PARAM_ID_RESPONSE_APDU;
		param->len = htons(length);

      DBG("param->len(%d)", param->len);

		size += PARAMETER_SIZE(length);

      DBG("3 size(%d)", size);

      DBG("PARAMETER size(%d)", size);

		if (size > SAP_BUF_SIZE)
		{
         DBG("returned EOVERFLOW");
			return -EOVERFLOW;
		}

		memcpy(param->val, apdu, length);
	} else {
	   DBG("result not OK");
	}

	conn->processing_req = SAP_NO_REQ;

   DBG("buf : %s", buf);
   DBG("buf_len(%d), size(%d)", strlen(buf), size);

	return send_message(sap_device, buf, size);
}
开发者ID:Kick-Buttowski,项目名称:android_external_bluetooth_bluez,代码行数:71,代码来源:server.c


示例7: rms_send_free_text_msg

void rms_send_free_text_msg () {

   UNSIGNED_BYTE free_text_buf[MAX_BUF_SIZE];
   UNSIGNED_BYTE *free_text_buf_ptr;
   char          *Msg;
   int           ret, i, msg_size;
   LB_info       info;
   ushort        message_size_halfwords, num_halfwords;

   /* Search for the latest free text message. */
   if((ret = ORPGDA_seek(ORPGDAT_RMS_TEXT_MSG, 0, LB_LATEST, &info)) < 0) {
       LE_send_msg(RMS_LE_ERROR, "Failed seek RMMS free text message (%d).\n", ret );
   }else {

      /* Allocate memory for the message. */
      Msg = (char*)malloc(info.size);

      /* Read the latest message. */
      ret = ORPGDA_read (ORPGDAT_RMS_TEXT_MSG, (char *) Msg, info.size, info.id);

      if(ret <0 ){
         LE_send_msg(RMS_LE_ERROR, "Failed read RMMS free text message (%d).\n", ret );
      }else {
         /* Set the pointer to beginning of buffer */
         free_text_buf_ptr = free_text_buf;

         /* Set the pointer past the header */
         free_text_buf_ptr += MESSAGE_START;

         /* Compute the size of the free text string in halfwords */
         message_size_halfwords = (info.size/2);

         /* Adjust for rounding */
         message_size_halfwords += (info.size%2);

         /* Put free text string size in output buffer */
          conv_ushort_unsigned(free_text_buf_ptr,&message_size_halfwords);
         free_text_buf_ptr += PLUS_SHORT;

         /* Put free text string in output buffer */
         for (i=0; i< info.size; i++){
            conv_char_unsigned(free_text_buf_ptr, &Msg[i], PLUS_BYTE);
            free_text_buf_ptr += PLUS_BYTE;
         } /* End loop */

         /* Compute the size of the message */
         msg_size = (free_text_buf_ptr - free_text_buf);

         /* Pad the message */
         pad_message (free_text_buf_ptr, msg_size, TEXT_PAD_SIZE);
         free_text_buf_ptr += (TEXT_PAD_SIZE - msg_size);

         /* Add the terminator to the message */
         add_terminator(free_text_buf_ptr);
         free_text_buf_ptr += PLUS_INT;

         /* Compute the size of the message in halfwords */
         num_halfwords = ((free_text_buf_ptr - free_text_buf) / 2);

         /* Add header to message */
         ret = build_header(&num_halfwords, FREE_TYPE, free_text_buf, 0);

         if (ret != 1){
            LE_send_msg (RMS_LE_ERROR,
            "RMS build header failed for rms send free text message");
         } /* End if */

         /* Send message to the FAA/RMMs */
         ret = send_message(free_text_buf,FREE_TYPE,RMS_STANDARD);

         if (ret != 1){
            LE_send_msg (RMS_LE_ERROR,
            "Send message failed (ret %d) for rms send free text message", ret);
         }  /* end if */
      } /* End else */

      free(Msg);

   } /* End else */

} /*End rms send free text msg */
开发者ID:likev,项目名称:CodeOrpgPub,代码行数:81,代码来源:rms_send_free_text.c


示例8: comm_get_txspace

void
GCS_MAVLINK::send_text(MAV_SEVERITY severity, const char *str)
{
    if (severity < MAV_SEVERITY_WARNING &&
            comm_get_txspace(chan) >=
            MAVLINK_NUM_NON_PAYLOAD_BYTES+MAVLINK_MSG_ID_STATUSTEXT_LEN) {
        // send immediately
        char msg[50] {};
        strncpy(msg, str, sizeof(msg));
        mavlink_msg_statustext_send(chan, severity, msg);
    } else {
        // send via the deferred queuing system
        mavlink_statustext_t *s = &pending_status;
        s->severity = (uint8_t)severity;
        strncpy((char *)s->text, str, sizeof(s->text));
        send_message(MSG_STATUSTEXT);
    }

#if CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN && APM_BUILD_TYPE(APM_BUILD_ArduCopter)
    if (!strcmp(str, "compass disabled"))                       // Messages defined in compassmot.pde (10x)
        textId = 1;
    else if (!strcmp(str, "check compass"))
        textId = 2;
    else if (!strcmp(str, "RC not calibrated"))
        textId = 3;
    else if (!strcmp(str, "thr not zero"))
        textId = 4;
    else if (!strcmp(str, "Not landed"))
        textId = 5;
    else if (!strcmp(str, "STARTING CALIBRATION"))
        textId = 6;
    else if (!strcmp(str, "CURRENT"))
        textId = 7;
    else if (!strcmp(str, "THROTTLE"))
        textId = 8;
    else if (!strcmp(str, "Calibration Successful"))
        textId = 9;
    else if (!strcmp(str, "Failed"))
        textId = 10;
    else if (!strcmp(str, "AutoTune: Started"))                 // Messages defined in control_autotune.pde (4x)
        textId = 21;
    else if (!strcmp(str, "AutoTune: Stopped"))
        textId = 22;
    else if (!strcmp(str, "AutoTune: Success"))
        textId = 23;
    else if (!strcmp(str, "AutoTune: Failed"))
        textId = 24;
    else if (!strcmp(str, "Crash: Disarming"))                  // Messages defined in crash_check.pde (3x)
        textId = 35;
    else if (!strcmp(str, "Parachute: Released"))
        textId = 36;
    else if (!strcmp(str, "Parachute: Too Low"))
        textId = 37;
    else if (!strcmp(str, "EKF variance"))                      // Messages defined in ekf_check.pde (2x)
        textId = 48;
    else if (!strcmp(str, "DCM bad heading"))
        textId = 49;
    else if (!strcmp(str, "Low Battery"))                       // Messages defined in events.pde (2x)
        textId = 60;
    else if (!strcmp(str, "Lost GPS"))
        textId = 61;
    else if (!strcmp(str, "bad rally point message ID"))        // Messages defined in GCS_Mavlink.pde (6x)
        textId = 72;
    else if (!strcmp(str, "bad rally point message count"))
        textId = 73;
    else if (!strcmp(str, "error setting rally point"))
        textId = 74;
    else if (!strcmp(str, "bad rally point index"))
        textId = 75;
    else if (!strcmp(str, "failed to set rally point"))
        textId = 76;
    else if (!strcmp(str, "Initialising APM..."))
        textId = 77;
    else if (!strcmp(str, "Erasing logs"))                      // Messages defined in Log.pde (2x)
        textId = 88;
    else if (!strcmp(str, "Log erase complete"))
        textId = 89;
    else if (!strcmp(str, "ARMING MOTORS"))                     // Messages defined in motors.pde  (30x)
        textId = 100;
    else if (!strcmp(str, "Arm: Gyro cal failed"))
        textId = 101;
    else if (!strcmp(str, "PreArm: RC not calibrated"))
        textId = 102;
    else if (!strcmp(str, "PreArm: Baro not healthy"))
        textId = 103;
    else if (!strcmp(str, "PreArm: Alt disparity"))
        textId = 104;
    else if (!strcmp(str, "PreArm: Compass not healthy"))
        textId = 105;
    else if (!strcmp(str, "PreArm: Compass not calibrated"))
        textId = 106;
    else if (!strcmp(str, "PreArm: Compass offsets too high"))
        textId = 107;
    else if (!strcmp(str, "PreArm: Check mag field"))
        textId = 108;
    else if (!strcmp(str, "PreArm: compasses inconsistent"))
        textId = 109;
    else if (!strcmp(str, "PreArm: INS not calibrated"))
        textId = 110;
    else if (!strcmp(str, "PreArm: Accels not healthy"))
//.........这里部分代码省略.........
开发者ID:VirtualRobotixItalia,项目名称:ardupilot,代码行数:101,代码来源:GCS_Common.cpp


示例9: end_sending_file

/* we have gotten to the end of the local file we are sending;
 * close the file descriptor on that file, and send a message to the
 * other side indicating that the whole file has been sent.
 */
static void end_sending_file()
{
    send_message(byte_buf, 1, transfer_end_msg);
    state = state_nominal;
    close(fd);
}
开发者ID:gregfjohnson,项目名称:Cloud-hub,代码行数:10,代码来源:com_util.c


示例10: WizardDlgProc

static LRESULT WizardDlgProc(HWND hDlg,UINT msg, WPARAM wParam,LPARAM lParam)
  {
  int i;
  switch (msg)
	{
	case WM_INITDIALOG:
	  hWizardDlg = hDlg;
	  hWizardText = GetDlgItem(hDlg,IDC_OUTPUT);
	  SendMessage(hWizardText,WM_SETFONT,(WPARAM)hfCourier,1);
	  display_game_status();
	  SetTimer(hDlg,10,20,NULL);
	  return 0;	
	case WM_TIMER: do_events();return 1;
	case WM_COMMAND:
	  switch (LOWORD(wParam))
		{
	 case IDCANCEL: EndDialog(hDlg,0);return 0;
     case IDC_CLEARMAP:
       {
          HWND listwnd = PrepareListWindow(hDlg);
          HWND list = GetDlgItem(listwnd,IDC_LIST);
          int res;
          ListBox_AddString(list,"Clear Monsters");
          ListBox_AddString(list,"Clear Items");
          res = PumpDialogMessages(listwnd);
          if (res == IDOK)
          {
            if (ListBox_GetSel(list,0))
            {
              for(i = 0;i<MAX_MOBS;i++)
                          if (mobs[i].vlajky & MOB_LIVE)
                            {
                            vybrana_zbran = -1;
                            select_player = -1;
                            mob_hit(mobs+i,mobs[i].lives);
                            }
            }
            if (ListBox_GetSel(list,1))
            {
              for(i = 0;i<mapsize*4;i++)
                              {
                              destroy_items(map_items[i]);
                              free(map_items[i]);
                              map_items[i] = NULL;
                              }
                           for(i = 0;i<vyk_max;i++)
                              {
                              destroy_items(map_vyk[i].items);
                              map_vyk[i].items[0] = 0;
                              }
            }
          }
          CloseListWindow(listwnd);          
       }
       break;
       
     case IDC_ADVENCE:
              {
              int i,j,c;
              if (!wzscanf("Advence to level <postava -1= vsichni><uroven>:","%d %d",&i,&j)) return 0;
              c = MessageBox(GetActiveWindow(),"Automaticky?","?",MB_YESNO|MB_ICONQUESTION);
              if (i>0) advence_player(i-1,j,c == IDYES);else
                 for(i = 0;i<POCET_POSTAV;i++) if (postavy[i].used) advence_player(i,j,c == IDYES);              
              return 0;
              }
     case IDC_GOTO:
			  {
			  char prompt[50];
              sprintf(prompt,"Goto sector <1-%d>:",mapsize-1);
			  if (!wzscanf(prompt,"%d",&viewsector)) return 0;
              chod_s_postavama(1);              
              SEND_LOG("(WIZARD) Goto %d",viewsector,0);
              return 0;
			  }
     case IDC_LOADMAP:
              if (!wzscanf("Load Map <filename><sector>","%s %hd",loadlevel.name,&loadlevel.start_pos)) return 0;
              for(i = 0;i<POCET_POSTAV;i++)postavy[i].sektor = loadlevel.start_pos;
              SEND_LOG("(WIZARD) Load map '%s' %d",loadlevel.name,loadlevel.start_pos);
			  EndDialog(hDlg,0);
              send_message(E_CLOSE_MAP);
              return 0;
     case IDC_OPENDOOR:if (map_sectors[viewsector].step_next[viewdir])
                delay_action(3,viewsector,viewdir,0x2000000,0,0);
              else
                delay_action(3,viewsector,viewdir,0,0,0);
              return 0;
     case IDC_TAKEMONEY:if (take_money()) return 0;break;
     case IDC_PURGE:if (purge_map()) return 0;break;
     case IDC_HEAL:if (heal_meditate()) return 0;break;
     case IDC_RAISEDEATH:if (raise_death()) return 0;break;
     case IDC_RAISEMONSTER:if (raise_killed_monster(hDlg)) return 0;break;
     case IDC_IMMORTAL:set_immortality();break;
     case IDC_NETECNOST:set_nohassle();break;
     case IDC_UNAFFECT :unaffect();break;
     case IDC_WEAPONSKILL:if (advance_weapon()) return 0;break;
     case IDC_REFRESH:display_game_status();break;
     case IDC_RELOADMOBILES:
			  i = MessageBox(hDlg,"Tato funkce precte znova parametry vsech existujicich nestvur. "
                      "Pouzivej jen v pripade, ze se tyto parametry zmenili a nesouhlasi tak "
                      "obsah ulozene pozice. Pokracovat? ","??",MB_YESNO|MB_ICONQUESTION);
//.........这里部分代码省略.........
开发者ID:svn2github,项目名称:Brany_Skeldalu,代码行数:101,代码来源:WIZARD.C


示例11: start_wallclock

void start_wallclock()
{
    uint32_t status;
    //initialise
    offset = 0; 
    ref = 0;
    clock_display_en = 0; //clock not displayed by default
    timeout_env = request_msg_env();
    send_env = request_msg_env();
    msg_q = msg_env_queue_create(); 

    status = request_delay ( ONE_SECOND_DELAY, WAKEUP_CODE, timeout_env); 
    if (status != CODE_SUCCESS)
    {
        params[0] = &status;
        params[1] = NULL;
        rtx_sprintf(str, "request_delay failed with status %d\r\n", params);
        print_ack(str, send_env, msg_q);
    }
    
    MsgEnv* env;

    while (1)
    {
        if (msg_env_queue_is_empty(msg_q))
        {
            env = receive_message();
        }
        else
        {
            env = msg_env_queue_dequeue(msg_q);
        }

        //envelope from timing services
        if (env->msg_type == WAKEUP_CODE)
        {
            status = request_delay( ONE_SECOND_DELAY, WAKEUP_CODE, timeout_env);
            if (status != CODE_SUCCESS)
            {
                params[0] = &status;
                params[1] = NULL;
                rtx_sprintf(str, "request_delay failed with status %d\r\n", params);
                print_ack(str, send_env, msg_q);
            }
            //86400 = 24hrs in secs
            int32_t clock_time = (int32_t)((get_system_time()-ref)/100
                                 +offset)%SEC_IN_HR;
            if (clock_display_en)
            {
                int32_t hr, min, sec;
                hr = clock_time/3600;
                min = (clock_time%3600)/60;
                sec = clock_time%60;

                params[0] = &hr;
                params[1] = &min;
                params[2] = &sec;
                params[3] = NULL;
                rtx_sprintf(str, SAVE_CURSOR MOVE_CURSOR CLOCK_FORMAT
                            RESTORE_CURSOR, params);
                print_ack(str, send_env, msg_q);
            }
        }
        else if (env->msg_type == CLOCK_ON)
        {
            _displayWallClock (1);
            env->msg_type = CLOCK_RET;
            send_message(env->send_pid,env);
        }
        else if (env->msg_type == CLOCK_OFF)
        {
            _displayWallClock (0);
            env->msg_type = CLOCK_RET;
            send_message(env->send_pid,env);
        }
        else if (env->msg_type == CLOCK_SET) 
        {
            int status = _setWallClock (env->msg);
            if (status == ERROR_ILLEGAL_ARG)
            {
                params[0] = NULL;
                rtx_sprintf( str, "c\r\n"
                           "Sets the console clock (24h).\r\n"
                           "Usage: c <hh:mm:ss>\r\n"
                           "hh must be 00-23\r\n"
                           "mm must be 00-59\r\n"
                           "ss must be 00-59\r\n", params );
                print_ack(str, send_env, msg_q);
            }
            else if (status != CODE_SUCCESS)
            {
                params[0] = &status;
                params[1] = NULL;
                rtx_sprintf( str, "CCI_setClock failed with status %d\r\n", params);
                print_ack(str, send_env, msg_q);
            }
            env->msg_type = CLOCK_RET;
            send_message(env->send_pid,env);
        }
    }
//.........这里部分代码省略.........
开发者ID:Hassaan,项目名称:rtx,代码行数:101,代码来源:wallclock.c


示例12: help_mouse_callback

static void
help_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
{
    int x, y;
    GSList *current_area;

    if (msg != MSG_MOUSE_CLICK)
        return;

    if ((event->buttons & GPM_B_RIGHT) != 0)
    {
        /* Right button click */
        help_back (whelp);
        return;
    }

    /* Left bytton click */

    /* The event is relative to the dialog window, adjust it: */
    x = event->x - 1;
    y = event->y - 1;

    /* Test whether the mouse click is inside one of the link areas */
    for (current_area = link_area; current_area != NULL; current_area = g_slist_next (current_area))
    {
        Link_Area *la = (Link_Area *) current_area->data;

        /* Test one line link area */
        if (y == la->y1 && x >= la->x1 && y == la->y2 && x <= la->x2)
            break;

        /* Test two line link area */
        if (la->y1 + 1 == la->y2)
        {
            /* The first line || The second line */
            if ((y == la->y1 && x >= la->x1) || (y == la->y2 && x <= la->x2))
                break;
        }
        /* Mouse will not work with link areas of more than two lines */
    }

    /* Test whether a link area was found */
    if (current_area != NULL)
    {
        Link_Area *la = (Link_Area *) current_area->data;

        /* The click was inside a link area -> follow the link */
        history_ptr = (history_ptr + 1) % HISTORY_SIZE;
        history[history_ptr].page = currentpoint;
        history[history_ptr].link = la->link_name;
        currentpoint = help_follow_link (currentpoint, la->link_name);
        selected_item = NULL;
    }
    else if (y < 0)
        move_backward (help_lines - 1);
    else if (y >= help_lines)
        move_forward (help_lines - 1);
    else if (y < help_lines / 2)
        move_backward (1);
    else
        move_forward (1);

    /* Show the new node */
    send_message (w->owner, NULL, MSG_DRAW, 0, NULL);
}
开发者ID:MidnightCommander,项目名称:mc,代码行数:65,代码来源:help.c


示例13: message_loop

static void message_loop() {
	static char buf1[4096], buf2[4096];
	struct nlmsghdr *nlh, *nlh2 = NULL;
	int skipped = 0;

	while (1) {
		struct userui_msg_params *msg;

		if (nlh2) {
			nlh = nlh2;
			nlh2 = NULL;
			memcpy(&buf1, &buf2, 4096);
			memset(&buf2, 0, 4096);
		} else
			if (!(nlh = fetch_message(buf1, sizeof(buf1), 0)))
				return; /* EOF */

		//nlh2 = fetch_message(buf2, sizeof(buf2), 1);

		msg = NLMSG_DATA(nlh);

		/* If there are two or more messages waiting and the current
		   message type is the same as the type of the next message,
		   skip this one. */
		if (nlh2 && nlh->nlmsg_type == nlh2->nlmsg_type && (++skipped < 5))
			continue;

		skipped = 0;
		might_switch_ops();

		switch (nlh->nlmsg_type) {
			case USERUI_MSG_MESSAGE:
				active_ops->message(msg->a, msg->b, msg->c, msg->text);
				break;
			case USERUI_MSG_PROGRESS:
				active_ops->update_progress(msg->a, msg->b, msg->text);
				break;
			case USERUI_MSG_GET_STATE:
				suspend_action = *(uint32_t*)NLMSG_DATA(nlh);
				break;
			case USERUI_MSG_GET_DEBUG_STATE:
				suspend_debug = *(uint32_t*)NLMSG_DATA(nlh);
				break;
			case USERUI_MSG_GET_LOGLEVEL:
				console_loglevel = *(uint32_t*)NLMSG_DATA(nlh);
				set_console_loglevel(0);
				break;
			case USERUI_MSG_IS_DEBUGGING:
				debugging_enabled = *(uint32_t *)NLMSG_DATA(nlh);
				break;
			case USERUI_MSG_GET_POWERDOWN_METHOD:
				powerdown_method = *(uint32_t *)NLMSG_DATA(nlh);
				break;
			case USERUI_MSG_CLEANUP:
				active_ops->cleanup();
				send_message(USERUI_MSG_CLEANUP, NULL, 0);
				close(nlsock);
				exit(0);
			case USERUI_MSG_POST_ATOMIC_RESTORE:
				send_message(USERUI_MSG_GET_LOGLEVEL, NULL, 0);
				send_message(USERUI_MSG_GET_STATE, NULL, 0);
				send_message(USERUI_MSG_GET_DEBUG_STATE, NULL, 0);
				send_message(USERUI_MSG_GET_POWERDOWN_METHOD, NULL, 0);
				resuming = 1;
				unblank_screen();
				active_ops->redraw();
				break;
			case NLMSG_ERROR:
				report_nl_error(nlh);
				break;
			case NLMSG_DONE:
				break;
			default:
				printf("userui: Received unknown message %d\n", nlh->nlmsg_type);
				break;
		}

		if (need_loglevel_change) {
			need_loglevel_change = 0;
			active_ops->log_level_change();
		}
	}
}
开发者ID:liulibing,项目名称:Tuxonice-Userui,代码行数:83,代码来源:userui_core.c


示例14: notify_space_pressed

static void notify_space_pressed() {
	send_message(USERUI_MSG_SPACE, NULL, 0);
}
开发者ID:liulibing,项目名称:Tuxonice-Userui,代码行数:3,代码来源:userui_core.c


示例15: svc


//.........这里部分代码省略.........
                else if(checkTimer(ID) == 1) {
                    head = timerfront;
                    while(head->pid != ID)
                        head=head->next;
                    change_priority_timer(head,PR);
                    Z502_REG9 = ERR_SUCCESS;
                }
                else if(checkSuspend(ID) == 1) {
                    head = suspendfront;
                    while(head->pid != ID)
                        head = head->next;
                    change_priority_suspend(head,PR);
                    Z502_REG9 = ERR_SUCCESS;
                }
                else {
                    printf("ID ERROR!\n");
                }
            }
            else {
                printf("illegal Priority");
            }
        }
        break;
    case SYSNUM_SEND_MESSAGE:
        sid = Running->pid;
        tid = (int)SystemCallData->Argument[0];
        tmpmsg =(char *)SystemCallData->Argument[1];
        mlen = (int)SystemCallData->Argument[2];
        if(maxbuffer < 8) {
            if(tid < 100) {
                if(mlen < 100)
                {
                    if(tid>0)
                    {   send_message(sid,tid,mlen,tmpmsg);
                        maxbuffer++;
                    }
                    else if(tid == -1) {
                        send_message_to_all(sid,mlen,tmpmsg);
                        maxbuffer++;
                    }
                }
                else {
                    printf("illegal length!\n");
                }
            } else
                printf("illegal id!\n");
        }
        else
        {   printf("no space!\n");
            Z502_REG9++;
        }
        break;
    case  SYSNUM_RECEIVE_MESSAGE:
        sid = (int)SystemCallData->Argument[0];
        mlen = (int)SystemCallData->Argument[2];

        if(sid < 100) {
            if(mlen < 100) {
                if(sid == -1) {

                    receive_message_fromall();
                    if(msgnum>0) {
                        actual_length = strlen(checkmsg->msg_buffer);
                        if(mlen >actual_length) {
                            msg_out_queue(checkmsg);
                            *SystemCallData->Argument[3] = actual_length;
开发者ID:KuanSheng,项目名称:CS502_OS,代码行数:67,代码来源:base.c


示例16: mavlink_msg_mission_item_decode

/*
  handle an incoming mission item
  return true if this is the last mission item, otherwise false
 */
bool GCS_MAVLINK::handle_mission_item(mavlink_message_t *msg, AP_Mission &mission)
{
    mavlink_mission_item_t packet;
    MAV_MISSION_RESULT result = MAV_MISSION_ACCEPTED;
    struct AP_Mission::Mission_Command cmd = {};
    bool mission_is_complete = false;

    mavlink_msg_mission_item_decode(msg, &packet);

    // convert mavlink packet to mission command
    if (!AP_Mission::mavlink_to_mission_cmd(packet, cmd)) {
        result = MAV_MISSION_INVALID;
        goto mission_ack;
    }

    if (packet.current == 2) {                                               
        // current = 2 is a flag to tell us this is a "guided mode"
        // waypoint and not for the mission
        handle_guided_request(cmd);

        // verify we received the command
        result = MAV_MISSION_ACCEPTED;
        goto mission_ack;
    }

    if (packet.current == 3) {
        //current = 3 is a flag to tell us this is a alt change only
        // add home alt if needed
        handle_change_alt_request(cmd);

        // verify we recevied the command
        result = MAV_MISSION_ACCEPTED;
        goto mission_ack;
    }

    // Check if receiving waypoints (mission upload expected)
    if (!waypoint_receiving) {
        result = MAV_MISSION_ERROR;
        goto mission_ack;
    }

    // check if this is the requested waypoint
    if (packet.seq != waypoint_request_i) {
        result = MAV_MISSION_INVALID_SEQUENCE;
        goto mission_ack;
    }
    
    // if command index is within the existing list, replace the command
    if (packet.seq < mission.num_commands()) {
        if (mission.replace_cmd(packet.seq,cmd)) {
            result = MAV_MISSION_ACCEPTED;
        }else{
            result = MAV_MISSION_ERROR;
            goto mission_ack;
        }
        // if command is at the end of command list, add the command
    } else if (packet.seq == mission.num_commands()) {
        if (mission.add_cmd(cmd)) {
            result = MAV_MISSION_ACCEPTED;
        }else{
            result = MAV_MISSION_ERROR;
            goto mission_ack;
        }
        // if beyond the end of the command list, return an error
    } else {
        result = MAV_MISSION_ERROR;
        goto mission_ack;
    }
    
    // update waypoint receiving state machine
    waypoint_timelast_receive = hal.scheduler->millis();
    waypoint_request_i++;
    
    if (waypoint_request_i >= waypoint_request_last) {
        mavlink_msg_mission_ack_send_buf(
            msg,
            chan,
            msg->sysid,
            msg->compid,
            MAV_MISSION_ACCEPTED);
        
        send_text_P(SEVERITY_LOW,PSTR("flight plan received"));
        waypoint_receiving = false;
        mission_is_complete = true;
        // XXX ignores waypoint radius for individual waypoints, can
        // only set WP_RADIUS parameter
    } else {
        waypoint_timelast_request = hal.scheduler->millis();
        // if we have enough space, then send the next WP immediately
        if (comm_get_txspace(chan) >= 
            MAVLINK_NUM_NON_PAYLOAD_BYTES+MAVLINK_MSG_ID_MISSION_ITEM_LEN) {
            queued_waypoint_send();
        } else {
            send_message(MSG_NEXT_WAYPOINT);
        }
    }
//.........这里部分代码省略.........
开发者ID:radiohail,项目名称:ardupilot,代码行数:101,代码来源:GCS_Common.cpp


示例17: sap_connect_rsp

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ send_msg函数代码示例发布时间:2022-05-30
下一篇:
C++ send_log函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap