Skip to content

the same function does not work the same.(recv_match) #1056

@FreshJude

Description

@FreshJude
  1. the received.py

from pymavlink import mavutil
from pymavlink.dialects.v20 import common as mavlink2

receive = mavutil.mavlink_connection('udpin:127.0.0.1:14551', dialect='common')
while True:
msg = recevie.recv_match(blocking = False)
if msg is not None:
if msg.get_type() == 'VIDEO_STREAM_INFORMATION':
if isinstance(msg.uri, str):
print(msg.uri)
print(msg)
publisher.put(msg.uri.encode('utf-8'))
match = re.match(r"udp://([^:]+):(\d+)", msg.uri)
if match:
UDP_IP = match.group(1)
UDP_PORT = match.group(2)
print(f"开始接收视频流,目标地址: {UDP_IP}:{UDP_PORT}")

  1. the send.py

from pymavlink import mavutil
from pymavlink.dialects.v20 import common as mavlink2

master_out = mavutil.mavlink_connection('udpout:127.0.0.1:14551', dialect= 'common')
video_stream_info_msg = mavlink2.MAVLink_video_stream_information_message(
stream_id=0,
count = 1,
type = 0,
flags = 0,
framerate = 30.0,
resolution_h = 1080,
resolution_v = 1920,
bitrate = 1000000,
rotation = 0,
hfov = 60,
name=b"test_stream\x00".ljust(32, b'\x00'),
uri=b'udp://127.0.0.1:5600\x00'.ljust(1600, b'\x00'),
)
while True:
master_out.mav.send(video_stream_info_msg)

These two functions work well with each other. But when I shut down the received.py, and change the port of send.py to "udpout:127.0.0.1:14550", which is another program's port. It does not work anymore.

  1. another program

from pymavlink.dialects.v20 import common as mavlink2
from pymavlink import mavutil

self.rover_in = mavutil.mavlink_connection("udpin:127.0.0.1:14550", dialect = 'common', mavlink20=True)
while True:
msg = self.rover_in.recv_match(blocking = False)
print(msg)

Here is the output of " print(msg)" : UNKNOWN_269 {data:['fd', '49', '0', '0', 'a9', 'ff', '0', 'd', '1', '0', '0', '0', 'f0', '41', '40', '42', 'f', '0', '0', '0', '38', '4', '80', '7', '0', '0', '3c', '0', '0', '1', '0', '74', '65', '73', '74', '5f', '73', '74', '72', '65', '61', '6d', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '75', '64', '70', '3a', '2f', '2f', '31', '32', '37', '2e', '30', '2e', '30', '2e', '31', '3a', '35', '36', '30', '30', '14', '5e']}

I see that the message VIDEO_STREAM_INFORMATION number is 269, and it could be the reason of the error, but I can not fix it and I do not know why the almost same function work so well and I do not know how to change to MAVLink version2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions