code: def set_stream_rates():
      '''set mavlink stream rates'''
      if (not msg_period.trigger() and
          mpstate.status.last_streamrate1 == mpstate.settings.streamrate and
          mpstate.status.last_streamrate2 == mpstate.settings.streamrate2):
          return
      mpstate.status.last_streamrate1 = mpstate.settings.streamrate
      mpstate.status.last_streamrate2 = mpstate.settings.streamrate2
      for master in mpstate.mav_master:
          if master.linknum == 0:
              rate = mpstate.settings.streamrate
          else:
              rate = mpstate.settings.streamrate2
          if rate != -1:
              master.mav.request_data_stream_send(mpstate.settings.target_system, mpstate.settings.target_component,
                                                  mavutil.mavlink.MAV_DATA_STREAM_ALL,
                                                  rate, 1f set_stream_rates():
      '''set mavlink stream rates'''
      if (not msg_period.trigger() and
          mpstate.status.last_streamrate1 == mpstate.settings.streamrate and
          mpstate.status.last_streamrate2 == mpstate.settings.streamrate2):
          return
      mpstate.status.last_streamrate1 = mpstate.settings.streamrate
      mpstate.status.last_streamrate2 = mpstate.settings.streamrate2
      for master in mpstate.mav_master:
          if master.linknum == 0:
              rate = mpstate.settings.streamrate
          else:
              rate = mpstate.settings.streamrate2
          if rate != -1:
              master.mav.request_data_stream_send(mpstate.settings.target_system, mpstate.settings.target_component,
                                                  mavutil.mavlink.MAV_DATA_STREAM_ALL,
                                                  rate, 1)
docs: set mavlink stream rates