当前位置: 首页>>代码示例>>Java>>正文


Java MAVLinkPacket类代码示例

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


MAVLinkPacket类属于com.MAVLink包,在下文中一共展示了MAVLinkPacket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendMessage

import com.MAVLink.MAVLinkPacket; //导入依赖的package包/类
@Override
public void sendMessage(MAVLinkPacket packet) throws IOException {
    if (packet == null)
        return;

    if (session.isOpen()) {
        synchronized(sendLock) {
            try {
                packet.seq = seq++;

                byte[] data = packet.encodePacket();

                session.getBasicRemote().sendBinary(ByteBuffer.wrap(data));

                MAVLinkLogger.log(Level.DEBUG, ">>", packet);
            } catch (IOException ex) {
                logger.warn("Failed to send MAVLink message to socket. " + ex.getMessage());
            }
        }
    }

}
 
开发者ID:envirover,项目名称:SPLGroundControl,代码行数:23,代码来源:MAVLinkWebSocket.java

示例2: pack

import com.MAVLink.MAVLinkPacket; //导入依赖的package包/类
/**
* Generates the payload for a mavlink message for a message of this type
* @return
*/
public MAVLinkPacket pack(){
    MAVLinkPacket packet = new MAVLinkPacket(MAVLINK_MSG_LENGTH);
    packet.sysid = 255;
    packet.compid = 190;
    packet.msgid = MAVLINK_MSG_ID_TERRAIN_REQUEST;
          
    packet.payload.putUnsignedLong(mask);
          
    packet.payload.putInt(lat);
          
    packet.payload.putInt(lon);
          
    packet.payload.putUnsignedShort(grid_spacing);
    
    return packet;
}
 
开发者ID:envirover,项目名称:SPLGroundControl,代码行数:21,代码来源:msg_terrain_request.java

示例3: run

import com.MAVLink.MAVLinkPacket; //导入依赖的package包/类
@Override
public void run() {
    logger.debug("MOMessagePump started.");

    while (true) {
        try {
            MAVLinkPacket packet = src.receiveMessage();

            dst.sendMessage(packet);

            Thread.sleep(MO_MESSAGE_PUMP_INTERVAL);
        } catch (IOException ex) {
            logger.error(ex.getMessage());
        } catch (InterruptedException e) {
            dst.close();
            logger.debug("MOMessagePump interrupted.");
            return;
        }
    }
}
 
开发者ID:envirover,项目名称:SPLGroundControl,代码行数:21,代码来源:MOMessagePump.java

示例4: pack

import com.MAVLink.MAVLinkPacket; //导入依赖的package包/类
/**
* Generates the payload for a mavlink message for a message of this type
* @return
*/
public MAVLinkPacket pack(){
    MAVLinkPacket packet = new MAVLinkPacket(MAVLINK_MSG_LENGTH);
    packet.sysid = 255;
    packet.compid = 190;
    packet.msgid = MAVLINK_MSG_ID_SCALED_PRESSURE;
          
    packet.payload.putUnsignedInt(time_boot_ms);
          
    packet.payload.putFloat(press_abs);
          
    packet.payload.putFloat(press_diff);
          
    packet.payload.putShort(temperature);
    
    return packet;
}
 
开发者ID:envirover,项目名称:SPLGroundControl,代码行数:21,代码来源:msg_scaled_pressure.java

示例5: pack

import com.MAVLink.MAVLinkPacket; //导入依赖的package包/类
/**
* Generates the payload for a mavlink message for a message of this type
* @return
*/
public MAVLinkPacket pack(){
    MAVLinkPacket packet = new MAVLinkPacket(MAVLINK_MSG_LENGTH);
    packet.sysid = 255;
    packet.compid = 190;
    packet.msgid = MAVLINK_MSG_ID_SCALED_PRESSURE3;
          
    packet.payload.putUnsignedInt(time_boot_ms);
          
    packet.payload.putFloat(press_abs);
          
    packet.payload.putFloat(press_diff);
          
    packet.payload.putShort(temperature);
    
    return packet;
}
 
开发者ID:envirover,项目名称:SPLGroundControl,代码行数:21,代码来源:msg_scaled_pressure3.java

