Exemple #1
0
        public bool InitilizeCamera()
        {
            if (deviceId == "")
            {
                StatusMessage = "Nikon Camera not present";
                return(false);
            }

            DeviceDescriptor descriptor = new DeviceDescriptor {
                WpdId = deviceId
            };

            cam = new BaseMTPCamera();
            if (cam.Init(descriptor) == false)
            {
                StatusMessage = "Failed to Initilize BaseMTPCamera";
                return(false);
            }

            var rep = cam.ExecuteReadDataEx(PtpCommands.MTP_OPERATION_GET_DEVICE_INFO);

            if (rep.ErrorCode != ErrorCodes.MTP_OK)
            {
                StatusMessage = "Failed to GET_DEVICE_INFO)";
                return(false);
            }

            ModelNumber    = PtpCommands.Get_CameraModel(this);
            FirmwareNumber = PtpCommands.Get_Version_FirmB(this);
            return(true);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            EepromChecko();
            return;

            string camid = FindNikonCamera();

            if (camid == "")
            {
                Debug.WriteLine("** Failed to find Nikon Camera");
                Console.WriteLine("Failed to find Nikon Camera");
                return;
            }

            SN = camid.Split('#')[2];

            DeviceDescriptor descriptor = new DeviceDescriptor {
                WpdId = camid
            };

            cam = new BaseMTPCamera();
            bool i   = cam.Init(descriptor);
            var  rep = cam.ExecuteReadDataEx(MTP_OPERATION_GET_DEVICE_INFO);

            if (rep.ErrorCode == ErrorCodes.MTP_OK)
            {
                //DumpTests();

                Dump_Eeprom_LANG_Test1(SN);
            }
        }
        public bool DoChecks(BaseMTPCamera cam)
        {
            var res = cam.ExecuteReadDataEx(0xFE34, OC_Fx31_ptr, 0x4, 0, 0, 0);

            uint OC_Fx31_base_check = (uint)((res.Data[0] << 24) | (res.Data[1] << 16) | (res.Data[2] << 8) | res.Data[3]);

            return(OC_Fx31_base_check == OC_Fx31_base);
        }
Exemple #4
0
        public bool DoChecks(BaseMTPCamera cam)
        {
            var res = ReadBytes(cam, OC_Fx31_ptr, 0x4);

            uint OC_Fx31_base_check = (uint)((res[0] << 24) | (res[1] << 16) | (res[2] << 8) | res[3]);

            return(OC_Fx31_base_check == OC_Fx31_base);
        }
        public void WriteBytes_FD31(BaseMTPCamera cam, uint OC_Fx31_base, uint addr, byte[] data)
        {
            uint datalen = (uint)data.Length;

            byte[] tmp_data = new byte[800];
            for (uint i = 0; i < datalen; i += 800)
            {
                uint tmp_len = Math.Min(0x800, datalen - i);
                Array.Copy(data, i, tmp_data, 0, tmp_len);

                cam.SetProperty(0xFD31, tmp_data, (addr + i) - OC_Fx31_base, tmp_len, 0);
            }
        }
