[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rxtx
Subject:    Re: [Rxtx] Rajesh Trying 9600 8,N,1
From:       Rajesh N <rajesh.invincible () gmail ! com>
Date:       2006-02-22 12:21:00
Message-ID: 6b2c65f0602220409u48bbbaabua202ca9c9fcb8895 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On 2/20/06, Trent Jarvi <tjarvi@qbang.org> wrote:
>
> On Mon, 20 Feb 2006, Rajesh N wrote:
>
> > Excuse me SALVO,DMITRY,TRENT
> > My name is Rajesh and i am presently involved in my final year
> curriculum
> > project in java
> > I saw ur website
> http://www.seattlerobotics.org/encoder/200205/gbcam.html
> > and hence *HOPE THAT U COULD HELP ME IN THIS REGARD(SERIAL COMMN).*
> > **
> >
> >> I am doing serial communication between a java program on linux*(FEDORA
> >> CORE4)* to a microcontroller
> >
> > The default baud rate in java is 9600bps
> >> 1.Now when i use a microcontroller programmed for 9600bps then it gives
> me
> >> *half data+half junk*
> >> i.e PARTIAL OUTPUT
> >> 2.when a 19200bps 20Mhz microcontroller was used *full junk* i.e NO
> OUTPUT
> >>
> >> MY CODE SNIPPET HAS THIS:
> >> SerialPort s=(SerialPort)commportid1.open("asdf",2000);
> >> s.setFlowControlMode(SerialPort.FLOWCONTROL_NONE)
> >> s.setSerialPortParams(9600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,
> >> SerialPort.PARITY_NONE);
> >>
> >> SIMILARLY i have tried for 19200bps but it didn't work
> >> i also tried all the FLOWCONTROL modes
> >> no use
> >>
> >
> >   ALSO I CHECKED FEDORA CORE4 UPDATE CD FOR ANY *SERIAL DRIVERS*
> >  BUT I *DON'T KNOW* WHICH OF THE OPTIONS HAS THE SERIAL DRIVER
> >  *I HOPE* SINCE PART OF THE DATA IS COMING MY *SERIAL DRIVER IS
> INSTALLED
> > BUT NOT SURE*
> >
> >
> > THE ONLY THING I GET IS
> >>
> >
> > * java.io.IOException: not all params supported by the kernel*
> > **
>
> Hi Rajesh,
>
> *taj flips his teachers cap into rally mode.
>
> Wasn't your project halted once before like this?  With senior projects
> you need to take time and problem solve.  The problem could be anyplace.
> While asking questions on mail-lists, the more complete your description
> of the settings and observations you make the better answer you may get.
> You may even have your advisor proof read your post before sending it to a
>
> list.
>
> With 9600 8 N 1, everything should work in rxtx.  In fact, if you open the
> device as a File for reading and writing the port will be configured like
> that.  This is the easiest thing for rxtx to do on all platforms.  The
> same can be said for no flow control.  Thats the default.  RXTX is used
> with many projects without problems at these settings as they are by far
> the most common for serial communication.
>
> The Linux serial drivers for standard PC ports just work at these
> settings.  That is how the kernel is debugged over remote console in many
> cases.  It was one of the first things to work in Linux (since 1991) and
> is tested by people every release.  You *don't need to find new Linux
> serial drivers.
> *
> Make sure only one program is reading the port.  Since you mention the
> problem is worse at *higher baudrates*, try a 300 baudrate if you can.
> Perhaps there is a problem at the physical layer.  Try to avoid closed
> source multiport cards.  They do not get the same level of review.
>
> But the most important thing is to stay calm and think through the problem
> like an engineer.  Use the resources available in your laboratory to test
> various theories and eliminate possibilities until you understand what the
> problem actually is.  You should even be able to see stopbits on a
> oscilloscope if you do things right.
>
> And don't forget I've been teaching 'final year Java' for six years ;)
> Sometimes when you give the answers, you destroy the learning process.
> You will have to think through this.
>
> --
> Trent Jarvi
> tjarvi@qbang.org
> _______________________________________________
> Rxtx mailing list
> Rxtx@qbang.org
> http://mailman.qbang.org/mailman/listinfo/rxtx
>


