简体   繁体   English

如何在J2ME Midlet和PC之间进行通信?

[英]How to Communicating between a J2ME Midlet and PC?

如何通过连接的电缆使J2ME Midlet与PC上的Java程序或某些应用程序通信?

Incredible_Honk is almost right. Incredible_Honk几乎是正确的。 The key is to use the (standard) system property "microedition.commports". 关键是使用(标准)系统属性“ microedition.commports”。 This provides a comma delimited list of the com ports which are available to your application. 这提供了以逗号分隔的COM端口列表,这些端口可用于您的应用程序。 To open a connection use CommConnection as follows: 要打开连接,请使用CommConnection ,如下所示:

CommConnection con = (CommConnection) Connector.open("com:<commport name>");

Usually this will provide access to a USB serial connection, possibly also infrared if available. 通常,这将提供对USB串行连接的访问​​,如果可能的话,也可以通过红外访问。 Iterate through each one to see which one corresponds to the connection you're looking for. 遍历每个对象,以查看与您要查找的连接相对应的对象。

On Windows at least, you will need to install the correct drivers for your handset first. 至少在Windows上,您需要首先为手机安装正确的驱动程序。 This will then allow you to open a serial connection and communicate with the application. 然后,这将允许您打开串行连接并与应用程序通信。

There is no general way of doing this. 没有一般的方法可以做到这一点。 It hardly depends on the capabilities of the mobil. 它几乎不取决于动员能力。 Might be that there is some vendor API giving you special access to USB, but I'm not aware of any. 可能是因为有一些供应商API赋予了您对USB的特殊访问权限,但我不知道有什么。

Some phones support communication via serial port connections. 某些电话支持通过串行端口连接进行通信。 Take a look at the javax.microedition.io.CommConnection interface for more information. 查看javax.microedition.io.CommConnection接口以获取更多信息。

索尼爱立信手机提供了一种在设备上调试Midlet并通过电缆将控制台消息返回的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM