Inheritance: PTP.PTPSession
        private static CHDKPTPDevice CheckSupported(PTPDevice ptpdev)
        {
            var dev = ptpdev as CHDKPTPDevice;

            if (!dev.PTPSupported)
            {
                return dev;
            }

            try
            {
                if (!dev.Open())
                {
                    return dev;
                }

                var sess = new CHDKPTPSession(dev);
                sess.OpenSession();
                if (sess.CHDK_Version(out dev.CHDKVersionMajor, out dev.CHDKVersionMinor))
                {
                    if (dev.CHDKVersionMajor == CHDK_VERSION_MAJOR && dev.CHDKVersionMinor >= CHDK_VERSION_MINOR)
                    {
                        CHDK_ScriptSupport flags;
                        sess.CHDK_ScriptSupport(out flags);
                        if (flags.HasFlag(CHDK_ScriptSupport.PTP_CHDK_SCRIPT_SUPPORT_LUA))
                        {
                            dev.CHDKSupported = true;
                        }
                    }

                    sess.CloseSession();
                }
            }
            catch (PTPException)
            {
                // make sure CHDKSupported has not already been set
                dev.CHDKSupported = false;
            }
            finally
            {
                if (dev.IsOpen)
                {
                    dev.Close();
                }
            }

            return dev;
        }
Beispiel #2
0
        private static CHDKPTPDevice CheckSupported(PTPDevice ptpdev)
        {
            CHDKPTPDevice dev = ptpdev as CHDKPTPDevice;

            if (!dev.PTPSupported)
            {
                return(dev);
            }

            try
            {
                if (!dev.Open())
                {
                    return(dev);
                }

                CHDKPTPSession sess = new CHDKPTPSession(dev);
                sess.OpenSession();
                if (sess.CHDK_Version(out dev.CHDKVersionMajor, out dev.CHDKVersionMinor))
                {
                    if (dev.CHDKVersionMajor == CHDK_VERSION_MAJOR && dev.CHDKVersionMinor >= CHDK_VERSION_MINOR)
                    {
                        CHDK_ScriptSupport flags;
                        sess.CHDK_ScriptSupport(out flags);
                        if (flags.HasFlag(CHDK_ScriptSupport.PTP_CHDK_SCRIPT_SUPPORT_LUA))
                        {
                            dev.CHDKSupported = true;
                        }
                    }

                    sess.CloseSession();
                }
            }
            catch (PTPException)
            {
                // make sure CHDKSupported has not already been set
                dev.CHDKSupported = false;
            }
            finally
            {
                if (dev.IsOpen)
                {
                    dev.Close();
                }
            }

            return(dev);
        }
Beispiel #3
0
 public Session(CHDKPTPDevice dev)
 {
     _session = new CHDKPTPSession(dev);
 }