我在我的电脑上使用Windows 7作为操作系统。我期待创建一个应用程序,在其中,我将发送AT命令移动,编程。到目前为止,我希望通过PC和Mobile之间的USB数据电缆连接来实现这一点。我最初的方法是使用JAVA。虽然我很快意识到JAVA和USB接口之间的大多数API开发对于windows来说都是死气沉沉的,但是这些API都不支持Windows 7。有人能建议一下哪种语言最适合这样做吗?
谢谢,
发布于 2013-01-22 08:44:32
要让Android与PC建立连接,您需要使用adb命令(Android )转发相同的端口,例如:
adb forward tcp:7612 tcp:7612 在中,似乎如下所示:
private int port = 7612;
....
/**
* Runs the android debug bridge command of forwarding the ports
*
*/
private void execAdb() {
// run the adb bridge
try {
String runP = "adb forward tcp:" + port + " tcp:" + port + "";
System.out.println("Run command through cmd: " + runP);
Process p=Runtime.getRuntime().exec(runP);
Scanner sc = new Scanner(p.getErrorStream());
if (sc.hasNext()) {
while (sc.hasNext()) System.out.println(sc.next());
System.out.println("Cannot start the Android debug bridge");
}
} catch (Exception e) {
e.printStackTrace();
}
}之后,您可以实现任何TCP客户机/服务器代码,因为端口是定义的,并且可以使用默认IP,如: 127.0.0.1
对于,iOS,,使用目标C。
https://stackoverflow.com/questions/14454501
复制相似问题