示例6: pack

import com.MAVLink.MAVLinkPacket; //导入依赖的package包/类
/**
* Generates the payload for a mavlink message for a message of this type
* @return
*/
public MAVLinkPacket pack(){
    MAVLinkPacket packet = new MAVLinkPacket(MAVLINK_MSG_LENGTH);
    packet.sysid = 255;
    packet.compid = 190;
    packet.msgid = MAVLINK_MSG_ID_PING;
          
    packet.payload.putUnsignedLong(time_usec);
          
    packet.payload.putUnsignedInt(seq);
          
    packet.payload.putUnsignedByte(target_system);
          
    packet.payload.putUnsignedByte(target_component);
    
    return packet;
}
 
开发者ID:envirover,项目名称:SPLGroundControl,代码行数:21,代码来源:msg_ping.java

示例7: msg_mission_item_reached

import com.MAVLink.MAVLinkPacket; //导入依赖的package包/类
/**
* Constructor for a new message, initializes the message with the payload
* from a mavlink packet
*
*/
public msg_mission_item_reached(MAVLinkPacket mavLinkPacket){
    this.sysid = mavLinkPacket.sysid;
    this.compid = mavLinkPacket.compid;
    this.msgid = MAVLINK_MSG_ID_MISSION_ITEM_REACHED;
    unpack(mavLinkPacket.payload);        
}
 
开发者ID:envirover,项目名称:SPLGroundControl,代码行数:12,代码来源:msg_mission_item_reached.java

示例8: writePacket

import com.MAVLink.MAVLinkPacket; //导入依赖的package包/类
@Override
public void writePacket(String deviceId, Date time, MAVLinkPacket packet) throws IOException {
    if (deviceId == null || deviceId.isEmpty() || time == null || packet == null) {
        return;
    }

    Table table = dynamoDB.getTable(tableName);

    table.putItem(new Item().withPrimaryKey(ATTR_DEVICE_ID, deviceId, ATTR_TIME, time.getTime())
            .withNumber(ATTR_MSG_ID, packet.msgid)
            .withJSON(ATTR_MESSAGE, toJSON(packet)));
}
 
开发者ID:envirover,项目名称:SPLGroundControl,代码行数:13,代码来源:DynamoDBOutputStream.java

示例9: receiveMessage

import com.MAVLink.MAVLinkPacket; //导入依赖的package包/类
@Override
public MAVLinkPacket receiveMessage() throws IOException {
    if (!is_open) {
        throw new IOException("Failed to receive message. The socket is closed.");
    }

    Parser parser = new Parser();

    MAVLinkPacket packet = null;

    // The maximum size of MAVLink packet is 261 bytes.
    for (int i = 0; i < 263 * 2; i++) {
        try {
            int c = in.readUnsignedByte();
            packet = parser.mavlink_parse_char(c);
        } catch (java.io.EOFException ex) {
            return null;
        }

        if (packet != null) {
            MAVLinkLogger.log(Level.DEBUG, "<<", packet);
            return packet;
        }
    }

    logger.warn("Failed to parse MAVLink message.");

    return null;
}
 
开发者ID:envirover,项目名称:SPLGroundControl,代码行数:30,代码来源:MAVLinkSocket.java

示例10: msg_safety_set_allowed_area

import com.MAVLink.MAVLinkPacket; //导入依赖的package包/类
/**
* Constructor for a new message, initializes the message with the payload
* from a mavlink packet
*
*/
public msg_safety_set_allowed_area(MAVLinkPacket mavLinkPacket){
    this.sysid = mavLinkPacket.sysid;
    this.compid = mavLinkPacket.compid;
    this.msgid = MAVLINK_MSG_ID_SAFETY_SET_ALLOWED_AREA;
    unpack(mavLinkPacket.payload);        
}
 
开发者ID:envirover,项目名称:SPLGroundControl,代码行数:12,代码来源:msg_safety_set_allowed_area.java

示例11: pack

