×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    1

    Arrow Serial port connection problem

    Hello All
    I want to send and receive data through the serial port of the mobile , but it doesn't work , i handled the exception from the "open" function the exception is as follows:
    "javax.microedition.io.ConnectionNotFoundException:The requested protocol does not exist
    comm:com0;baudrate=19200"
    and i tried many times to change the protocol parameters which path to the "open" function, but there is no use from this, i don't know want i can do, i thinking in two things the fault maybe in them
    1- the mobile which we try on in is series 40 NOKIA 6020 , and i think this mobile may be can't support the serial connections , or need spetial way
    2- I reed in the book , when an application wanna send to the serial port must have a permission form the system to access it
    the book says:

    "Access to serial ports is restricted to prevent unauthorized transmission or reception of data. MIDlet suites needing to use serial ports must request the javax.microedition.io.Connector.comm permission for Trusted MIDlet suites as described in Section 18.3, "Trusted MIDlet Suite Security Model."

    and in my program i do not know how i can do this

    my code as follows:

    //In command Action function in the displayable class
    if (command==Send) {
    try {

    CommConnection cc = (CommConnection) Connector.open("comm:com0;baudrate=19200");

    OutputStream os = cc.openOutputStream();
    os.write(97);//A
    os.write(98);//B
    cc.close();
    os.close();

    } catch (IOException ex) {
    alert2.setString(ex.toString());
    Display.getDisplay(MIDlet1.instance).setCurrent(alert2);
    }
    }
    I need help please , i do not knaw exactaly where is the fault or how i can fix it ,please help me

  2. #2
    Super Contributor
    Join Date
    Mar 2005
    Location
    Paris
    Posts
    814

    Re: Serial port connection problem

    did you put the authorisation request in your .jad descriptor ?
    did you sign your app ? (it may be required as you need special authorisation)

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    9

    Re: Serial port connection problem

    Hi, i'm having the same problem also. To be precise, when i run my app using WTK2.0, the following code always returns null, which means it cannot findany com port.
    port = System.getProperty( "microedition.commports");



    can you explain in details how do i put the authorisation request in the jad? and how do i sign the app? thx!

  4. #4
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: Serial port connection problem

    hi,

    #1
    it could be depending on machine that microedition.comports return null - I've got "0,1" while testing on my WinXP lappier in Sun WTK 2.2 emulator,

    #2
    .....
    The new security model introduced in MIDP 2.0 is protects the phone and the user from malicious applications by restricting access to APIs that are considered sensitive. In general the midlet is granted only minimal access to these APIs, meaning that the user is asked for confirmation every time the API is accessed.
    ...........
    The developer can also sign the MIDlet with a certificate so the MIDlet has less restricted access to the sensitive APIs.
    .....
    For more information on signed MIDlets, see Tutorial on Signed Midlets (http://www.forum.nokia.com/info/sw.n...1_en.pdf.html).
    in FAQ section:
    http://discussion.forum.nokia.com/fo...85&postcount=2

    hth,
    regards,
    Peter

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    9

    Re: Serial port connection problem

    Hi,
    thx for your reply! But I can't seem to figure out why i'm using the same WTK2.2 and win XP but i can't get the same results. could you email me a the sample code for serial communication u r using? my email address is u0307587@nus.edu.sg .

  6. #6
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: Serial port connection problem

    hi,

    huh, I'm newbie, don't worked with all api yet
    try FN (Nokia) sample:
    http://www.forum.nokia.com/info/sw.n..._v1_0.zip.html

    hth,
    regards,
    Peter

  7. #7
    Registered User
    Join Date
    Sep 2006
    Posts
    9

    Re: Serial port connection problem

    Hi thx for your useful link.

    I tried the sample code at
    http://www.forum.nokia.com/info/sw.n..._v1_0.zip.html, when i run it, i got the following output:

    System.getProperty(mircoedition.commports) got ports =0,1
    Failed with classjava.lang.RuntimeException: No COM port found in System Property

    I identified the code that is in question:
    Code:
    Tracer.outln("Calling System.getProperty(microedition.commports)", t);
            String ports = System.getProperty("microedition.commports");
            Tracer.outln("got ports="+ports, t);
            i = ports.indexOf("COM", 0);
            if(i==-1)
            {
                throw new RuntimeException("No COM port found in System Property");
            }
            System.out.println("System.out redirection ACTIVE!");

    My question is:
    1. Do we have to run the MIDlet in the phone? or if we run in WTK we can get the results?
    2. How come the System-getProperty returns port0,1 found, yet i=-1?
    Do you have the same problem?

    thanks for ur help!!

  8. #8
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: Serial port connection problem

    hi,

    that's stated in MIPD 2.0 docs that microedition.comports valued can be combined with "COM",

    MIDP docs also contains different way of getting comports:
    Code:
     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;
     }
    regards,
    Peter

  9. #9
    Registered User
    Join Date
    Mar 2007
    Posts
    4

    Smile Re: Serial port connection problem

    Quote Originally Posted by ayman_eng2006
    Hello All
    I want to send and receive data through the serial port of the mobile , but it doesn't work , i handled the exception from the "open" function the exception is as follows:
    "javax.microedition.io.ConnectionNotFoundException:The requested protocol does not exist
    comm:com0;baudrate=19200"
    and i tried many times to change the protocol parameters which path to the "open" function, but there is no use from this, i don't know want i can do, i thinking in two things the fault maybe in them
    1- the mobile which we try on in is series 40 NOKIA 6020 , and i think this mobile may be can't support the serial connections , or need spetial way
    2- I reed in the book , when an application wanna send to the serial port must have a permission form the system to access it
    the book says:

    "Access to serial ports is restricted to prevent unauthorized transmission or reception of data. MIDlet suites needing to use serial ports must request the javax.microedition.io.Connector.comm permission for Trusted MIDlet suites as described in Section 18.3, "Trusted MIDlet Suite Security Model."

    and in my program i do not know how i can do this

    my code as follows:

    //In command Action function in the displayable class
    if (command==Send) {
    try {

    CommConnection cc = (CommConnection) Connector.open("comm:com0;baudrate=19200");

    OutputStream os = cc.openOutputStream();
    os.write(97);//A
    os.write(98);//B
    cc.close();
    os.close();

    } catch (IOException ex) {
    alert2.setString(ex.toString());
    Display.getDisplay(MIDlet1.instance).setCurrent(alert2);
    }
    }
    I need help please , i do not knaw exactaly where is the fault or how i can fix it ,please help me

    Hi,
    I sugget you use the following line instead:

    CommConnection cc = (CommConnection) Connector.open("comm:#;baudrate=19200"); where '#' is a number as according to my experience with this type of connection, this protocol only accept numeric values. My application runs on the emulator when using it that way and it's ok for testing purposes but for the real device test, you need to find out the correct protocol is. I'm still working on it :-)

  10. #10
    Registered User
    Join Date
    May 2007
    Posts
    1

    Lightbulb Re: Serial port connection problem

    Quote Originally Posted by njzk2
    did you put the authorisation request in your .jad descriptor ?
    did you sign your app ? (it may be required as you need special authorisation)
    "MIDlet-Permissions: javax.microedition.io.Connector.comm"
    But it didnt do much. Still got microedition.commports null
    Last edited by gothmog; 2007-05-23 at 20:42.

Similar Threads

  1. Problem MMC+USB Connection
    By Fede81 in forum General Development Questions
    Replies: 3
    Last Post: 2006-07-19, 15:21
  2. HTTP Direct Connection without null serial port cable
    By jgarpu in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2004-01-02, 12:34
  3. Series 60 serial port problem
    By SergeyN in forum Mobile Java General
    Replies: 0
    Last Post: 2003-11-18, 15:47
  4. 7650 connection through Bluetooth Serial port ?
    By asabulu in forum Bluetooth Technology
    Replies: 2
    Last Post: 2002-11-21, 14:09
  5. Access to serial port signals in BT serial port emulation
    By ilkas in forum Bluetooth Technology
    Replies: 0
    Last Post: 2002-08-09, 09:45

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×