Java 无法在android中使用UsbSerialPort执行命令
我已经使用GitHub库完成了连接到设备、搜索和打开等初始步骤 但我无法使用控制台端口向cisco路由器发送命令。 我在onResume方法中对SerialConsoleActivity做了以下更改Java 无法在android中使用UsbSerialPort执行命令,java,android,Java,Android,我已经使用GitHub库完成了连接到设备、搜索和打开等初始步骤 但我无法使用控制台端口向cisco路由器发送命令。 我在onResume方法中对SerialConsoleActivity做了以下更改 sPort.setRTS(true); //sPort.setDTR(true); String command="show ?"; byte[] commandByteArray = command.getBytes(); sPort.write(commandByteAr
sPort.setRTS(true);
//sPort.setDTR(true);
String command="show ?";
byte[] commandByteArray = command.getBytes();
sPort.write(commandByteArray, 5000);
我想在我的android手机上执行命令,读取输出
这是我的第一篇文章,如果你需要任何关于课程的描述,请告诉我
提前感谢图书馆已经提供了使用sPort.write编写的功能,而不是使用sPort.write编写
SerialInputOutputManager
使用按钮和文本使用onCreate()方法。
我正在共享以下用于写入cisco控制台端口的代码:
commandButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View arg0) {
String command = commandEnter.getText().toString().trim();
command = command + "\r\n";
consoleText.append("Command > " + command);
mSerialIoManager.writeAsync(command.getBytes());
}
});
现在,无论何时接收到数据,它都将调用方法updateReceivedData(字节[]数据)
内部方法:
consoleText.append(new String(data));
mScrollView.smoothScrollTo(0, consoleText.getBottom());
现在我可以得到命令输出和初始路由器配置
快乐编码:)