import com.MAVLink.MAVLinkPacket; //导入依赖的package包/类
/**
* Generates the payload for a mavlink message for a message of this type
* @return
*/
public MAVLinkPacket pack(){
    MAVLinkPacket packet = new MAVLinkPacket(MAVLINK_MSG_LENGTH);
    packet.sysid = 255;
    packet.compid = 190;
    packet.msgid = MAVLINK_MSG_ID_LOG_ERASE;
          
    packet.payload.putUnsignedByte(target_system);
          
    packet.payload.putUnsignedByte(target_component);
    
    return packet;
}
 
开发者ID:envirover,项目名称:SPLGroundControl,代码行数:17,代码来源:msg_log_erase.java

示例12: msg_power_status

import com.MAVLink.MAVLinkPacket; //导入依赖的package包/类
/**
* Constructor for a new message, initializes the message with the payload
* from a mavlink packet
*
*/
public msg_power_status(MAVLinkPacket mavLinkPacket){
    this.sysid = mavLinkPacket.sysid;
    this.compid = mavLinkPacket.compid;
    this.msgid = MAVLINK_MSG_ID_POWER_STATUS;
    unpack(mavLinkPacket.payload);        
}
 
开发者ID:envirover,项目名称:SPLGroundControl,代码行数:12,代码来源:msg_power_status.java

示例13: msg_hil_rc_inputs_raw

import com.MAVLink.MAVLinkPacket; //导入依赖的package包/类
/**
* Constructor for a new message, initializes the message with the payload
* from a mavlink packet
*
*/
public msg_hil_rc_inputs_raw(MAVLinkPacket mavLinkPacket){
    this.sysid = mavLinkPacket.sysid;
    this.compid = mavLinkPacket.compid;
    this.msgid = MAVLINK_MSG_ID_HIL_RC_INPUTS_RAW;
    unpack(mavLinkPacket.payload);        
}
 
开发者ID:envirover,项目名称:SPLGroundControl,代码行数:12,代码来源:msg_hil_rc_inputs_raw.java

示例14: handleParams

import com.MAVLink.MAVLinkPacket; //导入依赖的package包/类
private void handleParams(MAVLinkPacket packet) throws IOException, InterruptedException {
    if (packet == null) {
        return;
    }

    MAVLinkShadow shadow = MAVLinkShadow.getInstance();

    switch (packet.msgid) {
        case msg_param_request_list.MAVLINK_MSG_ID_PARAM_REQUEST_LIST: {
            MAVLinkLogger.log(Level.INFO, "<<", packet);

            for (msg_param_value param : shadow.getParams()) {
                sendToSource(param);
                Thread.sleep(10);
            }

            logger.info(MessageFormat.format("{0} on-board parameters sent to the MAVLink client.", shadow.getParams().size()));
            break;
        }
        case msg_param_request_read.MAVLINK_MSG_ID_PARAM_REQUEST_READ: {
            MAVLinkLogger.log(Level.INFO, "<<", packet);

            msg_param_request_read request = (msg_param_request_read)packet.unpack();
            logger.info(MessageFormat.format("Sending value of parameter ''{0}'' to MAVLink client.", request.getParam_Id()));
            sendToSource(shadow.getParamValue(request.getParam_Id(), request.param_index));
            break;
        }
        case msg_param_set.MAVLINK_MSG_ID_PARAM_SET: {
            MAVLinkLogger.log(Level.INFO, "<<", packet);

            msg_param_set paramSet = (msg_param_set)packet.unpack();
            sendToSource(shadow.getParamValue(paramSet.getParam_Id(), (short)-1));
            break;
        }
    }
}
 
开发者ID:envirover,项目名称:SPLGroundControl,代码行数:37,代码来源:ClientSession.java

示例15: msg_home_position

import com.MAVLink.MAVLinkPacket; //导入依赖的package包/类
/**
* Constructor for a new message, initializes the message with the payload
* from a mavlink packet
*
*/
public msg_home_position(MAVLinkPacket mavLinkPacket){
    this.sysid = mavLinkPacket.sysid;
    this.compid = mavLinkPacket.compid;
    this.msgid = MAVLINK_MSG_ID_HOME_POSITION;
    unpack(mavLinkPacket.payload);        
}
 
开发者ID:envirover,项目名称:SPLGroundControl,代码行数:12,代码来源:msg_home_position.java


注:本文中的com.MAVLink.MAVLinkPacket类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。