Skip to main content

problem during serial port communication

10 replies [Last post]
sandykhan
Offline
Joined: 2008-01-15
Points: 0

hi,
i want to communicate with a device (which has linux on it), through serial port, but the problem is that i am unable to see all of my ports. i have run the following utility program on the target device, given in CDC's documentation, to list down my comm ports.

String port1;
String ports = System.getProperty("microedition.commports");
int comma = ports.indexOf(',');
if (comma > 0) {
// Parse the first port from the available ports list.
port1 = ports.substring(0, comma);
} else {
// Only one serial port available.
port1 =ports;
}

but, it always lists just one port /dev/ttyS0. i'm sure about the availability of /dev/ttyS1 on the target as i have used it to boot the device. so, what could be the problem?

regards,
khan.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> hi,
> i want to communicate with a device (which has linux on it), through serial port, but the problem is that i am unable to see all of my ports. i have run the following utility program on the target device, given in CDC's documentation, to list down my comm ports.
>
> String port1;
> String ports = System.getProperty("microedition.commports");
> int comma = ports.indexOf(',');
> if (comma > 0) {
> // Parse the first port from the available ports list.
> port1 = ports.substring(0, comma);
> } else {
> // Only one serial port available.
> port1 =ports;
> }
>
> but, it always lists just one port /dev/ttyS0. i'm sure about the availability of /dev/ttyS1 on the target as i have used it to boot the device. so, what could be the problem?
>

Hi Khan,

That's just because we set "microedition.commports" by default to
/dev/ttyS0. You can disregard that if you know that /dev/ttyS1 is
correct. It's really just meant as a placeholder property value.

Can you use GCF to connect to /dev/ttyS1 on your target device and
communicate?

Hinkmond

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

sandykhan
Offline
Joined: 2008-01-15
Points: 0

> phonemeadvanced@mobileandembedded.org wrote:
>
> Hi Khan,
>
> That's just because we set "microedition.commports"
> by default to
> /dev/ttyS0. You can disregard that if you know that
> /dev/ttyS1 is
> correct. It's really just meant as a placeholder
> property value.
>
> Can you use GCF to connect to /dev/ttyS1 on your
> target device and
> communicate?
>
>
> Hinkmond
>
> ------------------------------------------------------
> ---------------
> To unsubscribe, e-mail:
> advanced-unsubscribe@phoneme.dev.java.net
> For additional commands, e-mail:
> advanced-help@phoneme.dev.java.net

hi hinkmond,
thanks for your support. i have tried to communicate with /dev/ttyS1, but an IOException was thrown when i tried to open the port. i booted the device with a serial cable connecting it with my linux machine. so, /dev/ttyS0 might be in use (and i think it is). i used the following code to open the port:

try {
CommConnection comPort = (CommConnection) Connector.open("comm:COM1");
} catch(IOException e) {
System.out.println("not opened");
}

i have also tried it by passing "comm:COM0" , "comm:COM2" , "comm:com1" , "comm:/dev/ttyS1" etc. as argument to Connector.open(), but the port was not opened and always IOException was thrown. so, i need help to open the serial port.

regards,
khan

Hinkmond Wong

> hi hinkmond,
> thanks for your support. i have tried to communicate with /dev/ttyS1, but an IOException was thrown when i tried to open the port. i booted the device with a serial cable connecting it with my linux machine. so, /dev/ttyS0 might be in use (and i think it is). i used the following code to open the port:
>
> try {
> CommConnection comPort = (CommConnection) Connector.open("comm:COM1");
> } catch(IOException e) {
> System.out.println("not opened");
> }
>
> i have also tried it by passing "comm:COM0" , "comm:COM2" , "comm:com1" , "comm:/dev/ttyS1" etc. as argument to Connector.open(), but the port was not opened and always IOException was thrown. so, i need help to open the serial port

Hi Khan,

Can you first verify you can use the Linux native tool minicom to
connect to your /dev/ttyS1?

Does this work on your device?

minicom dfl ttyS1

(You might need to build minicom for your device depending on which
Linux distro you are using)

Hinkmond

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

sandykhan
Offline
Joined: 2008-01-15
Points: 0

>
> Hi Khan,
>
> Can you first verify you can use the Linux native
> tool minicom to
> connect to your /dev/ttyS1?
>
> Does this work on your device?
>
> minicom dfl ttyS1
> You might need to build minicom for your device
> depending on which
> Linux distro you are using)
>
>
> Hinkmond
>
> ------------------------------------------------------
> ---------------
> To unsubscribe, e-mail:
> advanced-unsubscribe@phoneme.dev.java.net
> For additional commands, e-mail:
> advanced-help@phoneme.dev.java.net

