Skip to main content

pMEA, Access to serial ports

10 replies [Last post]
jldominguez
Offline
Joined: 2008-01-02
Points: 0

Hello, we need to communicate with a serial port to get access to a GPS device. I think we have the same problem described in this message:

http://markmail.org/message/osumbxclbtzuthep

But we are running Windows Mobile, not Linux. If I understood it well, they have recompiled the VM with a small change to let applications access serial ports.

Is that correct? Do Davy's CAB installers give access to serial ports? How? We always get an exception when we try. Do we have to recompile the VM as the person in that forum did?

Besides, when we read the GPS data, we need to write a few bytes to that port to let the data flow begin.

Regards,
Lucas

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
fchen2020
Offline
Joined: 2009-04-30
Points: 0

Hi Davy,

I follow your instruction to setup the environment and successfully compile and run GPSTest.java without error. But, it stucks on Found port 'COM1' without further data retreive from GPS receiver. Do I miss anything such as send a command or else? The code did not go through serialEvent(). Help and Thanks.

Fred

davyp
Offline
Joined: 2007-01-03
Points: 0

Are you sure your GPS is hooked up to COM1? I have my Bluetooth GPS configured to use
COM6. For an internal GPS, the COM1 port could be correct, but it is possible that the port is
already in use, or that you have to send some commands to this port first, or that you have to
use different speed/parity/stopbits etc. That is all I can think of right now.

Davy

orlandobarrera
Offline
Joined: 2010-03-08
Points: 0

sorry for reviving this thread but im having some issues regarding this topic..

Well, the deal is im also trying to read data from the GPS via a serial port connection, i have had little success.. first i try opening the port.. done, then, adding the serial Event listener interface.. done, and finally trying to read on incoming data.. well.. in all 3 phases randomly im having this weird problem that the app frezzes and i have to shut it down from the system memory, and sometimes it completely frezzes my PDA, so i have to remove the battery and then putting it again... i dont know if is something regarding the port or what.. but is driving me crazy... hope anyone could have a hint on what to do... thx in advance...

Davy Preuveneers

On Tuesday 07 October 2008 09:18:22 phonemeadvanced@mobileandembedded.org
wrote:
> Hello, we need to communicate with a serial port to get access to a GPS
> device. I think we have the same problem described in this message:
>
> http://markmail.org/message/osumbxclbtzuthep
>
> But we are running Windows Mobile, not Linux. If I understood it well, they
> have recompiled the VM with a small change to let applications access
> serial ports.
>
> Is that correct? Do Davy's CAB installers give access to serial ports? How?
> We always get an exception when we try. Do we have to recompile the VM as
> the person in that forum did?
>
> Besides, when we read the GPS data, we need to write a few bytes to that
> port to let the data flow begin.
>
> Regards,
> Lucas
> [Message sent by forum member 'jldominguez' (jldominguez)]

Hi Lucas,

A while ago, I was able to get my bluetooth GPS dongle to work (via COM6:)
with J9 using a WinCE implementation of RXTX. I added jcl.jar and comm.jar to
the classpath and put the rxtxSerial.dll in the library path, etc. I just
tested the same approach with a pMEA personal profile build and that works as
well.

I implemented the JNI interfaces for the Generic Connection Framework (GCF)
for Windows Mobile, and had to set "export CVM_INCLUDE_COMMCONNECTION=true"
before compiling the sources. I made a midlet that could read the NMEA
sentences of my GPS dongle using the javax.microedition.io.CommConnection
class. You can find the same class in cdc.jar, foundation.jar or
personal.jar. There does not appear to be a javax.comm package and e.g. no
CommPortIdentifier class in the subversion tree, so I think you will still
need external libraries to get serial port access this way, unless we build
javax.comm wrapper classes around the native code (commProtocol_md.c) that is
used by the javax.microedition.io.CommConnection class.

Cheers,
Davy

