MonoDroid 缺乏对 System.IO.Ports 的支持
我有一个用 C# .NET 4.0 编写的应用程序。我考虑使用 MonoDroid 使其也可以在 Android 系统上运行。问题是,该应用程序严重依赖 .NET Framework 命名空间 System.IO.Ports,而 MonoDroid 中似乎不存在该命名空间。有什么解决方案适合我,这样我仍然可以使用 MonoDroid?
I have an application written in C# .NET 4.0. I consider using MonoDroid for making it run also on Android systems. Thing is, the application relies heavily on .NET Framework namespace System.IO.Ports which doesn't seem to exist in MonoDroid. What solution is there for me, so I could still use MonoDroid?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已向 Android 版 Mono 添加了串行端口支持的增强请求:
https://bugzilla .novell.com/show_bug.cgi?id=687407
但是,我不确定它有多大用处,因为粗略搜索表明需要自定义 Linux 内核才能获得 RS232 Android 上的串行端口支持,因此这可能有点不可行。
还有 android-serialport-api...但 wiki 还建议重新编译内核。
假设您希望将此用于“正常”使用(在 Android 市场上部署等),我不确定串行端口是否以任何形式受到支持。
I've added an enhancement request for serial port support to Mono for Android:
https://bugzilla.novell.com/show_bug.cgi?id=687407
However, I'm not sure how useful it would be, as cursory searching suggests that a custom Linux kernel is needed in order to get RS232 serial port support on Android, so that may be a bit of a non-starter.
There's also android-serialport-api...but the wiki also suggests recompiling the kernel.
Assuming you want this for "normal" use (deployment on the Android Market, etc.), I'm not sure serial ports are supportable in any form.
如果您只需要一些简单的代码构造,您可以从 单声道 github 存储库。当然,并非主 Mono 存储库中的所有内容都可以在 MonoDroid 中使用,但像枚举这样的一些内容应该可以毫无问题地复制/粘贴。但最终,据我所知,Android 中并没有真正的串行端口。
正如其他人所说,可能有一种方法可以破解您的设备上的序列号。不过,您最好探索蓝牙或 wifi 串行适配器。 (蓝牙 SPP 可用于 Android,但可能不适用于 iOS,因此如果您想同时覆盖这两个功能,您可能需要使用 wifi。)然后您可以创建自己的 System.IO.Ports.SerialPort 实现,将其包装在您的系统中。 MonoDroid 项目。
我自己没有这样做过,但这是我探索过的事情。
If you just need some simple code constructs, you could grab some code from the mono github repo. Of course not everything in the main mono repo may work in MonoDroid, but some stuff like enums should copy/paste without issue. Ultimately though, as far as I've seen, you don't get an actual serial port in Android.
As stated by others, there may be a way to hack serial onto your device. However you might be better off exploring a bluetooth or wifi serial adapter. (Bluetooth SPP is available for Android, but might not be for iOS, so if you want to cover both you may want to go wifi.) You could then perhaps create your own System.IO.Ports.SerialPort implementation to wrap it inside your MonoDroid project.
I have not done this myself, but it is something I've explored.