paparazzi / pprzlink

Message and communication library for the Paparazzi UAV system
Other
24 stars 55 forks source link

Add request messages #122

Closed MJafarMashhadi closed 4 years ago

MJafarMashhadi commented 4 years ago

IvyMessagesInterface now has a send_request method that implements advanced request mechanism.

Example:

>>> from pprzlink import ivy
... _ivy = ivy.IvyMessagesInterface(agent_name='MyTestAgent', start_ivy=True)

>>> _ivy.send_request('ground', 'AIRCRAFTS', callback=lambda *args: print(*args))
2  # return from send_request
0 ground.AIRCRAFTS {ac_list: ['14']}  # Callback being executed

>>> _ivy.send_request('ground', 'CONFIG', callback=lambda *args: print(*args), ac_id=14)
2
14 ground.CONFIG {ac_id : 14, flight_plan : file:///home/mjafar/Documents/paparazzi/var/aircrafts/Microjet/flight_plan.xml, airframe : file:///home/mjafar/Documents/paparazzi/conf/airframes/examples/microjet_lisa_m.xml, radio : file:///home/mjafar/Documents/paparazzi/conf/radios/cockpitMM.xml, settings : file:///home/mjafar/Documents/paparazzi/var/aircrafts/Microjet/settings.xml, default_gui_color : #6293ba, ac_name : Microjet}
gautierhattenberger commented 4 years ago

@MJafarMashhadi This is looking good and a very useful addition. For the ocaml implementation, we also have an 'answerer' that you can set as the "other side" of the send_request function (https://github.com/paparazzi/pprzlink/blob/master/lib/v2.0/ocaml/pprzLink.ml#L789). Do you think you could add that as well ? If you don't have the time, this might be done later as well.

MJafarMashhadi commented 4 years ago

Thanks! Yeah I could do that, it's not that difficult. Should I add it here or open another PR?

gautierhattenberger commented 4 years ago

It's fine to do it in this PR, thanks again

MJafarMashhadi commented 4 years ago

Sure, I'll let you know when I'm done

MJafarMashhadi commented 4 years ago

@gautierhattenberger I'm done, please check when you could.

MJafarMashhadi commented 4 years ago

@gautierhattenberger Hi again, I found a small bug in send_request. I didn't test it after adding the request answerer method which changed a parameter in the callback. Can it be merged again? I'll have to open another pull request otherwise. I wish we had more tests!

MJafarMashhadi commented 4 years ago

Opened a new PR