• Post Reply Bookmark Topic Watch Topic
  • New Topic

Threads - reading/writing to serial device

 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

Recently I have been tasked with a new project to resurrect an old piece of scientific kit which takes measurements of samples over time. Previously it was running with a DOS machine and a QBasic programme. Now we have decided to re-write in Java on a more modern PC with a GUI etc for user convenience.

The basic way this will work is I will have to send short commands to the hardware via a serial port and wait for any response that gets sent back. Problem is I know very little about communicating with hardware and also very little about threads because I have not had to use them before.

Does anyone have pointers for me about how this would be best approached? So far I have created a class called BoxCommunicator which implements Runnable. Ideally I would have two methods in here one called writeCommand() and one called readResponse or similar, but how would that work with the thread througout the life of the programme (maybe hundreds of individual reads/writes)??? Any pointers to example sof this sort of task?

thanks in advance
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should start by getting smart about the Java Comm API (Tutorial/ user's guide is here)
and Threads,
then start worrying about how to implement your particular problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!