This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

serial connection w/ palm

 
chris chayka
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am having a problem closing the serial connection with the palm. I am using cldc 1.02 with dataInputStream.
public void
closeStream()
{
try
{
dis = null;
dis.close();
}
catch(Exception iox)
{System.out.println("io exception at close stream");}
}
The exception above is caught, a thread doing a dis.readByte() is unlocked (i assume) and the program terminates. However, when I try and hotSync, I get an error message stating that the serial port is in use by another application. Am I missing something when closing the dataInputStream? If I do not set dis to null before closing, the program hangs due to the blocked thread.
Thanks very much in advance,
chris chayka
cchayka@elantech-inc.com
 
Richard Taylor
Author
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> dis = null;
> dis.close();
Don't you want those the other way round, maybe?
Closing a null won't do much...
------------------
Richard Taylor
Author of Professional Java Mobile Programming
 
chris chayka
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is true, however, if I reorder the close and null, the program hangs until a byte of data comes across the serial line to release a blocked thread. If the thread executing dis.readByte() does not receive anything, it waits and waits. Is there a way I can kill it or throw some kind of exception after closing the data input stream that will cause an exit?
Thanks again,
chris chayka
 
Vincent Leung
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody,
I got a problem writing to a palm serial port. The code is as follows:
Connector.open("comm:0;baudrate=9600");
The program compiles fine (using the Wireless toolkit). I converted it to a .prc using the MIDP for Palm but when I try to run it on a palm, the following exception is thrown:
unsupported protocol comm
I have tried replacing comm with comm. and com and neither of these works. Anyone got any ideas? Or is comm not supported yet in MIDP for palm??
 
What are you doing? You are supposed to be reading 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!