MonoDroid lacks support for System.IO.Ports

百般思念 提交于 2020-01-17 05:07:15

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/5653890/monodroid-lacks-support-for-system-io-ports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!