Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot read the data from the serial port on the second time

 
Darren Alexandria
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good day!

I have made a program that reads data from a machine. When I deploy it for the first time, it gets the output successfully. But when I click the button so that I could get the data again, it doesn't read anymore.

ControllerServlet.java


ReadWriteC.java


read.jsp


Bean.java


the data outputs on the console but I can't show it on the JSP page.

Thanks.
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Darren Alexandria:

the data outputs on the console but I can't show it on the JSP page.


That's a lot of code and I don't really have the time to dig into it, but it appears that you are attempting to read a serial port with a servlet. Probably a bad idea. First, a serial port has a finite data buffer. If you aren't going to poll the servlet constantly, what will happen with the data? Second, you are using an asynchronous method to read data from the serial port. What if it doesn't get back to you in time (i think this is what's happening, see here for a discussion on synchronous and asynchronous serial port access). You should probably have a program accumulate the serial port data somewhere (database, file, message queue) and your servlet access that store.
 
Darren Alexandria
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good Day!

Thanks for your reply. Yes I am reading data from a serial port using a Servlet. If that's not a good idea then what else should I use? JSP?
I am outputting a 2 strings which is supposed to contain the data read.
One string is from the Servlet, and the other one is on the Action Class.
When the page is loaded and I click on the button for the first time,
I am able to get the (correct)data from the Servlet and a (correct but concatenated) data from the Action Class. On the succeeding clicks, still the string from the Servlet outputs the correct one, while the string in the Action Class became null. I will read the link that you provided and research on the asynchronous thing that you mentioned.


Thanks again.

Darren
[ October 10, 2007: Message edited by: Darren Alexandria ]
 
It is an experimental device that will make my mind that most powerful force on earth! More powerful than this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!