dcsimg
Problem using JAVA Comm, please help...
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Akshay_Prasad
Posted On:   Thursday, May 9, 2002 07:02 PM

I am having problems using the Sun JAVA comm, I am working on a WIN32 platform, specificallyt winNT, the thing is, it is able to connect to the serial port and all, but when I try and retrieve the responses, which is connected to the serial port, it takes ages to restrieve the response. This is whatr I am doing in = serialPort.getInputStream(); reader = new InputStreamReader(in); br = new BufferedReader(reader); ... ... ... input = br.readLine(); System.out.println(input); input = br.readLine(); System.out.println(input); input = br.readLine(); System.out.println(input); when it reaches the input = br.r   More>>


I am having problems using the Sun JAVA comm, I am working on a WIN32 platform, specificallyt winNT, the thing is, it is able to connect to the serial port and all, but when I try and retrieve the responses, which is connected to the serial port, it takes ages to restrieve the response. This is whatr I am doing



			
in = serialPort.getInputStream();
reader = new InputStreamReader(in);
br = new BufferedReader(reader);
...
...
...

input = br.readLine();
System.out.println(input);
input = br.readLine();
System.out.println(input);
input = br.readLine();
System.out.println(input);



when it reaches the input = br.readLine() thing it waits foir like 30 secs before it can print out anything. After that it prints out everything in split second.

When the reading part is called again, it again slows down, but this time it retrieve the second line is retrieved immediately after the first line(it waits before the first lien for 30 secs) but at teh thjird line it again waits for abt 30 secs to retrieve it.

Can any please help me... I am totally stuck here... thanks!

   <<Less

Re: Problem using JAVA Comm, please help...

Posted By:   Gordon_Murphy  
Posted On:   Thursday, May 9, 2002 09:51 PM

I'm not positive if this will work (since it kinda depends on the data you are sending), but try getting rid of the buffered reader. When you call readLine(), it keeps reading until it sees an end of line character(s). Try reading directly from the inputstream using the read() method (just cast the int it returns to a char), and see if it still takes 30 seconds.
About | Sitemap | Contact