Exemple #6
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            DeviceInfo = new XmlDeviceData();
            SelectDevice wnd = new SelectDevice();

            wnd.ShowDialog();
            if (wnd.DialogResult == true && wnd.SelectedDevice != null)
            {
                try
                {
                    SelectedDevice = wnd.SelectedDevice;
                    DeviceDescriptor descriptor = new DeviceDescriptor {
                        WpdId = SelectedDevice.DeviceId
                    };
                    MtpProtocol device = new MtpProtocol(descriptor.WpdId);
                    device.ConnectToDevice("MTPTester", 1, 0);
                    descriptor.StillImageDevice = device;
                    MTPCamera = new BaseMTPCamera();
                    MTPCamera.Init(descriptor);
                    LoadDeviceData(MTPCamera.ExecuteReadDataEx(0x1001));
                    //LoadDeviceData(MTPCamera.ExecuteReadDataEx(0x9108));

                    PopulateProperties();
                }
                catch (DeviceException exception)
                {
                    MessageBox.Show("Error getting device information" + exception.Message);
                }
                catch (Exception exception)
                {
                    MessageBox.Show("General error" + exception.Message);
                }
                if (DefaultDeviceInfo != null)
                {
                    foreach (XmlCommandDescriptor command in DeviceInfo.AvaiableCommands)
                    {
                        command.Name = DefaultDeviceInfo.GetCommandName(command.Code);
                    }
                    foreach (XmlEventDescriptor avaiableEvent in DeviceInfo.AvaiableEvents)
                    {
                        avaiableEvent.Name = DefaultDeviceInfo.GetEventName(avaiableEvent.Code);
                    }
                    foreach (XmlPropertyDescriptor property in DeviceInfo.AvaiableProperties)
                    {
                        property.Name = DefaultDeviceInfo.GetPropName(property.Code);
                    }
                }
                InitUi();
            }
        }
        public byte[] ReadBytes_FE31(BaseMTPCamera cam, uint OC_Fx31_base, uint addr, uint readlength)
        {
            uint step = 0x800;

            byte[] data = new byte[readlength];

            for (uint i = 0; i < readlength; i += step)
            {
                uint tmp_len = Math.Min(step, readlength - i);
                var  res     = cam.ExecuteReadDataEx(0xFE31, (addr + i) - OC_Fx31_base, tmp_len, 0, 0, 0);
                Array.Copy(res.Data, 0, data, i, tmp_len);
            }

            return(data);
        }
 private void btn_get_value_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (MTPCamera == null || MTPCamera.IsConnected == false)
         {
             DeviceInfo = new XmlDeviceData();
             SelectDevice wnd = new SelectDevice();
             wnd.ShowDialog();
             if (wnd.DialogResult == true && wnd.SelectedDevice != null)
             {
                 SelectedDevice = wnd.SelectedDevice;
                 DeviceDescriptor descriptor = new DeviceDescriptor {
                     WpdId = SelectedDevice.DeviceId
                 };
                 MTPCamera = new BaseMTPCamera();
                 MTPCamera.Init(descriptor);
             }
             else
             {
                 return;
             }
         }
         XmlPropertyDescriptor propertyDescriptor = lst_prop.SelectedItem as XmlPropertyDescriptor;
         MTPDataResponse       resp = MTPCamera.ExecuteReadDataEx(BaseMTPCamera.CONST_CMD_GetDevicePropValue,
                                                                  (int)propertyDescriptor.Code, -1);
         long             val      = GetValue(resp, 0, GetDataLength(propertyDescriptor.DataType));
         XmlPropertyValue selected = null;
         foreach (XmlPropertyValue xmlPropertyValue in propertyDescriptor.Values)
         {
             if (xmlPropertyValue.Value == val)
             {
                 selected = xmlPropertyValue;
             }
         }
         if (selected != null)
         {
             lst_values.BeginInit();
             lst_values.SelectedItem = selected;
             lst_values.EndInit();
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show("Error to get value " + exception.Message);
     }
 }
