How can I get DRI Drone Serial Number from AirSDK?

Maybe I missed it, but I am looking to pull the Drone Serial Number, sometimes called DRI, from the drone in AirSDK. Does that exist?

image

Hi @ohlarikd,

Please take a look at the Storage and persistence section of Airsdk documentation.

from a C or C++ service using the sys_prop_get() function from libputils :

#include <putils/properties.h>
...
char prop[SYS_PROP_VALUE_MAX];
sys_prop_get(“ro.factory.serial”, prop, "0");

Regards,
Axel

Thanks for the code snippet - we will try! When I click into Storage and Perstistence, I do not see this code or any reference to it at all - how would I see this info about ‘ro.factory.serlal’? OR how would we have known this answer?

I just change the code from the SD card storage part of the Storage and Perstistence section. All the properties values are not documented.

As mentioned in the first paragraph on SD card storage part, you can use the gprop command-line utility on the drone to obtain a list of all available properties. You must enable shell access before.

Regards,
Axel

Great - thank you, we shall investigate further. Much appreciated!

Derek

So we are using Python, can you please provide a way to get these properties from a python service?

Thanks!

Hi @ohlarikd,

import putils
import ctypes

def get_property_bytes(prop, default=b""):
    """Get system property PROP, or DEFAULT, as bytes

    PROP and DEFAULT must be bytes.

    Call putils.sys_prop_get with PROP and DEFAULT, and if the call is
    successful, return the stored value as bytes. Otherwise, return
    DEFAULT.
    """
    if not putils.sys_prop_is_available():
        return default
    key = putils.char_pointer_cast(prop)
    value = ctypes.create_string_buffer(92)  # SYS_PROP_VALUE_MAX
    default = putils.char_pointer_cast(default)
    ret = putils.sys_prop_get(key, value, default)
    if ret >= 0:
        return _cstring2bytes(value)
    else:
        return default

and you can use this function like this:

    def get_factory_serial(self):
        return _bytes2cstring(
            fsup.utils.get_property_bytes(b"ro.factory.serial", b"0")
        )

Regards,
Axel

This is VERY helpful - thank you Axel!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.