---------------------------------------------------------------------
To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
For additional commands, e-mail: advanced-help@phoneme.dev.java.net

jacarma
Offline
Joined: 2008-09-19
Points: 0

I'm trying to connect using:

CommConnection cc = (CommConnection)Connector.open("comm:com5",Connector.READ);
InputStream is = cc.openInputStream();
BufferedReader br = new BufferedReader( new InputStreamReader(is));
String line = br.readLine();

but I allways get:

javax.microedition.io.ConnectionNotFoundException: The requested protocol does not exist com5

System.getProperty("microedition.commports") returns
"com0,com1,com2,com3,com4,com5,com6,com7,com8,com9"
but none of this ports works

Davy Preuveneers

On Wednesday 08 October 2008 10:30:49 phonemeadvanced@mobileandembedded.org
wrote:
> I'm trying to connect using:
>
> CommConnection cc =
> (CommConnection)Connector.open("comm:com5",Connector.READ); InputStream is
> = cc.openInputStream();
> BufferedReader br = new BufferedReader( new InputStreamReader(is));
> String line = br.readLine();
>
> but I allways get:
>
> javax.microedition.io.ConnectionNotFoundException: The requested protocol
> does not exist com5
>
> System.getProperty("microedition.commports") returns
> "com0,com1,com2,com3,com4,com5,com6,com7,com8,com9"
> but none of this ports works
> [Message sent by forum member 'jacarma' (jacarma)]
>
> http://forums.java.net/jive/thread.jspa?messageID=303887
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
> For additional commands, e-mail: advanced-help@phoneme.dev.java.net

I am getting the same problem with CommConnection in phoneME Personal Profile.
The fact that you get "com0,com1,com2,com3,com4,com5,com6,com7,com8,com9" for
the system property, is because I defined the property as such. Don't rely too
much on this property, because it is a static hard coded property.

I documented my approach with pMEA+RXTX and some sample code over here:
http://www.cs.kuleuven.be/~davy/phoneme/other.htm

Cheers,
Davy

---------------------------------------------------------------------
To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
For additional commands, e-mail: advanced-help@phoneme.dev.java.net

jacarma
Offline
Joined: 2008-09-19
Points: 0

Thank you Davy,

I have downloaded
* GPSTest.java
* comm.jar
* jcl.jar
* rxtxSerial.dll

and tried to run It but I got "Port XXX not found." for everyport I try, and CommPortIdentifier.getPortIdentifiers() returns an empty collection.

Davy Preuveneers

On Wednesday 08 October 2008 16:01:47 phonemeadvanced@mobileandembedded.org
wrote:
> Thank you Davy,
>
> I have downloaded
> * GPSTest.java
> * comm.jar
> * jcl.jar
> * rxtxSerial.dll
>
> and tried to run It but I got "Port XXX not found." for everyport I try,
> and CommPortIdentifier.getPortIdentifiers() returns an empty collection.
> [Message sent by forum member 'jacarma' (jacarma)]
>
> http://forums.java.net/jive/thread.jspa?messageID=303960

In that case I am afraid I cannot really help you. The only thing I can think
of is testing whether a midlet on top of phoneME Feature can connect to your
serial port. A have written a small midlet before that uses the GCF to read
from a serial port, so I know it works on my device and I have confirmation
from other people that they connect to a serial port this way too. Here is a
another more advanced midlet that you could use to test your serial ports:

http://mob385.com/midlet/SerialPortTester.jad
http://mob385.com/midlet/SerialPortTester.jar

Regards,
Davy

---------------------------------------------------------------------
To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
For additional commands, e-mail: advanced-help@phoneme.dev.java.net

jacarma
Offline
Joined: 2008-09-19
Points: 0

Thank you Davy, we made it work recompiling the rxtxserial.dll, now we have only some minor problems with RXTX (with setSerialPortParams() ).

Thank you again

jldominguez
Offline
Joined: 2008-01-02
Points: 0

:)