Exemple #9
0
        public static bool InitilizeCamera(string wpdId)
        {
            DeviceDescriptor descriptor = new DeviceDescriptor {
                WpdId = wpdId
            };
            var  cam = new BaseMTPCamera();
            bool i   = cam.Init(descriptor);
            var  rep = cam.ExecuteReadDataEx(PtpCommands.MTP_OPERATION_GET_DEVICE_INFO);

            if (rep.ErrorCode != ErrorCodes.MTP_OK)
            {
                //LogIt("Failed to initialise");
                return(false);
            }

            return(false);
            //var version = Get_Version_FirmB();
            //var model = Get_CameraModel();
        }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (MTPCamera == null || MTPCamera.IsConnected == false)
         {
             DeviceInfo = new XmlDeviceData();
             SelectDevice wnd = new SelectDevice();
             wnd.ShowDialog();
             if (wnd.DialogResult == true && wnd.SelectedDevice != null)
             {
                 SelectedDevice = wnd.SelectedDevice;
                 DeviceDescriptor descriptor = new DeviceDescriptor {
                     WpdId = SelectedDevice.DeviceId
                 };
                 MTPCamera = new BaseMTPCamera();
                 MTPCamera.Init(descriptor);
             }
             else
             {
                 return;
             }
         }
         XmlPropertyValue      property           = lst_values.SelectedItem as XmlPropertyValue;
         XmlPropertyDescriptor propertyDescriptor = lst_prop.SelectedItem as XmlPropertyDescriptor;
         if (property != null)
         {
             MTPCamera.SetProperty(BaseMTPCamera.CONST_CMD_SetDevicePropValue,
                                   BitConverter.GetBytes(property.Value), (int)propertyDescriptor.Code, -1);
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show("Error set property " + exception.Message);
     }
 }
Exemple #11
0
 public byte[] ReadBytes(BaseMTPCamera cam, uint addr, uint readlength)
 {
     return(ReadBytes_FE31(cam, OC_Fx31_base, addr, readlength));
 }
Exemple #12
0
        static public byte[] ReadBytes(BaseMTPCamera cam, uint addr, uint readlength)
        {
            var res = cam.ExecuteReadDataEx(0xFE34, addr, readlength, 0, 0, 0);

            return(res.Data);
        }