Hi Hinkmond,

Instead of using minicom on my device, i used hyper-terminal of Windows XP to verify that whether i can connect to /dev/ttyS1 and /dev/ttyS2 or not?

My target device has 3 serial ports. The /dev/ttyS0 port of device was connected to my linux machine (to boot the device). And, I connected the other ports (i.e. /dev/ttyS1 and /dev/ttyS2) with a Windows XP machine (one at a time) and diverted the output of [b]cat[/b] command to the serial ports.

Both the ports were found to be available and fully functional, as the hyper-terminal window on Windows XP machine showed the exact contents of the file for both the ports.

After this, I need to know that how can i connect to the ports using CDC/Foundation Profile, as i am still unable to open the ports.

I am using the following code to open the port:

try {
CommConnection comPort = (CommConnection) Connector.open("comm:/dev/ttyS1");
}

And, the output of stack trace is:

javax.microedition.io.ConnectionNotFoundException: The requested protocol does not exist /dev/ttyS1

Whatever I pass in Connector.open(), its portion after "comm:" is taken as a protocol. And an exception occurs and says that requested protocol does not exist.

So, what could be the reason after the serial ports have been verified to be available?

Regards,
Khan.

Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
>
> Instead of using minicom on my device, i used hyper-terminal of Windows XP to verify that whether i can connect to /dev/ttyS1 and /dev/ttyS2 or not?
>
> ...
>

Hi Khan,

I'm assuming your device is a Linux device. Please let me know if it is
not.

If it is a Linux device, you'll need some way to test the connection
from the Linux side on the device itself, not from a Windows XP
connected to the port externally. That will only acknowledge the
external side of your port.

The way GCF works is that it needs to match the way you call the
connection from the internal device-side, not from the external side.

So, if I have a Linux device, I can use minicom (or in your case
something else) to run on the Linux device itself locally to check if
"/dev/ttyS0" is connectible or not from the internal side.

That's the only way to tell if using the following code for GCF using
CDC/Foundation profile will work:

> try {
> CommConnection comPort = (CommConnection) Connector.open("comm:/dev/ttyS1");
> }
>
> And, the output of stack trace is:
>
> javax.microedition.io.ConnectionNotFoundException: The requested protocol does not exist /dev/ttyS1
>
> Whatever I pass in Connector.open(), its portion after "comm:" is taken as a protocol. And an exception occurs and says that requested protocol does not exist

I think we have a bug in our Makefiles from what you mention above.

Did you build the binary yourself? If you did, try changing the
defs_cdc.mk Makefile:

In the cdc component
src/share/defs_cdc.mk
----

