Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions py/mavsdk/mavsdk/cmavsdk_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ def _find_library() -> ctypes.CDLL:
Path.cwd() / "lib", # fallback
]

print(f"Searching for library on {platform}...")
print(f"Searching for library on {platform}...", file=sys.stderr)

for path in search_paths:
for name in names:
lib_path = path / name
if lib_path.exists():
try:
lib = ctypes.CDLL(str(lib_path))
print(f"✓ Loaded library: {lib_path}")
print(f"✓ Loaded library: {lib_path}", file=sys.stderr)
return lib
except OSError as e:
print(f"✗ Failed to load {lib_path}: {e}")
print(f"✗ Failed to load {lib_path}: {e}", file=sys.stderr)
continue

raise LibraryNotFoundError(f"Could not find cmavsdk library. Tried: {names}")
Expand Down
7 changes: 4 additions & 3 deletions py/mavsdk/mavsdk/logging.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Logging support for cmavsdk"""

import ctypes
import sys

from enum import IntEnum
from typing import Optional, Callable
Expand Down Expand Up @@ -40,9 +41,9 @@ def log_subscribe(callback: Callable[[LogLevel, str, Optional[str], int], bool])

Example:
def my_log_handler(level, message, file, line):
print(f"[{level.name}] {message}")
print(f"[{level.name}] {message}", file=sys.stderr)
if file:
print(f" at {file}:{line}")
print(f" at {file}:{line}", file=sys.stderr)
return True # Suppress default logging

log_subscribe(my_log_handler)
Expand All @@ -59,7 +60,7 @@ def c_callback(level: int, message: bytes, file: bytes, line: int, user_data):

return callback(level_enum, msg_str, file_str, line)
except Exception as e:
print(f"Error in log callback: {e}")
print(f"Error in log callback: {e}", file=sys.stderr)
return False

# Keep reference to prevent garbage collection
Expand Down
45 changes: 23 additions & 22 deletions py/mavsdk/mavsdk/plugins/action/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import atexit
import ctypes
import sys

from typing import Callable, Any
from enum import IntEnum
Expand Down Expand Up @@ -100,7 +101,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in arm callback: {e}")
print(f"Error in arm callback: {e}", file=sys.stderr)

cb = ArmCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -134,7 +135,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in arm_force callback: {e}")
print(f"Error in arm_force callback: {e}", file=sys.stderr)

cb = ArmForceCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -166,7 +167,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in disarm callback: {e}")
print(f"Error in disarm callback: {e}", file=sys.stderr)

cb = DisarmCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -200,7 +201,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in takeoff callback: {e}")
print(f"Error in takeoff callback: {e}", file=sys.stderr)

cb = TakeoffCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -231,7 +232,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in land callback: {e}")
print(f"Error in land callback: {e}", file=sys.stderr)

cb = LandCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -262,7 +263,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in reboot callback: {e}")
print(f"Error in reboot callback: {e}", file=sys.stderr)

cb = RebootCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -295,7 +296,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in shutdown callback: {e}")
print(f"Error in shutdown callback: {e}", file=sys.stderr)

cb = ShutdownCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -326,7 +327,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in terminate callback: {e}")
print(f"Error in terminate callback: {e}", file=sys.stderr)

cb = TerminateCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -358,7 +359,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in kill callback: {e}")
print(f"Error in kill callback: {e}", file=sys.stderr)

cb = KillCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -391,7 +392,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in return_to_launch callback: {e}")
print(f"Error in return_to_launch callback: {e}", file=sys.stderr)

cb = ReturnToLaunchCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -433,7 +434,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in goto_location callback: {e}")
print(f"Error in goto_location callback: {e}", file=sys.stderr)

cb = GotoLocationCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -486,7 +487,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in do_orbit callback: {e}")
print(f"Error in do_orbit callback: {e}", file=sys.stderr)

cb = DoOrbitCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -545,7 +546,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in hold callback: {e}")
print(f"Error in hold callback: {e}", file=sys.stderr)

cb = HoldCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -578,7 +579,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in set_actuator callback: {e}")
print(f"Error in set_actuator callback: {e}", file=sys.stderr)

cb = SetActuatorCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -614,7 +615,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in set_relay callback: {e}")
print(f"Error in set_relay callback: {e}", file=sys.stderr)

cb = SetRelayCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -649,7 +650,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in transition_to_fixedwing callback: {e}")
print(f"Error in transition_to_fixedwing callback: {e}", file=sys.stderr)

cb = TransitionToFixedwingCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -684,7 +685,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in transition_to_multicopter callback: {e}")
print(f"Error in transition_to_multicopter callback: {e}", file=sys.stderr)

cb = TransitionToMulticopterCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -715,7 +716,7 @@ def c_callback(result, c_data, ud):
callback(py_result, py_data, user_data)

except Exception as e:
print(f"Error in get_takeoff_altitude callback: {e}")
print(f"Error in get_takeoff_altitude callback: {e}", file=sys.stderr)

cb = GetTakeoffAltitudeCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -748,7 +749,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in set_takeoff_altitude callback: {e}")
print(f"Error in set_takeoff_altitude callback: {e}", file=sys.stderr)

cb = SetTakeoffAltitudeCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -784,7 +785,7 @@ def c_callback(result, c_data, ud):
callback(py_result, py_data, user_data)

except Exception as e:
print(f"Error in get_return_to_launch_altitude callback: {e}")
print(f"Error in get_return_to_launch_altitude callback: {e}", file=sys.stderr)

cb = GetReturnToLaunchAltitudeCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -819,7 +820,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in set_return_to_launch_altitude callback: {e}")
print(f"Error in set_return_to_launch_altitude callback: {e}", file=sys.stderr)

cb = SetReturnToLaunchAltitudeCallback(c_callback)
self._callbacks.append(cb)
Expand Down Expand Up @@ -856,7 +857,7 @@ def c_callback(result, ud):
callback(py_result, user_data)

except Exception as e:
print(f"Error in set_current_speed callback: {e}")
print(f"Error in set_current_speed callback: {e}", file=sys.stderr)

cb = SetCurrentSpeedCallback(c_callback)
self._callbacks.append(cb)
Expand Down
15 changes: 8 additions & 7 deletions py/mavsdk/mavsdk/plugins/action_server/action_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import atexit
import ctypes
import sys

from typing import Callable, Any
from enum import IntEnum
Expand Down Expand Up @@ -222,7 +223,7 @@ def c_callback(result, c_data, ud):
callback(py_result, py_data, user_data)

except Exception as e:
print(f"Error in arm_disarm callback: {e}")
print(f"Error in arm_disarm callback: {e}", file=sys.stderr)

cb = ArmDisarmCallback(c_callback)
self._callbacks.append(cb)
Expand All @@ -247,7 +248,7 @@ def c_callback(result, c_data, ud):
callback(py_result, py_data, user_data)

except Exception as e:
print(f"Error in flight_mode_change callback: {e}")
print(f"Error in flight_mode_change callback: {e}", file=sys.stderr)

cb = FlightModeChangeCallback(c_callback)
self._callbacks.append(cb)
Expand All @@ -274,7 +275,7 @@ def c_callback(result, c_data, ud):
callback(py_result, py_data, user_data)

except Exception as e:
print(f"Error in takeoff callback: {e}")
print(f"Error in takeoff callback: {e}", file=sys.stderr)

cb = TakeoffCallback(c_callback)
self._callbacks.append(cb)
Expand All @@ -297,7 +298,7 @@ def c_callback(result, c_data, ud):
callback(py_result, py_data, user_data)

except Exception as e:
print(f"Error in land callback: {e}")
print(f"Error in land callback: {e}", file=sys.stderr)

cb = LandCallback(c_callback)
self._callbacks.append(cb)
Expand All @@ -320,7 +321,7 @@ def c_callback(result, c_data, ud):
callback(py_result, py_data, user_data)

except Exception as e:
print(f"Error in reboot callback: {e}")
print(f"Error in reboot callback: {e}", file=sys.stderr)

cb = RebootCallback(c_callback)
self._callbacks.append(cb)
Expand All @@ -343,7 +344,7 @@ def c_callback(result, c_data, ud):
callback(py_result, py_data, user_data)

except Exception as e:
print(f"Error in shutdown callback: {e}")
print(f"Error in shutdown callback: {e}", file=sys.stderr)

cb = ShutdownCallback(c_callback)
self._callbacks.append(cb)
Expand All @@ -366,7 +367,7 @@ def c_callback(result, c_data, ud):
callback(py_result, py_data, user_data)

except Exception as e:
print(f"Error in terminate callback: {e}")
print(f"Error in terminate callback: {e}", file=sys.stderr)

cb = TerminateCallback(c_callback)
self._callbacks.append(cb)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import atexit
import ctypes
import sys

from typing import Callable, Any
from enum import IntEnum
Expand Down Expand Up @@ -79,7 +80,7 @@ def c_callback(c_data, ud):
callback(py_data, user_data)

except Exception as e:
print(f"Error in arm_authorization callback: {e}")
print(f"Error in arm_authorization callback: {e}", file=sys.stderr)

cb = ArmAuthorizationCallback(c_callback)
self._callbacks.append(cb)
Expand Down
11 changes: 6 additions & 5 deletions py/mavsdk/mavsdk/plugins/calibration/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import atexit
import ctypes
import sys

from typing import Callable, Any
from enum import IntEnum
Expand Down Expand Up @@ -137,7 +138,7 @@ def c_callback(result, c_data, ud):
callback(py_result, py_data, user_data)

except Exception as e:
print(f"Error in calibrate_gyro callback: {e}")
print(f"Error in calibrate_gyro callback: {e}", file=sys.stderr)

cb = CalibrateGyroCallback(c_callback)
self._callbacks.append(cb)
Expand All @@ -158,7 +159,7 @@ def c_callback(result, c_data, ud):
callback(py_result, py_data, user_data)

except Exception as e:
print(f"Error in calibrate_accelerometer callback: {e}")
print(f"Error in calibrate_accelerometer callback: {e}", file=sys.stderr)

cb = CalibrateAccelerometerCallback(c_callback)
self._callbacks.append(cb)
Expand All @@ -181,7 +182,7 @@ def c_callback(result, c_data, ud):
callback(py_result, py_data, user_data)

except Exception as e:
print(f"Error in calibrate_magnetometer callback: {e}")
print(f"Error in calibrate_magnetometer callback: {e}", file=sys.stderr)

cb = CalibrateMagnetometerCallback(c_callback)
self._callbacks.append(cb)
Expand All @@ -204,7 +205,7 @@ def c_callback(result, c_data, ud):
callback(py_result, py_data, user_data)

except Exception as e:
print(f"Error in calibrate_level_horizon callback: {e}")
print(f"Error in calibrate_level_horizon callback: {e}", file=sys.stderr)

cb = CalibrateLevelHorizonCallback(c_callback)
self._callbacks.append(cb)
Expand All @@ -229,7 +230,7 @@ def c_callback(result, c_data, ud):
callback(py_result, py_data, user_data)

except Exception as e:
print(f"Error in calibrate_gimbal_accelerometer callback: {e}")
print(f"Error in calibrate_gimbal_accelerometer callback: {e}", file=sys.stderr)

cb = CalibrateGimbalAccelerometerCallback(c_callback)
self._callbacks.append(cb)
Expand Down
Loading
Loading