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; }
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}; 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; }
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 = CameraBase.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); } } } }
static public byte[] ReadBytes(BaseMTPCamera cam, uint addr, uint readlength) { var res = cam.ExecuteReadDataEx(0xFE34, addr, readlength, 0, 0, 0); return res.Data; }