从串行端口

时间:2016-11-23 10:43:41

标签: java serial-port type-conversion

我基本上实现了一种方法,我将读取从串口(RS232)传入的输入。

void read() throws IllegalStateException, IllegalArgumentException, ATCommandFailedException{
String hexch="";
String hex="";
String chave="";




//  System.out.println(" RS232 Standby...");
try {
  int char = -1;
  while(char != 13) {
    char = inStream.read();

    if (ch >= 0) {
      chave += (char) char; // Input char type in the String
      hex = Integer.toHexString(ch);
      hexch += hex;     // Input hex type in the String 
    }   
  }            
}

这很完美。虽然为了确保该过程在长期使用中有效,但我希望在读取时刻之外进行转换。问题是因为我的项目是用JavaME制作的,所以我无法使用任何String.format方法等。 有人能指出我的解决方案吗? 谢谢:)

0 个答案:

没有答案
相关问题