From this (at line #488)
com.sun.cdc.io.j2me.datagram.DatagramObject \
com.sun.cdc.io.j2me.datagram.Protocol \

To this:
com.sun.cdc.io.j2me.datagram.DatagramObject \
com.sun.cdc.io.j2me.datagram.Protocol \
com.sun.cdc.io.j2me.comm.Protocol \

Rebuild cvm then rerun your test.

If it works, I will fix it in our Makefiles.

Let us know if that's the problem or not.

Thanks,

Hinkmond

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

Gary Adams

This might help ...

cdc/build/linux/defs.mk:

# Only add GCF CommProtocol if requested
ifeq ($(CVM_INCLUDE_COMMCONNECTION),true)
ifneq ($(CDC_10),true)
CLASSLIB_CLASSES += com.sun.cdc.io.j2me.comm.Protocol
CVM_TARGETOBJS_SPACE += commProtocol_md.o
CVM_SRCDIRS += $(CVM_TARGETROOT)/native/com/sun/cdc/io/j2me/comm
endif
endif

cdc/build/share/defs.mk:291:
CVM_INCLUDE_COMMCONNECTION ?= false

cdc/build/share/top.mk:

# CVM_INCLUDE_COMMCONNECTION default: false
# Include GCF CommProtocol support. This feature is not supported
# on all platforms.

\gra

Hinkmond Wong wrote:
> phonemeadvanced@mobileandembedded.org wrote:
>>
>> Instead of using minicom on my device, i used hyper-terminal of
>> Windows XP to verify that whether i can connect to /dev/ttyS1 and
>> /dev/ttyS2 or not?
>> ...
>>
>
> Hi Khan,
>
> I'm assuming your device is a Linux device. Please let me know if it is
> not.
>
> If it is a Linux device, you'll need some way to test the connection
> from the Linux side on the device itself, not from a Windows XP
> connected to the port externally. That will only acknowledge the
> external side of your port.
>
> The way GCF works is that it needs to match the way you call the
> connection from the internal device-side, not from the external side.
>
> So, if I have a Linux device, I can use minicom (or in your case
> something else) to run on the Linux device itself locally to check if
> "/dev/ttyS0" is connectible or not from the internal side.
>
> That's the only way to tell if using the following code for GCF using
> CDC/Foundation profile will work:
>
>> try {
>> CommConnection comPort = (CommConnection)
>> Connector.open("comm:/dev/ttyS1");
>> }
>>
>> And, the output of stack trace is:
>>
>> javax.microedition.io.ConnectionNotFoundException: The requested
>> protocol does not exist /dev/ttyS1
>>
>> Whatever I pass in Connector.open(), its portion after "comm:" is
>> taken as a protocol. And an exception occurs and says that requested
>> protocol does not exist
>
> I think we have a bug in our Makefiles from what you mention above.
>
> Did you build the binary yourself? If you did, try changing the
> defs_cdc.mk Makefile:
>
> In the cdc component
> src/share/defs_cdc.mk
> ----
>
> From this (at line #488)
> com.sun.cdc.io.j2me.datagram.DatagramObject \
> com.sun.cdc.io.j2me.datagram.Protocol \
>
> To this:
> com.sun.cdc.io.j2me.datagram.DatagramObject \
> com.sun.cdc.io.j2me.datagram.Protocol \
> com.sun.cdc.io.j2me.comm.Protocol \
>
> Rebuild cvm then rerun your test.
>
> If it works, I will fix it in our Makefiles.
>
>
> Let us know if that's the problem or not.
>
>
> Thanks,
>
> Hinkmond
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
> For additional commands, e-mail: advanced-help@phoneme.dev.java.net
>

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

Hinkmond Wong

Gary Adams wrote:
> This might help ...
>
> cdc/build/linux/defs.mk:
>
> # Only add GCF CommProtocol if requested
> ifeq ($(CVM_INCLUDE_COMMCONNECTION),true)
> ifneq ($(CDC_10),true)
> CLASSLIB_CLASSES += com.sun.cdc.io.j2me.comm.Protocol
> CVM_TARGETOBJS_SPACE += commProtocol_md.o
> CVM_SRCDIRS += $(CVM_TARGETROOT)/native/com/sun/cdc/io/j2me/comm
> endif
> endif
>
>
> cdc/build/share/defs.mk:291:
> CVM_INCLUDE_COMMCONNECTION ?= false
>
> cdc/build/share/top.mk:
>
> # CVM_INCLUDE_COMMCONNECTION default: false
> # Include GCF CommProtocol support. This feature is not supported
> # on all platforms.

That's it! Thanks Gary!

Khan, please rebuild a new binary with CVM_INCLUDE_COMMCONNECTION=true.

Ex.

make CVM_INCLUDE_COMMCONNECTION=true J2ME_CLASSLIB=foundation

Hinkmond

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

sandykhan
Offline
Joined: 2008-01-15
Points: 0

Hi Gary and Hinkmond!

Thank you very much for your support. By setting "CVM_INCLUDE_COMMCONNECTION=true" i was able to open my serial ports. I have just opened it and haven't written any application to communicate with it. So, i might need ur help when i write one.

Thanks and Regards,
Khan.

Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> Hi Gary and Hinkmond!
>
> Thank you very much for your support. By setting "CVM_INCLUDE_COMMCONNECTION=true" i was able to open my serial ports. I have just opened it and haven't written any application to communicate with it. So, i might need ur help when i write one

Hi Khan,

Glad to hear you were able to open your serial ports using phoneME
Advanced! Please let us know how everything works out for your project
and if you have further questions or problems.

Thanks,
Hinkmond

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

Gary Adams

Which ports were configured for use with the Java stack on
your platform?
midp/src/configuration/configuration_xml/share/properties.xml

phonemeadvanced@mobileandembedded.org wrote:
> hi,
> i want to communicate with a device (which has linux on it), through serial port, but the problem is that i am unable to see all of my ports. i have run the following utility program on the target device, given in CDC's documentation, to list down my comm ports.
>
> String port1;
> String ports = System.getProperty("microedition.commports");
> int comma = ports.indexOf(',');
> if (comma > 0) {
> // Parse the first port from the available ports list.
> port1 = ports.substring(0, comma);
> } else {
> // Only one serial port available.
> port1 =ports;
> }
>
> but, it always lists just one port /dev/ttyS0. i'm sure about the availability of /dev/ttyS1 on the target as i have used it to boot the device. so, what could be the problem?
>
> regards,
> khan.
> [Message sent by forum member 'sandykhan' (sandykhan)]
>
> http://forums.java.net/jive/thread.jspa?messageID=265530
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
> For additional commands, e-mail: advanced-help@phoneme.dev.java.net
>
>

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