Respected Friends, I wanted to establish a connection with serial port through my J2ME application.I am writting the following code it compiles(build) successfully but it is throwing exception which means that the Sun's J2ME wireless toolkit does'nt supports serial port connection,can any one please tell me the reason why the toolkit is not supporting serial port and if there is any mistake in the code what is it,the code is as follows:
The Wireless toolkit(WTK) does support the serial port communications. You can get the available list of ports for the WTK with the method, System.getProperty("microedition.commports") method, here you will get a comma seperated list.
I think if you have "com0" instead of "0", your program may work.
Hope this will solve your problem, if the problem still persist, please do post the exception you get so we can pin point the problem more accurately.
SCJP 1.4, SCMAD 1.0<br />SCWCD, SCBCD (in progress)
Salman Faraz
Greenhorn
Joined: Feb 14, 2005
Posts: 28
posted
0
Respected Mr Ransika deSilva , Thanks for your previous reply.According to your suggestion I tryed to use the System.getProperty("microedition.commports") method but it continiously returned me null does this means that no ports are supported.The code after making changes is as follows:
If you run the above code you will get null which means that no ports are present,how is this possible,since my PC has all three parallel,serial and USB ports.Can you please mail the correct code so that I can successfully establish connection with the serial ports.Please mail it as soon as possible since it is very important for me.
Thanking You, Salman Faraz.
Ransika deSilva
Ranch Hand
Joined: Feb 18, 2003
Posts: 524
posted
0
Hi, I am so sorry, I couldn't reply you soon, well the getProperty() returns a COMMA seperated list of all the the available ports. You have put the entire String to get the port, but what happens is the String looks like this, "COM1,COM2" so on. So you have to get one out of all these ports, get ONE out of the list. This should work fine. Regards.
Salman Faraz
Greenhorn
Joined: Feb 14, 2005
Posts: 28
posted
0
Respected Mr Ransika deSilva, I am sorry but Sir I was unable to understand your last reply(since I am not very genius or intellegent).If convinient for you than can you please make changes(which you are suggesting) in the code which I posted.I know that it will take a lot of your precious time but I would be thankful to you from the depth of my heart.
Thanking You, Salman Faraz.
Ransika deSilva
Ranch Hand
Joined: Feb 18, 2003
Posts: 524
posted
0
Hi, Sorry about my previous reply if you couldn't understand it. What I meant was that the getProperty() method signature is . Since you have many ports available, what you get as the return value is a "Comman String of ports". For example the returned String would look like: COM1,COM2,COM3
So you have to get one out of all the ports. You can do a substring like this.
Now you can use the myPort String in your Connection. Hope this is much clearer. Regards
Salman Faraz
Greenhorn
Joined: Feb 14, 2005
Posts: 28
posted
0
Respected Sir, I did the same way as yu suggested but I am getting "null" and nothing else.I am using J2ME wireless toolkit version1.0,on what version are you working.
Thanking You, Salman Faraz.
Ransika deSilva
Ranch Hand
Joined: Feb 18, 2003
Posts: 524
posted
0
Hi, Well I am using the WTK 2.1 version. I am not sure whether this is going to work with WTK 1.0 version. If possible try out it with 2.1 version. Regards.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.