Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

serial connection w/ palm  RSS feed

 
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
 
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
 
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??
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!