iOS (iPhone/iPad) 中的串行或 HID (usb) 通信

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21285841/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 23:12:56  来源:igfitidea点击:

Serial or HID (usb) Communication in iOS (iPhone/iPad)

iosiphoneobjective-chidftdi

提问by Usman Awan

I want to get data from glucose meter devices by connecting into iPhone or iPad devices. I have different vendors glucose meters some uses simple HID interface for communicate and other uses serial communication.

我想通过连接到 iPhone 或 iPad 设备从血糖仪设备获取数据。我有不同的供应商血糖仪,一些使用简单的 HID 接口进行通信,其他使用串行通信。

These are the two possible ways of communication:

这是两种可能的通信方式:

  • USB to 30-Pin connector.
  • 3.5 Hyman to 30-Pin Connector.
  • USB 转 30 针连接器。
  • 3.5 插孔转 30 针连接器。

USB or 3.5 Hyman will be connected to glucose meter and 30 pin connector will be attached with iDevice.

USB 或 3.5 插孔将连接到血糖仪,30 针连接器将与 iDevice 相连。

After having hours of research I did not find much help on internet for iOS specific.

经过数小时的研究,我在互联网上没有找到针对 iOS 的太多帮助。

I do find ORSSerialPort but I think it is for OS X apps only.

我确实找到了 ORSSerialPort,但我认为它仅适用于 OS X 应用程序。

There is RedPark serial Cable but that is for RS232 to 30-Pin communication and secondly that can be only used in internal projects. I want to sell my application on Apple Store.

有 RedPark 串行电缆,但用于 RS232 到 30 针通信,其次只能用于内部项目。我想在 Apple Store 上出售我的应用程序。

Someone also was discussing about using IOKit framework. We can communicate with iDevie but that is private framework.

也有人在讨论使用IOKit框架。我们可以与 iDevie 通信,但那是私有框架。

Someone help me with this issue or let me know if that is even possible in iOS application.

有人帮我解决这个问题,或者让我知道这在 iOS 应用程序中是否可行。

Do Apple have any consideration on this type of working?

Apple 是否考虑过这种类型的工作?

采纳答案by Prince Agrawal

An iOS device can talk to external devices by following means of communications only:

iOS 设备只能通过以下通信方式与外部设备通话:

  1. Wifi
  2. Bluetooth
  3. GPRS &
  4. GSM
  5. USB (Don't exactly know what it is called)
  1. 无线上网
  2. 蓝牙
  3. GPRS &
  4. 全球通
  5. USB(不知道叫什么)

There is no possible way to have RS232 serial port communication with iOS device.

无法与 iOS 设备进行 RS232 串口通信。

Now What are the options left then?

现在还有什么选择呢?

  1. Get a communication convertor in between your external device & iOS device. It can be

    • Serial to ethernet adapter
    • serial to USB adapter etc.
  2. Embedd a wifi/bluetooth module in the external device (If it is being manufactured by you/your firm)

  3. Have something with USB cable & mfi .(Never worked on this, but have seen stuff working with this). By something I meant, register your external device under MFI license & implement USB between devices (Again lack of clarity about USB stuff). Menwhile, I would appreciate edits on my answer by people who might improve it with USB stuff.

  1. 在您的外部设备和 iOS 设备之间获取通信转换器。有可能

    • 串口转以太网适配器
    • 串行到 USB 适配器等。
  2. 在外部设备中嵌入 wifi/蓝牙模块(如果它是由您/您的公司制造的)

  3. 用 USB 电缆和 mfi 做一些事情。(从来没有做过这个,但见过使用这个的东西)。我的意思是,在 MFI 许可下注册您的外部设备并在设备之间实现 USB(再次缺乏关于 USB 的内容)。同时,我会很感激那些可能会用 USB 的东西来改进它的人对我的答案的编辑。

Update:

更新:

I visited the site of your vendor "glooko". I could not find any clue about them having any libraries for developers. So according to my opinion, they have kept their library private. They don't want you to develop apps based on their communication protocol. If you still need to develop apps for them,?contact them here& let them know about your zeal.. M sure they will give you their private code. Anyhow, you don't need to register for any MFI or anything now. What you need is just the code they are using for communication & about that, nobody other than them can help you. So, all the best .. :)

我访问了您的供应商“glooko”的网站。我找不到任何关于他们为开发人员提供任何库的线索。所以根据我的意见,他们已经将他们的图书馆保密了。他们不希望您根据他们的通信协议开发应用程序。如果您仍然需要为他们开发应用程序,?在此处与他们联系并让他们知道您的热情。我相信他们会给您他们的私人代码。无论如何,您现在不需要注册任何 MFI 或任何东西。您需要的只是他们用于通信的代码,除此之外没有其他人可以帮助您。所以,一切顺利.. :)

Update 2:

更新 2:

What I understood from your updated question is, you want to create an iOS application that works with various Glucose meters, from different vendors. In a way you can call it as "universal Glucose meter app"

我从您更新的问题中了解到,您想要创建一个适用于来自不同供应商的各种血糖仪的 iOS 应用程序。在某种程度上,您可以将其称为“通用血糖仪应用程序

The short and straight answer for this is .."You Can't" . But wait, apple is not responsible for this. Neither it is impossible.

对此的简短而直接的答案是..“你不能”。但是等等,苹果对此不承担任何责任。也不是不可能。

Let me tell you why. When you want your application to talk with a hardware device, there must be a communication channel between you too. You are well aware of those two options available. now, if your app must run on iDevices, the communication channel cables must be registered for mfi. Here that is also not the issue.

让我来告诉你为什么。当您希望您的应用程序与硬件设备通信时,您之间也必须有一个通信通道。您很清楚这两个选项。现在,如果您的应用程序必须在 iDevices 上运行,则必须为 mfi 注册通信通道电缆。这也不是问题。

What is the issue then?Different vendons don't generally follow the same communication protocols between their hardware & softwares. What happens if a german commander commands to indian soldier. Obviously, nobody will understand.

那是什么问题呢?不同的供应商通常不会在其硬件和软件之间遵循相同的通信协议。如果德国指挥官向印度士兵指挥会发生什么?显然,没有人会理解。

So, to achieve your objective, the only way is, you have to include SDK provided by each supported vendors in your app. Let me know if you are not yet clear..:)

因此,要实现您的目标,唯一的方法是,您必须在您的应用程序中包含每个受支持的供应商提供的 SDK。如果您还不清楚,请告诉我..:)

回答by apolloneo

There is a device called Lightning Serial Cable, the link is following.Take a look at their SDK.

有一种设备叫Lightning Serial Cable,链接如下。看看他们的SDK。

http://redpark.com/lightning-serial-cable-l2-db9v/

http://redpark.com/lightning-serial-cable-l2-db9v/

It seems work with your application. I'm also looking for the solution that iOS device can talk to another device via serial port. In PC world, all PC has USB ports, so there is large amount of USB to serial port devices and vendors, such as FTDI and Prolific. I don't know if similar situation happens in iOS world.

它似乎适用于您的应用程序。我也在寻找 iOS 设备可以通过串口与另一台设备通信的解决方案。在PC的世界里,所有的PC都有USB接口,所以有大量的USB转串口设备和厂商,比如FTDI和Prolific。我不知道类似的情况是否发生在 iOS 世界。

回答by rckoenes

Unless you join the Made For iPhone programyou can not directly connect anything to an iOS device unless you use Bluetooth or TCP/IP.

除非您加入Made For iPhone 计划,否则您无法直接将任何设备连接到 iOS 设备,除非您使用蓝牙或 TCP/IP。