Exemple #13
0
        static void Main(string[] args)
        {
            string camid = FindNikonCamera();

            if (camid == "")
            {
                Debug.WriteLine("** Failed to find Nikon Camera");
                Console.WriteLine("Failed to find Nikon Camera");
                return;
            }

            SN = camid.Split('#')[2];

            DeviceDescriptor descriptor = new DeviceDescriptor {
                WpdId = camid
            };

            cam = new BaseMTPCamera();
            bool i   = cam.Init(descriptor);
            var  rep = cam.ExecuteReadDataEx(MTP_OPERATION_GET_DEVICE_INFO);

            if (rep.ErrorCode == ErrorCodes.MTP_OK)
            {
                if (Directory.Exists(path) == false)
                {
                    Directory.CreateDirectory(path);
                }

                EnterServiceMode();

                //FR_BKT_Test();

                if (false)
                //int count = 0;
                //while (Console.KeyAvailable == false)
                {
                    //FR_Dump_6700xxxx();
                    //FR_D7000_alter_blacklevel_B();

                    //FR_D7000_alter_blacklevel_B();

                    //Tmp19_DisablesDefectProcessing_Set(true);

                    //cam.SetProperty(0xD015, new byte[] { 0x01 }, 0, 0);
                    //cam.SetProperty(0x5010, new byte[] { 0x00, 0x00 }, 0, 0);
                    //cam.SetProperty(0xD10B, new byte[] { 0x01 }, 0, 0);
                    //cam.SetProperty(0x5004, new byte[] { 0x04 }, 0, 0);
                    ////FR_FC46_Compression(1);

                    //cam.SetProperty(0xd149, new byte[] { 0x01 }, 0, 0);
                    //cam.SetProperty(0xd054, new byte[] { 0x00 }, 0, 0);
                    //cam.SetProperty(0xd070, new byte[] { 0x00 }, 0, 0);

                    //FR_FC44_Overscan(1);

                    //cam.SetProperty(0xFD31, new byte[] { 0x00, 0x9C, 0x00, 0x01, 0x20, 0x00 }, 0x2176, 6, 0);

                    //byte[] iso = { 0xC0, 0xEF, 0xFC, 0x0E, 0xFC, 0x0E, 0xFC, 0x0E };
                    //cam.SetProperty(0xFD31, iso, 0xC90A, 8, 0);

                    //Thread.Sleep(1 * 1000);
                    //Tmp19_CMD_475D(50, 120);
                    //Thread.Sleep(3 * 1000);
                    //Tmp19_DisablesDefectProcessing_Set(false);

                    //Tmp19_Resume();
                    //Console.WriteLine("{0}", ++count);
                }


                // Step 1
                //Console.WriteLine("Dump 0x00xxxxxx");
                //FR_Dump_00xxxxxx();
                //Console.WriteLine("Dump 0x9xxxxxxx");
                //FR_Dump_9xxxxxxx();

                // Step 2
                //Console.WriteLine("Dump All");
                //FR_Dump_all2();

                //Tmp19_DumpEeprom();



//simeon HDMI testing

                //FR_test_USB_offbit();
                FR_Set04Ram_SetBit(0x14, 0x01); // Liveview auto off timer off.
                FR_Set04Ram_SetBit(0x16, 0x02); // Liveview raw save.

                //FR_Set04Ram_SetBit(0x16, 0x08); // ??

                //FR_FindMemChange();

                //FR_FC44_Overscan(1);

                //FR_Set04Ram_SetBit(0x07, 0x01); // LiveView Clean LCD

                //FR_D7000_dump_button_bits();
                //FR_Set_LED_test();

                //FR_D7000_alter_blacklevel();
                //FR_D7000_alter_iso_tab();
                //FR_D7000_alter_vid_tab();

                FR_USB_ClearOnBit();

                //FR_Set0B_b01b08();
                //FR_Set0B_b01b08_clear();
                //FR_StartLiveView();
                //FR_StartMovie();
                //Thread.Sleep(10 * 1000);
                //FR_EndLiveView();

                //ScanForServiceFunctions();
                //FR_FindMemChange();
                //FR_Dump_all2();
                //FR_Dump_all_via_FE31();
                //FR_Dump_00xxxxxx();
                //FR_Dump_01xxxxxx();
                //FR_Dump_8xxxxxxx();

                //Tmp19_Suspend();

                //Tmp19_Dump_ADCTab();
                //Tmp19_Dump_FFxxxx();
                //Tmp19_Dump_FF6A5C();

                //var va = Tmp19_Cmd_4152(0xFF5FDC, 0x20);

                //FR_FDE1_test();
                //FR_StartLiveView();
                //FR_StartMovie();

                //FR_FDE1_test();

                //FR_LiveView_hack();

                //Tmp19_Resume();
                //ExitServiceMode();
            }
        }
