def getMtpDeviceInfo():
mtpTcpCmdResult = mtpwifi.execMtpOp(g.socketPrimary, MTP_OP_GetDeviceInfo)
mtpDeviceInfo = parseMtpDeviceInfo(mtpTcpCmdResult.dataReceived)
if g.mtpDeviceInfo:
# this is a retry invocation. make sure we're talking with the same camera as before
if mtpDeviceInfo != g.mtpDeviceInfo:
applog_e("Discovered different camera during retry invocation. Orig camera was Model \"{:s}\", S/N \":{:s}\", New camera is \"{:s}\", S/N \":{:s}\"".format(\
g.mtpDeviceInfo.modelStr, g.mtpDeviceInfo.serialNumberStr, mtpDeviceInfo.modelStr, mtpDeviceInfo.serialNumberStr))
sys.exit(ERRNO_DIFFERENT_CAMREA_DURING_RETRY)
g.mtpDeviceInfo = mtpDeviceInfo
applog_d(g.mtpDeviceInfo)
#
# determine make of camera for use in any make-specific logic in our app
#
makeStrUpper = g.mtpDeviceInfo.manufacturerStr.upper()
if makeStrUpper.find("NIKON") != -1:
g.cameraMake = CAMERA_MAKE_NIKON
elif makeStrUpper.find("CANON") != -1:
g.cameraMake = CAMERA_MAKE_CANON
elif makeStrUpper.find("SONY") != -1:
g.cameraMake = CAMERA_MAKE_SONY
else:
g.cameraMake = CAMERA_MAKE_UNDETERMINED
#
# set any program options/behavior that is specific to the make of the camera
#
processCameraMakeDetermination()
#
# build path (dir + rootfilename) that will serve as the template for all metadata
# files we create and store locally. this name needs to be unique to the camera
# attached and locatable on future invocations, so we use a combination of the camera
# model and serial number
#
g.cameraLocalMetadataPathAndRootName = os.path.join(g.appDataDir, "{:s}-SN{:s}".format(g.mtpDeviceInfo.modelStr, g.mtpDeviceInfo.serialNumberStr))
applog_i("Camera Model \"{:s}\", S/N \"{:s}\"".format(g.mtpDeviceInfo.modelStr, g.mtpDeviceInfo.serialNumberStr))
#
# gets the slot index (1 or 2) from an MTP storage ID
#
评论列表
文章目录