aspose file tools*
The moose likes Threads and Synchronization and the fly likes PROBLEM  IN  SYNCHRONIZING THREADS READING FROM  AND WRITING TO SERIAL PORT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "PROBLEM  IN  SYNCHRONIZING THREADS READING FROM  AND WRITING TO SERIAL PORT " Watch "PROBLEM  IN  SYNCHRONIZING THREADS READING FROM  AND WRITING TO SERIAL PORT " New topic
Author

PROBLEM IN SYNCHRONIZING THREADS READING FROM AND WRITING TO SERIAL PORT

zerfu tilla
Greenhorn

Joined: Apr 04, 2006
Posts: 5
HI,WHILE DOING OUR FINAL YEAR PROJECT WE
FAILED IN SYNCHRONIZING THE READING AND WRITING
OPERATION CONCUENTLY ON RS-232 SERIAL PORT
AS WE ARE IN NEED TO DO BOTH THE WRITING AND THE
READING OPERATION SIMULTANEUSLY,PLZZ
ANY BODY INTERSTED HELP US OR POST THE CODES
MY EMAIL ADRESS
zsamuelt@yahoo.com
THANKS FOR YOUR HELP
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18717
    
  40

Not sure if I understand you correctly, what do you mean you want to synchronize "TO DO BOTH THE WRITING AND THE READING OPERATION SIMULTANEUSLY"?

Do you mean that you are doing both simultaneously and need synchronization to protect it? or do you mean that you want to allow one thread to write and one thread to read simultaneously?



Regardless, synchronization can be done independant of the serial port. Just have only one object access the serial port API only, and do the synchronization only on that object.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
zerfu tilla
Greenhorn

Joined: Apr 04, 2006
Posts: 5
hi ,thanks henry
we were trying to use the rs-232 serial port
to accept and send data but we have to bothe
the accepting(reading) and sending(writing)
to occur simultaneausly,the port has not to be idle
while writing or reading doing one thing but has to
do both simultaneusly i think u get my idea
thanks
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18717
    
  40

i think u get my idea
thanks


Actually, I do not. My question was... are you trying to prevent simultaneous read and write by the use of synchronization, or trying to "loosen" synchronization to allow a protocol that supports simulateous transfers to work. These are two distinct and different questions.

Henry
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18717
    
  40

And BTW, it has been over a decade since I program drivers for the RS-232 port, so take this with a grain of salt. I am also making an assumption on your question for this answer. The assumption is that you are trying to "loosen" your synchronization.

Raw RS-232 does not allow simultaneous transfers in both directions at the same time. To do that you have to simulate it with a protocol -- Such as IP, SNA, BiSync, etc. And even then it is a simulated. The protocol is interlacing the transfers.

Adding threads doesn't fix this. When using threads, you need to work within the restrictions of the protocol that you are using.

Hope this helps,
Henry
zerfu tilla
Greenhorn

Joined: Apr 04, 2006
Posts: 5
HI HENRY,THAAKS AGAIN FOR YOUR IMMEDIATE RESPONSE
NOW I THINK YOU GET MY IDEA , WHAT WE ARE INTENDING
TO DO IS THAT ACESSING THE RS_232 PORT TO SEND FILE
AND AND TEXT MESSAGE WIRELESSLY USING ANTENNA TO ANOTHER
PC SO IN DOING SO,THE PERSON IN CHARGE WHILE SENDING
DATA OR TEXT MESSAGE HAS NOT TO WAIT LONG BY SENDING
ONLY HE HAS TO ACCEPT THE DATA ALSO,THOUGH THE CONCEPT
IS DIFFERENT IT IS LIKE APPLICATIONS IN MESSANGERS..LIKE YAHOO,
SKYPE ETC THE PERSON DO ALL THINGS AT THE SAME TIME.
SO IF THREAD CANNOT ALLOW AS TO DO SO HOW CAN WE DO SO
BY USING SOME OTHE METHODS
PLZ TRY TO SOLVE THE PROBLEM AGAIN
THANKS
zsamuelt@yahoo.com

zsamuelt@yahoo.com
 
 
subject: PROBLEM IN SYNCHRONIZING THREADS READING FROM AND WRITING TO SERIAL PORT