javaserial-portmidletgemalto1wire

BGS5T RS232 communication with 1-wire sensor


I have Gemalto BGS5T java module and 1-wire temperature sensor. I have java midlet which uses RS232 port to communicate with temperature sensor. But the problem is that, I get no response from the sensor no matter what I send. Sensor has the right voltage on it, so the connection should be fine. I tried testing my program so that I connected rs232 port to computer and watched with terminal(Termite) if the sent data was correct and everything looks like it should. Another test was that I connected temperature sensor directly to computer and sent data with terminal and it worked like it should. I even got responses on some random inputs like 9999. I checked the parameters for connection inside the terminal and copied them to java midlet, but with no success. There was only one time that I got some responses, but when I tryed the next day to continue with the work I had no success. Parameters inside terminal: Baud rate:9600 Data bits : 8 Stop bits: 1 Parity: none Flow control:RTS/CTS

Here is the Java code:

String strCOM = "comm:COM0;blocking=on;baudrate=9600";
commConn = (CommConnection)Connector.open(strCOM);
System.out.println("CommConnection(" + strCOM + ") opened");
System.out.println("Real baud rate: " + commConn.getBaudRate());
inStream  = commConn.openInputStream();
outStream = commConn.openOutputStream();
System.out.println("InputStream and OutputStream opened");
while(1==1)
    {
        byte bC1 = (byte)Integer.parseInt("11000001",2);
        byte C1 = hexToBin("C1");
        byte bparameter2 = (byte)Integer.parseInt("00010111",2);
        byte bparameter3 = (byte)Integer.parseInt("01000101",2);
        byte bparameter4 = (byte)Integer.parseInt("01011011",2);
        byte bparameter5 = (byte)Integer.parseInt("00001111",2);
        byte bparameter6 = (byte)Integer.parseInt("10010101",2);
        byte[] bArray = {bparameter2,bparameter3,bparameter4,bparameter5,bparameter6};





      int ch;
      try {
        outStream.write(bC1);
        Thread.sleep(50);
        //outStream.write(bArray);
        outStream.write(bparameter2);
        outStream.write(bparameter3);
        outStream.write(bparameter4);
        outStream.write(bparameter5);
        outStream.write(bparameter6);

        System.err.println("inStream bytes:" + inStream.available());
        if(inStream.available() > 0)
        {   
          String msg = "";
          while(inStream.available() > 0)
          {
            ch = inStream.read();
            msg = msg + (char) ch;
          }
          System.out.println("Serial msg: " + msg);
        }
        outStream.write('9');
        outStream.write('9');
        outStream.write('9');
        outStream.write('9');
        Thread.sleep(100);
        outStream.write('9');
        outStream.write('9');
        outStream.write('9');
        outStream.write('9');
        System.err.println("inStream bytes:" + inStream.available());
        if(inStream.available() > 0)
        {   
          String msg = "";
          while(inStream.available() > 0)
          {
            ch = inStream.read();
            msg = msg + (char) ch;
          }
          System.out.println("Serial msg: " + msg);
        }

Solution

  • I had to use null modem cable to get it working.