我有一个现金抽屉,我需要用Android应用程序的命令打开它。但我无法正确阅读手册。
这是一组打开抽屉的命令。我正在使用以下来自互联网的代码来实现这一点。我在命令集中收到错误。请你们建议任何有用的代码,只需按一下按钮即可实现现金抽屉打开功能?还帮我看一下手册。
final byte[] openCD={27,112,0,60,120};
String s=new String(openCD);
commandSet+=s;
return s;
手动样品
现金抽屉控制命令
ESC p m n1 n2生成脉冲n1 n2原始控制命令ASCII ESC p m十进制27 112 m格式n1 n2十六进制1B 70 m n1 n2
现金抽屉通过电缆连接到Android设备
我得到了这个东西
String file= "/sys/class/gpio/gpio14/value";
writeToFile(file,"1");
writeToFile(file,"0");
public static void writeToFile(String fileName, String data){
File file = new File("/sys/class/gpio/gpio14/value");
FileOutputStream outputStream = null;
try{
outputStream=new FileOutputStream(file);
byte [] bytes = data.getBytes();
outputStream.write(bytes);
outputStream.close();
}
catch(Exception e){
e.printStackTrace();
}
}
1表示打开抽屉,0表示关闭。将代码放在按钮单击上