HI TRENT
As ur advice i tried the engineering way but still *failed*
Let me tell u trent my project duration completes by this weekend TILL NOW I
WAS GOING THAT WAY AND THAT IS WHY I THOUGHT I'LL DO IT ALL ALONE(myself)
BUT I *CAN'T. I AM A FAILED MAN*
THIS TIME I AM SENDING U MY CODE TOO
PLZZ GO THRU IT AND HELP ME OUT
I have not tried for different baud rates but i suppose my logic of
receiving the data is wrong Since i am missing part of the data that means
the O.S buffer which stores the data must have overflown before i processed
it so it is not available to me

THE PIC MICROCONTROLLER 18F452 20MhZ is programmed  to send 40 bytes[hexa
code] (255*255) times

WHEN I EXECUTE THE PROGRAM  i get 1-5 sets correctly then some 4-5 sets are
gone and again some are visible and so on...
So that means the speed at which the data is coming maybe my program is not
able to receive and therefore lot of data is missing

do u have any idea od the os buffer
for eg
byte r=inStream.read().Here i am operating on 1 char at a time then where is
all that
 data stored and how can i regulate it.
JUST TAKE A LOOK AT THE PROGRAM
import javax.comm.*;
import java.io.*;


public class SerialPortImpl1
{

   private static SerialPort serialPort=null;
   private static CommPortIdentifier commportid1;
   private static InputStream  inStream;  // serial input stream
   private static OutputStream outStream; // serial output stream
   static Enumeration portlist;
   static byte str[] ={65,99,100,101};
   public static Quec q1;//A Queue i have made is used here

