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


Python Packet.parse_packet方法代码示例

本文整理汇总了Python中packet.Packet.parse_packet方法的典型用法代码示例。如果您正苦于以下问题:Python Packet.parse_packet方法的具体用法?Python Packet.parse_packet怎么用?Python Packet.parse_packet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在packet.Packet的用法示例。


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

示例1: RadioSubsystem

# 需要导入模块: from packet import Packet [as 别名]
# 或者: from packet.Packet import parse_packet [as 别名]

#.........这里部分代码省略.........
            Radio bitrate, one of {...}
            
        """

        if mode == 'stream_data':
            self.packet.set_flags_node_a(send_stream=True)
            payload = self.data.pack_data(mode)

        elif mode == 'send_reconfig_command':
            self.packet.set_flags_node_a(send_command=True)
            payload = self.data.pack_data(mode, mod, eirp, bitrate)

        elif mode == 'request_data':
            self.packet.set_flags_node_a(request_data=True)
            payload = self.data.pack_data(mode)

        else:
            print "error in _send_packet, no mode specified"
            raise ValueError

        tx_packet = self.packet.make_packet(self.tx_packet_number, self.current_location, payload)
        self.tx_packet_number += 1
        self.radio.transmit(tx_packet)
        # logging.info("packet sent")


    def _receive_packet(self):
        """
        Receive packet

        """
        (self.rssi_level, rx_packet) = self.radio.receive(rx_fifo_threshold=63, timeout=None)
        # rx_packet = self.radio.receive(rx_fifo_threshold=64, timeout=None)
        pkt_num, t, loc, flags, data = self.packet.parse_packet(rx_packet)

        return pkt_num, loc, flags, data

                    
    def set_current_location(self, current_location):
        """
        Set current location.

        Used by controller to tell radio subsytem the current physical
        location.

        Parameters
        ----------
        current_location : int
            Value of barcode representing current location.

        """

        self.current_location = current_location


    def set_config_packet_data(self, modulation, eirp, bitrate):
        """
        Set reconfig-packet data.

        This function is used by the controller to set the contents of
        the packet that is used in a reconfiguration request. NOTE:
        use this function to set the config packet data *before*
        sending a reconfiguration packet.

        """
        self.reconfig_mod = modulation
开发者ID:saschayoung,项目名称:fessenden,代码行数:70,代码来源:radio_subsystem.py


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