Exemple #14
0
 public bool DoChecks(BaseMTPCamera cam)
 {
     return(true);
 }
        static void Main(string[] args)
        {
            LogIt("Nikon Flags v1.1");

            string camid = FindNikonCamera();

            if (camid == "")
            {
                LogIt("Failed to find Nikon Camera");
                return;
            }


            SN = camid.Split('#')[2];

            DeviceDescriptor descriptor = new DeviceDescriptor {
                WpdId = camid
            };

            cam = new BaseMTPCamera();
            bool i   = cam.Init(descriptor);
            var  rep = cam.ExecuteReadDataEx(MTP_OPERATION_GET_DEVICE_INFO);

            if (rep.ErrorCode != ErrorCodes.MTP_OK)
            {
                var s = "Failed to initialise";
                LogIt(s);
                return;
            }

            var version = Get_Version_FirmB();
            var model   = Get_CameraModel();

            var cam_obj = GetCameraObject(model, version);

            LogIt(model);
            LogIt(version);

            if (cam_obj == null)
            {
                var s = "Camera model/version not recognised, please email: [email protected] with the details";

                LogIt(s);
                return;
            }

            if (cam_obj.DoChecks(cam) == false)
            {
                var s = "Camera model/version checks failed, please email: [email protected] with the details";

                LogIt(s);
                return;
            }

            var flagAddr = cam_obj.GetKnownAddresss(KnownAddressList.Set04Ram);
            var flagLen  = cam_obj.GetKnownLenght(KnownAddressList.Set04Ram);

            //var flagAddr = cam_obj.GetKnownAddresss(KnownAddressList.Set26);
            //var flagLen = cam_obj.GetKnownLenght(KnownAddressList.Set26);

            LogIt("");
            LogIt("Flag Opp [Value]");

            LogIt("   Flag - byte between 0 - 0x{0:X} inclusive", flagLen - 1);
            LogIt("   Opp - A and, O or, C clear, D display, Q quit (no flag needed)");
            LogIt("   Value - hex value used in A, O, C operations");
            LogIt(" '0 A 0x01' will apply AND 0x01 with currnet set04ram[0x00]");
            LogIt(" '0x12 O 0x10' will apply OR 0x10 with current set04ram[0x12]");
            LogIt(" '0x11 C 0x01' will apply AND 0xFE (~0x01), aka clear current set04ram[0x11]");
            LogIt(" '15 D' will display current set04ram[0x15]");

            uint offset = 0;

            while (offset < flagLen)
            {
                var line  = Console.ReadLine().ToLower().Trim();
                var parts = line.Split(' ');

                if (line == "q")
                {
                    break;
                }

                if (parts.Length < 2)
                {
                    continue;
                }
                var a = parts[0].ToLower().Trim();
                if (a.StartsWith("0x"))
                {
                    a = a.Substring(2);
                }
                if (uint.TryParse(a, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out offset) &&
                    offset < flagLen)
                {
                    var b = parts[1].ToLower().Trim();
                    if (b.Length >= 1)
                    {
                        var opp = b[0];
                        if (opp != 'a' && opp != 'o' && opp != 'c' && opp != 'd')
                        {
                            LogIt("Bad operation character.");
                            break;
                        }

                        byte value = 0;
                        if (opp == 'a' || opp == 'o' || opp == 'c')
                        {
                            if (parts.Length != 3)
                            {
                                LogIt("Value missing");
                                continue;
                            }

                            var c = parts[2].ToLower().Trim();
                            if (c.StartsWith("0x"))
                            {
                                c = c.Substring(2);
                            }

                            if (byte.TryParse(c, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out value) == false)
                            {
                                LogIt("Bad value input");
                                continue;
                            }
                        }

                        var data = cam_obj.ReadBytes(cam, flagAddr + offset, 1);

                        if (data.Length != 1)
                        {
                            LogIt("Bad data read.");
                            break;
                        }

                        if (opp == 'd')
                        {
                            LogIt("Set04ram[0x{0:X}] = 0x{1:X}", offset, data[0]);
                            continue;
                        }

                        if (opp == 'a')
                        {
                            data[0] &= value;
                        }

                        if (opp == 'o')
                        {
                            data[0] |= value;
                        }

                        if (opp == 'c')
                        {
                            data[0] &= (byte)(~value);
                        }

                        LogIt("write: Set04ram[0x{0:X}] = 0x{1:X}", offset, data[0]);
                        cam_obj.WriteBytes(cam, flagAddr + offset, data);
                    }
                }
            }
        }
Exemple #16
0
 public byte[] ReadBytes(BaseMTPCamera cam, uint addr, uint readlength)
 {
     return(ReadBytes_FE34(cam, addr, readlength));
 }
 public void WriteBytes_FD34(BaseMTPCamera cam, uint addr, byte[] data)
 {
     cam.SetProperty(0xFD34, data, addr, (uint)data.Length, 0);
 }
Exemple #18
0
 public void WriteBytes(BaseMTPCamera cam, uint addr, byte[] data)
 {
     WriteBytes_FD31(cam, OC_Fx31_base, addr, data);
 }
Exemple #19
0
 public void WriteBytes(BaseMTPCamera cam, uint addr, byte[] data)
 {
     WriteBytes_FD34(cam, addr, data);
 }