   public void initializeSerialPort()
   {

   eg=new byte[5100];
    try
   {

       boolean portfound=false;
        portlist=CommPortIdentifier.getPortIdentifiers();
       while(portlist.hasMoreElements())
       {
        commportid1=(CommPortIdentifier)portlist.nextElement();
        if(commportid1.getPortType()==CommPortIdentifier.PORT_SERIAL)
        {
          System.out.println("List of
Ports+"+commportid1.getName()+commportid1.getCurrentOwner());

        }

    }

       commportid1 = CommPortIdentifier.getPortIdentifier("/dev/ttyS0");
       System.out.println("So the port in use
is+"+commportid1.getName()+"type is+"+commportid1.getPortType()+"Owner
is+"+commportid1.getCurrentOwner());
       serialPort = (SerialPort)commportid1.open("COM",2000);/*CLAIM
OWNERSHIP(name resolving,waiting time)*/
       serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
       serialPort.setSerialPortParams(9600,SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
       //serialPort.enableReceiveThreshold(1080);

  System.out.println("BAUD RATE"+serialPort.getBaudRate()+"\nDATA
BITS"+serialPort.getDataBits()+"\nstop
bits"+serialPort.getStopBits()+"\nflowcontrol"+serialPort.getFlowControlMode());

   }

   catch(NoSuchPortException np)
   {System.out.println("NO suchPOrt Exists in port identification"+np);}
   catch(PortInUseException p)
   { System.out.println("Port In use Exception in port identification"+p);}
   catch(UnsupportedCommOperationException e)
   { System.out.println("Speed is not supported in port identification"+e);}
   catch(java.lang.NullPointerException ne)
   { System.out.println("NULL BHAIYYA in port identification"+ne);}

   try
   {
    // Get output and input streams
    outStream = serialPort.getOutputStream();
    inStream  = serialPort.getInputStream();
   }//end of try
   catch(IOException ioe)
   {System.out.println("The streams are not opening in i/o streams");}
   catch(java.lang.NullPointerException ne)
   { System.out.println("NULL BHAIYYA in i/o streams"+ne);}
   catch(Exception e)
   { System.out.println("Exception in enumerating the ports in i/o
streams"+e);}

  }


  public SerialPortImpl1()
  {

   q1= new Quec("que");
  }

 public void receiveByte() throws IOException
 {
  do
    {
   char r='N';//w global
   int n=0;
   try{

   r=(char)inStream.read();//System.out.print(r); //CHECK FOR THRESHOLD(OUR
BUFFER)
   int  i=0,k=0;
   //The queue holds the data(each node has 1 hex charecter(4 bits))when 540
nodes(chars) //are stored then the queue is repeated with the next data
being stored in the 1st nodeTHIS //AVAOIDES ANY MEMORY PROBLEM
    if(w==540){q1.cycle(r);w=0;S++;System.out.println("SET OVER"+S);}
    else
    {q1.enque(r);w++;System.out.print(q1.ar[k++]);}
    if(w%72==0){System.out.print(" ");k=0;}

  }//try ends
   catch(IOException ie){System.out.println("io in receiveByte"+ie);}
   catch(NullPointerException ne){System.out.println("NULL in
receiveByte"+ne);}
   catch(Exception e){System.out.println("general exception in
receiveByte"+e);}
  }while(true);
}//end of receive

  public static void main(String ab[])
  {
   SerialPortImpl1 serialP=new SerialPortImpl1();
   try{
         serialP.initializeSerialPort();//ALL THE INTIAL SETTINGS
        serialP.receiveByte();

These i have removed b'coz the ports are closed aas i shut the program and
since evrytime i execute it again the port is found that means it is not the
problem
//outStream.close();inStream.close();serialPort.sendBreak(1);commportid1.internalClosePort();os.close();

      }//try ends
      catch(IOException ioe)
      {System.out.println("IOEXCEPTION in calling receive byte in while
loop"+ioe);}
      catch(SecurityException se)
      {System.out.println("SECURITY EXCEPTIONin calling receive byte in
while loop+"+se);}
      catch(java.lang.NullPointerException ne)
      { System.out.println("NULL in calling receive byte in while
loop"+ne);}
  }//main ends


}//end of class

 **
thankin u
EXPECTING A REPLY AT THE EARLIEST

[Attachment #5 (text/html)]

<br><br>
<div><span class="gmail_quote">On 2/20/06, <b class="gmail_sendername">Trent \
Jarvi</b> &lt;<a href="mailto:tjarvi@qbang.org" target="_blank" onclick="return \
top.js.OpenExtLink(window,event,this)">tjarvi@qbang.org</a>&gt; wrote: </span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); \
margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">On Mon, 20 Feb 2006, Rajesh N \
wrote:<br><br>&gt; Excuse me SALVO,DMITRY,TRENT<br>&gt; My name is Rajesh and i am \
presently involved in my final year curriculum <br>&gt; project in java<br>&gt; I saw \
ur website <a href="http://www.seattlerobotics.org/encoder/200205/gbcam.html" \
target="_blank" onclick="return \
top.js.OpenExtLink(window,event,this)">http://www.seattlerobotics.org/encoder/200205/gbcam.html
 </a><br>&gt; and hence *HOPE THAT U COULD HELP ME IN THIS REGARD(SERIAL COMMN).*
<br>&gt; **<br>&gt;<br>&gt;&gt; I am doing serial communication between a java \
program on linux*(FEDORA<br>&gt;&gt; CORE4)* to a microcontroller<br>&gt;<br>&gt; The \
default baud rate in java is 9600bps<br>&gt;&gt; 1.Now when i use a microcontroller \
programmed for 9600bps then it gives me <br>&gt;&gt; *half data+half \
junk*<br>&gt;&gt; i.e PARTIAL OUTPUT<br>&gt;&gt; 2.when a 19200bps 20Mhz \
microcontroller was used *full junk* i.e NO OUTPUT<br>&gt;&gt;<br>&gt;&gt; MY CODE \
SNIPPET HAS THIS:<br>&gt;&gt; SerialPort \
s=(SerialPort)commportid1.open(&quot;asdf&quot;,2000); <br>&gt;&gt; \
s.setFlowControlMode(SerialPort.FLOWCONTROL_NONE)<br>&gt;&gt; \
s.setSerialPortParams(9600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,<br>&gt;&gt; \
SerialPort.PARITY_NONE);<br>&gt;&gt;<br>&gt;&gt; SIMILARLY i have tried for 19200bps \
but it didn't work <br>&gt;&gt; i also tried all the FLOWCONTROL modes<br>&gt;&gt; no \
use<br>&gt;&gt;<br>&gt;<br>&gt;&nbsp;&nbsp; ALSO I CHECKED FEDORA CORE4 UPDATE CD FOR \
ANY *SERIAL DRIVERS*<br>&gt;&nbsp;&nbsp;BUT I *DON'T KNOW* WHICH OF THE OPTIONS HAS \
THE SERIAL DRIVER <br>&gt;&nbsp;&nbsp;*I HOPE* SINCE PART OF THE DATA IS COMING MY \
*SERIAL DRIVER IS INSTALLED<br>&gt; BUT NOT SURE*<br>&gt;<br>&gt;<br>&gt; THE ONLY \
THING I GET IS<br>&gt;&gt;<br>&gt;<br>&gt; * java.io.IOException: not all params \
supported by the kernel* <br>&gt; **<br><br>Hi Rajesh,<br><br>*taj flips his teachers \
cap into rally mode.<br><br>Wasn't your project halted once before like \
this?&nbsp;&nbsp;With senior projects<br>you need to take time and problem \
solve.&nbsp;&nbsp;The problem could be anyplace. <br>While asking questions on \
mail-lists, the more complete your description<br>of the settings and observations \
you make the better answer you may get.<br>You may even have your advisor proof read \
your post before sending it to a <br>list.<br><br>With 9600 8 N 1, everything should \
work in rxtx.&nbsp;&nbsp;In fact, if you open the<br>device as a File for reading and \
writing the port will be configured like<br>that.&nbsp;&nbsp;This is the easiest \
thing for rxtx to do on all platforms.&nbsp;&nbsp;The <br>same can be said for no \
flow control.&nbsp;&nbsp;Thats the default.&nbsp;&nbsp;RXTX is used<br>with many \
projects without problems at these settings as they are by far<br>the most common for \
serial communication.<br><br>The Linux serial drivers for standard PC ports just work \
at these <br>settings.&nbsp;&nbsp;That is how the kernel is debugged over remote \
console in many<br>cases.&nbsp;&nbsp;It was one of the first things to work in Linux \
(since 1991) and<br>is tested by people every release.&nbsp;&nbsp;You <strong>don't \
need to find new Linux <br>serial drivers.<br></strong><br>Make sure only one program \
is reading the port.&nbsp;&nbsp;Since you mention the<br>problem is worse at \
<strong>higher baudrates</strong>, try a 300 baudrate if you can.<br>Perhaps there is \
a problem at the physical layer.&nbsp;&nbsp;Try to avoid closed <br>source multiport \
cards.&nbsp;&nbsp;They do not get the same level of review.<br><br>But the most \
important thing is to stay calm and think through the problem<br>like an \
engineer.&nbsp;&nbsp;Use the resources available in your laboratory to test \
<br>various theories and eliminate possibilities until you understand what \
the<br>problem actually is.&nbsp;&nbsp;You should even be able to see stopbits on \
a<br>oscilloscope if you do things right.<br><br>And don't forget I've been teaching \
'final year Java' for six years ;) <br>Sometimes when you give the answers, you \
destroy the learning process.<br>You will have to think through \
this.<br><br>--<br>Trent Jarvi<br><a href="mailto:tjarvi@qbang.org" target="_blank" \
onclick="return top.js.OpenExtLink(window,event,this)"> \
tjarvi@qbang.org</a><br>_______________________________________________ <br>Rxtx \
mailing list<br><a href="mailto:Rxtx@qbang.org" target="_blank" onclick="return \
top.js.OpenExtLink(window,event,this)">Rxtx@qbang.org</a><br><a \
href="http://mailman.qbang.org/mailman/listinfo/rxtx" target="_blank" onclick="return \
top.js.OpenExtLink(window,event,this)"> \
http://mailman.qbang.org/mailman/listinfo/rxtx</a><br></blockquote></div> \
<div>&nbsp;</div> <div>&nbsp;</div>
<div>HI TRENT </div>
<div>As ur advice i tried the engineering way but still <strong>failed</strong></div>
<div>Let me tell u trent my project duration completes by this weekend TILL NOW I WAS \
GOING THAT<span style="font-weight: bold;"> WAY </span>AND THAT IS WHY I THOUGHT I'LL \
DO IT ALL ALONE(myself)</div> <div>BUT I <strong>CAN'T. I AM A FAILED \
MAN</strong></div> <div>THIS TIME I AM SENDING U MY CODE TOO</div>
<div>PLZZ GO THRU IT AND HELP ME OUT<br>I have not tried for different baud rates but \
i suppose my logic of receiving the data is wrong Since i am missing part of the data \
that means the O.S buffer which stores the data must have overflown before i \
processed it so it is not available to me <br></div>
<div>&nbsp;</div>
<div>THE PIC MICROCONTROLLER 18F452 20MhZ is programmed&nbsp; to send 40 bytes[hexa \
code] (255*255) times</div> <div>&nbsp;</div>
<div>WHEN I EXECUTE THE PROGRAM&nbsp; i get 1-5 sets correctly then some 4-5 sets are \
gone and again some are visible and so on...</div> <div>So that means the speed at \
which the data is coming maybe my program is not able to receive and therefore lot of \
data is missing</div> <div>&nbsp;</div>
<div>do u have any idea od the os buffer</div>
<div>for eg</div>
<div>byte r=inStream.read().Here i am operating on 1 char at a time then where is all \
that<br>&nbsp;data stored and how can i regulate it.<br>JUST TAKE A LOOK AT THE \
PROGRAM<br>import javax.comm.*;<br>import java.io.*;<br><br> <br>public class \
SerialPortImpl1 <br>{&nbsp;&nbsp; <br>&nbsp;&nbsp; <br>&nbsp;&nbsp; private static \
SerialPort serialPort=null;<br>&nbsp;&nbsp; private static CommPortIdentifier \
commportid1;&nbsp;  <br>&nbsp;&nbsp; private static InputStream&nbsp; inStream;&nbsp; \
// serial input stream&nbsp;  <br>&nbsp;&nbsp; private static OutputStream outStream; \
// serial output stream<br>&nbsp;&nbsp; static Enumeration portlist;<br>&nbsp;&nbsp; \
static byte str[] ={65,99,100,101};&nbsp; <br>&nbsp;&nbsp; public static Quec q1;//A \
Queue i have made is used here<br>&nbsp;<br>&nbsp;&nbsp; public void \
initializeSerialPort()  <br>&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp; \
eg=new byte[5100];<br>&nbsp;&nbsp;&nbsp; try<br>&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp; \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
boolean portfound=false;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
portlist=CommPortIdentifier.getPortIdentifiers();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
while(portlist.hasMoreElements())<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
commportid1=(CommPortIdentifier)portlist.nextElement();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
if(commportid1.getPortType()==CommPortIdentifier.PORT_SERIAL)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
System.out.println(&quot;List of \
Ports+&quot;+commportid1.getName()+commportid1.getCurrentOwner()); \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp; \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; \
}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
commportid1 = CommPortIdentifier.getPortIdentifier(&quot;/dev/ttyS0&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
System.out.println(&quot;So the port in use \
is+&quot;+commportid1.getName()+&quot;type \
is+&quot;+commportid1.getPortType()+&quot;Owner \
is+&quot;+commportid1.getCurrentOwner());&nbsp;&nbsp;&nbsp;  \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; serialPort = \
(SerialPort)commportid1.open(&quot;COM&quot;,2000);/*CLAIM OWNERSHIP(name \
resolving,waiting time)*/<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
serialPort.setSerialPortParams \
(9600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE); \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
//serialPort.enableReceiveThreshold(1080);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
<br>&nbsp; System.out.println(&quot;BAUD \
RATE&quot;+serialPort.getBaudRate()+&quot;\nDATA \
BITS&quot;+serialPort.getDataBits()+&quot;\nstop \
bits&quot;+serialPort.getStopBits()+&quot;\nflowcontrol&quot;+serialPort.getFlowControlMode());
 <br>&nbsp;&nbsp; <br>&nbsp;&nbsp; }<br>&nbsp;&nbsp; <br>&nbsp;&nbsp; \
catch(NoSuchPortException np)<br>&nbsp;&nbsp; {System.out.println(&quot;NO suchPOrt \
Exists in port identification&quot;+np);}&nbsp; <br>&nbsp;&nbsp; \
catch(PortInUseException p)<br>&nbsp;&nbsp; { System.out.println(&quot;Port In use \
Exception in port identification&quot;+p);}  <br>&nbsp;&nbsp; \
catch(UnsupportedCommOperationException e)<br>&nbsp;&nbsp; { \
System.out.println(&quot;Speed is not supported in port \
identification&quot;+e);}<br>&nbsp;&nbsp; catch(java.lang.NullPointerException \
ne)<br>&nbsp;&nbsp; { System.out.println(&quot;NULL BHAIYYA in port \
identification&quot;+ne);} <br>&nbsp;&nbsp; <br>&nbsp;&nbsp; try<br>&nbsp;&nbsp; { \
<br>&nbsp;&nbsp;&nbsp; // Get output and input streams<br>&nbsp;&nbsp;&nbsp; \
outStream = serialPort.getOutputStream();<br>&nbsp;&nbsp;&nbsp; inStream&nbsp; = \
serialPort.getInputStream();<br>&nbsp;&nbsp; }//end of try<br>&nbsp;&nbsp; \
catch(IOException ioe)<br>&nbsp;&nbsp; {System.out.println (&quot;The streams are not \
opening in i/o streams&quot;);} <br>&nbsp;&nbsp; catch(java.lang.NullPointerException \
ne)<br>&nbsp;&nbsp; { System.out.println(&quot;NULL BHAIYYA in i/o \
streams&quot;+ne);}&nbsp; <br>&nbsp;&nbsp; catch(Exception e)<br>&nbsp;&nbsp; { \
System.out.println (&quot;Exception in enumerating the ports in i/o \
streams&quot;+e);}&nbsp;&nbsp; <br>&nbsp;<br>&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; \
<br>&nbsp; public SerialPortImpl1()<br>&nbsp; {<br>&nbsp;&nbsp; <br>&nbsp;&nbsp; q1= \
new Quec(&quot;que&quot;);&nbsp; <br>&nbsp; }&nbsp; <br><br>&nbsp;public void \
receiveByte() throws IOException <br>&nbsp;{ <br>&nbsp; do<br>&nbsp;&nbsp;&nbsp; \
{<br>&nbsp;&nbsp; char r='N';//w global<br>&nbsp;&nbsp; int n=0;<br>&nbsp;&nbsp; \
try{<br>&nbsp;&nbsp; <br>&nbsp;&nbsp; r=(char)inStream.read();//System.out.print(r); \
//CHECK FOR THRESHOLD(OUR BUFFER)<br>&nbsp;&nbsp; int&nbsp; i=0,k=0;&nbsp;  \
<br>&nbsp;&nbsp; //The queue holds the data(each node has 1 hex charecter(4 \
bits))when 540 nodes(chars) //are stored then the queue is repeated with the next \
data being stored in the 1st nodeTHIS //AVAOIDES ANY MEMORY PROBLEM&nbsp;   \
<br>&nbsp;&nbsp;&nbsp; if(w==540){q1.cycle(r);w=0;S++;System.out.println(&quot;SET \
OVER&quot;+S);}&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; \
{q1.enque(r);w++;System.out.print(q1.ar[k++]);}<br>&nbsp;&nbsp;&nbsp; \
if(w%72==0){System.out.print(&quot; &quot;);k=0;}  <br>&nbsp;&nbsp;&nbsp;  <br>&nbsp; \
}//try ends<br>&nbsp;&nbsp; catch(IOException ie){System.out.println(&quot;io in \
receiveByte&quot;+ie);}<br>&nbsp;&nbsp; catch(NullPointerException \
ne){System.out.println(&quot;NULL in receiveByte&quot;+ne);}<br>&nbsp;&nbsp; \
catch(Exception e){System.out.println (&quot;general exception in \
receiveByte&quot;+e);}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp; \
}while(true);<br>}//end of receive<br>&nbsp; <br>&nbsp; public static void \
main(String ab[])<br>&nbsp; {<br>&nbsp;&nbsp; SerialPortImpl1 serialP=new \
SerialPortImpl1();<br>&nbsp;&nbsp; try{ <br> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; serialP.initializeSerialPort();//ALL \
THE INTIAL SETTINGS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  \
<br>&nbsp; &nbsp; &nbsp; &nbsp; serialP.receiveByte();&nbsp;&nbsp;  \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>These i have removed b'coz the \
ports are closed aas i shut the program and since evrytime i execute it again the \
port is found that means it is not the problem &nbsp;&nbsp; \
//outStream.close();inStream.close();serialPort.sendBreak(1);commportid1.internalClosePort();os.close(); \
 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }//try ends<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
catch(IOException ioe)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
{System.out.println(&quot;IOEXCEPTION in calling receive byte in while \
loop&quot;+ioe);}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch(SecurityException \
se)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {System.out.println(&quot;SECURITY EXCEPTIONin \
calling receive byte in while loop+&quot;+se);}&nbsp;&nbsp;  \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch(java.lang.NullPointerException \
ne)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { System.out.println(&quot;NULL in calling \
receive byte in while loop&quot;+ne);} <br>&nbsp; }//main ends \
<br>&nbsp;<br>&nbsp;<br>}//end of class<br><br> </div> \
<div><strong></strong>&nbsp;</div> <div>thankin u <br>EXPECTING A REPLY AT THE \
EARLIEST<br>&nbsp;</div>



_______________________________________________
Rxtx mailing list
Rxtx@qbang.org
http://mailman.qbang.org/mailman/listinfo/rxtx


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic