Xcode 在c语言中开发类似iTunes的应用程序#
我需要用c语言开发一个应用程序,当iPhone连接到系统时,它可以自动检测到iPhone,并为iPhone文件系统读取特定文件。我基本上希望这个文件能自动从设备下载到电脑上。我使用了USBpcap工具,它建议iTunes使用某种XML格式连接到手机上。非常感谢任何帮助或见解。是否有任何第三方API的文档可以让我开始?有些应用程序可以复制iTunes的功能,例如 苹果是否提供任何协议或API 我一直在互联网上挖掘,找到了这个链接。 我还使用LibUsbDotNet库与usb设备()通信。有人能建议应该使用哪些端点吗 在我看来,我必须在windows应用程序中实现usbmuxd。它是一个多层协议。一定有一些实现usbmuxd的库(我不认为我必须自己实现协议) 我不太了解iTunes通信以及USB通信。我正在尽可能多地添加信息(当然是我在研发中提出的东西)。非常感谢您的帮助Xcode 在c语言中开发类似iTunes的应用程序#,xcode,cocoa-touch,c#-4.0,itunes-sdk,Xcode,Cocoa Touch,C# 4.0,Itunes Sdk,我需要用c语言开发一个应用程序,当iPhone连接到系统时,它可以自动检测到iPhone,并为iPhone文件系统读取特定文件。我基本上希望这个文件能自动从设备下载到电脑上。我使用了USBpcap工具,它建议iTunes使用某种XML格式连接到手机上。非常感谢任何帮助或见解。是否有任何第三方API的文档可以让我开始?有些应用程序可以复制iTunes的功能,例如 苹果是否提供任何协议或API 我一直在互联网上挖掘,找到了这个链接。 我还使用LibUsbDotNet库与usb设备()通信。有人能建议
public static DateTime LastDataEventDate = DateTime.Now;
public static UsbDevice MyUsbDevice;
#region SET YOUR USB Vendor and Product ID!
public static UsbDeviceFinder MyUsbFinder = new UsbDeviceFinder(1452, 4768);
#endregion
private void LibUSB()
{
ErrorCode ec = ErrorCode.None;
try
{
// Find and open the usb device.
MyUsbDevice = UsbDevice.OpenUsbDevice(MyUsbFinder);
// If the device is open and ready
if (MyUsbDevice == null)
throw new Exception("Device Not Found.");
// If this is a "whole" usb device (libusb-win32, linux libusb)
// it will have an IUsbDevice interface. If not (WinUSB) the
// variable will be null indicating this is an interface of a
// device.
IUsbDevice wholeUsbDevice = MyUsbDevice as IUsbDevice;
if (!ReferenceEquals(wholeUsbDevice, null))
{
// This is a "whole" USB device. Before it can be used,
// the desired configuration and interface must be selected.
// Select config #1
wholeUsbDevice.SetConfiguration(1);
// Claim interface #0.
wholeUsbDevice.ClaimInterface(0);
}
// open read endpoint 1.
UsbEndpointReader reader = MyUsbDevice.OpenEndpointReader(ReadEndpointID.Ep03);
// open write endpoint 1.
UsbEndpointWriter writer = MyUsbDevice.OpenEndpointWriter(WriteEndpointID.Ep02);
int bytesWritten;
ec = writer.Write(usbmux_header.GetBytes(), 2000, out bytesWritten);
if (ec != ErrorCode.None)
throw new Exception(UsbDevice.LastErrorString);
byte[] readBuffer = new byte[1024];
while (ec == ErrorCode.None)
{
int bytesRead;
// If the device hasn't sent data in the last 100 milliseconds,
// a timeout error (ec = IoTimedOut) will occur.
ec = reader.Read(readBuffer, 10000, out bytesRead);
if (ec == ErrorCode.Win32Error)
throw new Exception("port not open");
if (bytesRead == 0)
throw new Exception("No more bytes!");
// Write that output to the console.
Console.Write(Encoding.Default.GetString(readBuffer, 0, bytesRead));
}
}
catch (Exception ex)
{
Console.WriteLine();
Console.WriteLine((ec != ErrorCode.None ? ec + ":" : String.Empty) + ex.Message);
}
finally
{
if (MyUsbDevice != null)
{
if (MyUsbDevice.IsOpen)
{
// If this is a "whole" usb device (libusb-win32, linux libusb-1.0)
// it exposes an IUsbDevice interface. If not (WinUSB) the
// 'wholeUsbDevice' variable will be null indicating this is
// an interface of a device; it does not require or support
// configuration and interface selection.
IUsbDevice wholeUsbDevice = MyUsbDevice as IUsbDevice;
if (!ReferenceEquals(wholeUsbDevice, null))
{
// Release interface #0.
wholeUsbDevice.ReleaseInterface(0);
}
MyUsbDevice.Close();
}
MyUsbDevice = null;
// Free usb resources
UsbDevice.Exit();
}
}
}
class usbmux_header
{
public static UInt32 length = 10; // length of message, including header
public static UInt32 reserved = 0; // always zero
public static UInt32 type = 3; // message type
public static UInt32 tag = 2; // responses to this query will echo back this tag
public static byte[] GetBytes()
{
byte[] lgth = BitConverter.GetBytes(length);
byte[] res = BitConverter.GetBytes(reserved);
byte[] tpe = BitConverter.GetBytes(type);
byte[] tg = BitConverter.GetBytes(tag);
byte[] retArray = new byte[16];
lgth.CopyTo(retArray, 0);
res.CopyTo(retArray, 4);
tpe.CopyTo(retArray, 8);
tg.CopyTo(retArray, 12);
return retArray;
}
};
我一直在尝试向iPhone发送hello数据包字节,但我无法读取手机的任何响应。要使用ipod,您可以使用据我所知,一次只有一个客户端可以使用到iOS的USB连接。在macOS和Windows上,一个客户端是usbmux。该库将TCP连接多路复用到更高级别的客户端,包括iTunes、Photos和(在macOS上)开源peertalk库 因此,在Windows上,您不希望实现自己的usbmux,而是希望实现一个位于其之上的客户端,类似于peertalk。我还没有看到任何开源软件可以做到这一点,但许多开发人员已经用他们自己的专有软件实现了这一点 如果其他人有关于在Windows上使用usbmux的建议,我很想听听 -戴夫你可以用。它提供了一个C#API,可以使用PC连接到iOS设备 例如,要列出连接到PC的所有iOS设备,您可以运行以下操作:
ReadOnlyCollection<string> udids;
int count = 0;
var idevice = LibiMobileDevice.Instance.iDevice;
var lockdown = LibiMobileDevice.Instance.Lockdown;
var ret = idevice.idevice_get_device_list(out udids, ref count);
if (ret == iDeviceError.NoDevice)
{
// Not actually an error in our case
return;
}
ret.ThrowOnError();
// Get the device name
foreach (var udid in udids)
{
iDeviceHandle deviceHandle;
idevice.idevice_new(out deviceHandle, udid).ThrowOnError();
LockdownClientHandle lockdownHandle;
lockdown.lockdownd_client_new_with_handshake(deviceHandle, out lockdownHandle, "Quamotion").ThrowOnError();
string deviceName;
lockdown.lockdownd_get_device_name(lockdownHandle, out deviceName).ThrowOnError();
deviceHandle.Dispose();
lockdownHandle.Dispose();
}
ReadOnlyCollection udid;
整数计数=0;
var idevice=LibiMobileDevice.Instance.idevice;
var lockdown=LibiMobileDevice.Instance.lockdown;
var ret=idevice.idevice\u get\u device\u list(out udid,ref count);
if(ret==iDeviceError.NoDevice)
{
//在我们的案例中,这实际上不是一个错误
返回;
}
ret.ThrowOnError();
//获取设备名称
foreach(udid中的变量udid)
{
iDeviceHandle设备手柄;
idevice.idevice_new(out deviceHandle,udid).ThrowOnError();
锁止手柄锁止手柄;
锁定。通过握手(deviceHandle,out lockdownHandle,“Quamotion”)。ThrowOnError();
字符串设备名;
lockdown.lockdown_get_device_name(lockdownHandle,out deviceName).ThrowOnError();
deviceHandle.Dispose();
lockdownHandle.Dispose();
}
我也在尝试这样做。你运气好吗?