java - Sending data by serial port -


i'm trying send data serial port in device have , connected device serial pc. in pc i'm trying receive data through terminal application. device using j2me, code i'm using connect com port given below.

public boolean connect() {     if (bconnected) {         return true;     } else {         try {             stringbuffer strcom = new stringbuffer(80);             strcom.append("comm:" + strcomport                     + ";blocking=on;autocts=off;autorts=off;stopbits=");             //autocts=on;autorts=on;             strcom.append(stopbits);             strcom.append(";bitsperchar=");             strcom.append(bitsperchar);             //strcom.append(";parity=");             //strcom.append(parity);             strcom.append(";baudrate=");             strcom.append(baudrate);              commconn = (commconnection) connector.open(strcom.tostring());             writestatustofile(                     "commconnection(" + strcom.tostring()                             + ") device opened.");             strcom = null;             instream = commconn.opendatainputstream();             outstream = commconn.openoutputstream();             instream.skip(instream.available());             bconnected = true;             return true;         } catch (exception ioe) {             writestatustofile(                             "opening com0 ioexception :" + ioe.getmessage());             return false;         }     } } 

the code i'm using write data serial port given below.

public void senddata(short[] message){     string bytedata = "";     try     {         system.out.println("length of message array: " +  message.length);         for(int = 0; i<message.length; i++){             system.out.println("data: " +message[i]);             bytedata += message[i];             outstream.write(message[i]);             system.out.println("done");         }     //outstream.write(message);     outstream.flush();     }     catch(exception ex)     {         system.out.println("exception during sending bytes--->" + ex.tostring());         ex.printstacktrace();     }             system.out.println(             "data flushed output stream: " + bytedata); } 

the com settings device com0, baud rate 4800, parity none, bits per character 8 , stop bits 1 (these values initialised globaly). set same in terminal application i'm receiving data com port.

the issue i'm facing i'm not receiving in pc when connect serial port. want know if made mistakes in code logic. suggestions me analyse issue welcome. please if other information required.

this issue related fact serial port application trying access of type rs232 , type of serial port allow on thread access port , there not see logs along out display. please note not solution reason


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -