java - BGS5T RS232 communication with 1-wire sensor -
i have gemalto bgs5t java module , 1-wire temperature sensor. have java midlet uses rs232 port communicate temperature sensor. problem that, no response sensor no matter send. sensor has right voltage on it, connection should fine. tried testing program connected rs232 port computer , watched terminal(termite) if sent data correct , looks should. test connected temperature sensor directly computer , sent data terminal , worked should. got responses on random inputs 9999. checked parameters connection inside terminal , copied them java midlet, no success. there 1 time got responses, when tryed next day continue work had no success. parameters inside terminal: baud rate:9600 data bits : 8 stop bits: 1 parity: none flow control:rts/cts
here 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 , 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); }
i had use null modem cable working.
Comments
Post a Comment