information

์กฐ์ข…๊ธฐ์˜ ํŽŒ์›จ์–ด ์ •๋ณด ์š”์ฒญ

from time import sleep

from e_drone.drone import *
from e_drone.protocol import *


if __name__ == '__main__':

    drone = Drone(False)
    drone.open()

    drone.sendRequest(DeviceType.Controller, DataType.Information)

    timeStart = time.time()

    while True:
        sleep(0.01)
        dataType = drone.check()
        
        if dataType == DataType.Information:
            information = drone.getData(DataType.Information)
            print("ModeUpdate: {0}".format(information.modeUpdate))
            print("ModelNumber: {0}".format(information.modelNumber))
            print("Version: {0}.{1}.{2} / {3} / 0x{3:08X}".format(
                information.version.major,
                information.version.minor,
                information.version.build,
                information.version.v))
            print("Release Date: {0}.{1}.{2}".format(
                information.year,
                information.month,
                information.day))
            break

        if time.time() > timeStart + 1:
            break

    drone.close()

์กฐ์ข…๊ธฐ์˜ ํŽŒ์›จ์–ด ์ •๋ณด ์š”์ฒญ(์ด๋ฒคํŠธ ํ•จ์ˆ˜ ๋“ฑ๋ก)

# ์กฐ์ข…๊ธฐ์˜ ํŽŒ์›จ์–ด ์ •๋ณด๋ฅผ ์š”์ฒญํ•˜๊ณ , ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ๋ฅผ ํ†ตํ•ด ์‘๋‹ต์„ ์ถœ๋ ฅํ•˜๋Š” ์˜ˆ์ œ
from time import sleep

from e_drone.drone import *
from e_drone.protocol import *


def eventInformation(information):
    print("eventInformation()")
    print("ModeUpdate: {0}".format(information.modeUpdate))
    print("ModelNumber: {0}".format(information.modelNumber))
    print("Version: {0}.{1}.{2} / {3} / 0x{3:08X}".format(
        information.version.major,
        information.version.minor,
        information.version.build,
        information.version.v))
    print("Release Date: {0}.{1}.{2}".format(
        information.year,
        information.month,
        information.day))


if __name__ == '__main__':

    drone = Drone()
    drone.open()

    # ์ด๋ฒคํŠธ ํ•ธ๋“ค๋ง ํ•จ์ˆ˜ ๋“ฑ๋ก
    drone.setEventHandler(DataType.Information, eventInformation)

    # Information ์ •๋ณด ์š”์ฒญ
    drone.sendRequest(DeviceType.Controller, DataType.Information)
    sleep(0.1)

    drone.close()

Last updated