×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    Feb 2007
    Posts
    18

    Using Bluetooth serial port in MIDlets (nokia 9500 issue)

    Hi,

    I've created a midlet that reads data from a bluetooth GPS. It works perfectly on for example Nokia 6600, but gives the error message below on nokia 9500:

    Reason code: E32USER-CBase
    Number Code:40

    I googled on this and found the issue below:

    KIJ000109
    Another issue is that the InputStream cannot use a bigger byte array than 512 bytes when reading stream. A bigger byte array may crash the MIDlet.
    Solution to the stream size issue: Do not use a bigger byte array than 512 bytes. Read the input stream in a loop or keep the whole length of the stream under 512 bytes.(http://forum.nokia.com/document/Forum_Nokia_Technical_Library/contents/FNTL/Using_Bluetooth_serial_port_in_MIDlets.htm)

    I consider this a very likely reason, because my midlet gets data continously from the GPS so it may happen that this limit is exceeded.

    My question is: how should I modify my code to avoid this error? The data is coming continously from the GPS so I guess I can't limit the input. I'm thinking about reseting regularly somehow the inputstream, but couldn't figure out how to do this.
    I would greatly appreciate any suggestions on this.
    Here is my code to modify:

    // connecting to BT GPS device
    public void connect()
    {
    state = CONNECTING;
    try
    {
    // kapcsolodas
    connection = (StreamConnection) Connector.ope(serviceURL, Connector.READ);
    reader = new InputStreamReader(connection.openInputStream());

    }
    catch (IOException ex)
    {
    ex.printStackTrace();
    midlet.Dump(StrErrorConnFailed);
    }

    }

    // continous reading from BT GPS device
    public void run()
    {

    // folyamatos adatolvasas
    try
    {
    String data="";
    int c;

    while((c=reader.read())!= LINE_DELIMITER)
    {
    data += (char)c;
    }

    btm.appendRawData(data);

    }

    catch (IOException ex)
    {
    midlet.Dump(ex.getMessage());
    }


    }

    Thanks a lot!
    Örs

  2. #2
    Registered User
    Join Date
    Dec 2005
    Location
    Brazil
    Posts
    1,884

    Re: Using Bluetooth serial port in MIDlets (nokia 9500 issue)

    Hi Ors,

    If i got it right you can use the public int read(char[] cbuf,
    int off,
    int len)
    throws IOException
    method of InputStreamReader class instead of the no-arg version, read(). Just provide the array with size equals to 512 and add to secondary buffer as required while in the loop. I am not sure if it's going to work properly as it's related to a known Nokia issue, though.

    Please do not crosspost as below and create your own threads (no hijacking) as well so this forum will be kept organized, ok?
    http://discussion.forum.nokia.com/fo...ad.php?t=87666

    Hope this helps
    Juarez Alvares Barbosa Junior - Brazil

  3. #3
    Registered User
    Join Date
    Feb 2007
    Posts
    18

    Re: Using Bluetooth serial port in MIDlets (nokia 9500 issue)

    Hi,

    Juarez, thanks for your answer! According to your recommendation I managed to avoid the error mentioned below. Unfortunately the problem is not solved, I ran into another error: Program: jes-232-java-comms, Reason code: KERN-EXEC, Reason number: 3

    So I created a demo code to isolate this error. It is caused by the "read" line with bold. Any idea what is the reason, or how to avoid it? I know that this code has to work somehow, because I found and decompiled another midlet, and it runs perfectly with similar code (unfortunately it was obfuscated).

    Let me know if you have any idea how to move forward with this!
    Thanks a lot!
    Örs

    Here is the test code:

    public void run()
    {
    if (!isConnected()) connect();
    try
    {
    int n=0;
    if (stream!=null)
    {
    n = stream.available();
    if (n>2048) stream.skip(n);
    else
    {
    int i = 0;
    int c;
    // the line below causes panic error (Reason code: KERN- EXEC, Reason number: 3) after run a couple of times
    while ((c=stream.read()) >-1)
    {
    i++;
    if ((c==LINE_DELIMITER)||(i>=256)) break;
    // do something with the data
    }
    }
    }
    }
    catch (Throwable th)
    {
    midlet.Dump("skip'n'read error: " + th.toString());
    }
    }
    Last edited by orsteglasy; 2007-02-28 at 23:32.

  4. #4
    Registered User
    Join Date
    Nov 2006
    Posts
    1

    Re: Using Bluetooth serial port in MIDlets (nokia 9500 issue)

    Hi Ors,

    Have you tried doing what juarezjunior recommended? If i read your requirment correctly, it would look something like this:

    Code:
    byte[] buffer = new byte[512];
    int c;
    while ((c=stream.read(buffer, 0, 512)) != -1) 
    {
        // do something with buffer here
    }
    Hth

  5. #5
    Registered User
    Join Date
    Feb 2007
    Posts
    18

    Re: Using Bluetooth serial port in MIDlets (nokia 9500 issue)

    Hi,

    Yes, I tested the code recommended by Juarez, but it gives the same error message as in the first post (E32USER-CBase, 40). Then I tried to use the code shown in my previous post, it's from a decompiled midlet, which do the same task perfectly on nokia 9500. I really don't understand the situation because we have the same read-code but my midlet crashes the other one doesn't, so there must be a solution for this. Do you have any idea what other factors may influence this behavior? Or how is it possible to "debug" this error, and figure out the fix?

    I would really appreciate your help!
    Thanks!
    Örs

  6. #6
    Registered User
    Join Date
    Dec 2005
    Location
    Brazil
    Posts
    1,884

    Re: Using Bluetooth serial port in MIDlets (nokia 9500 issue)

    Hi Örs,

    Nice to know you managed to solve your first problem.

    "I ran into another error: Program: jes-232-java-comms, Reason code: KERN-EXEC, Reason number: 3 "
    I am not sure but it seems to be an error by the low-level implementation. Let's see if someone else can help you this time.

    Best,
    Juarez Alvares Barbosa Junior - Brazil

  7. #7
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    I try to debug this issue, too. Is that other non-affected MIDlet using L2CAP or SPP, too?

  8. #8
    Registered User
    Join Date
    Feb 2007
    Posts
    18

    Re: Using Bluetooth serial port in MIDlets (nokia 9500 issue)

    Hi traud,

    Sorry for answering late, I was away from my computer for a couple of days.
    Yes, the other midlet uses the same SPP architecture. I sent you a letter.
    Örs
    Last edited by orsteglasy; 2007-03-10 at 08:38.

  9. #9
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    150

    Arrow Re: Using Bluetooth serial port in MIDlets (nokia 9500 issue)

    Hi orteglasy,

    I have spent a lot of my time trying to sort this problem out but I haven't solve it yet! Last summer, I lost almost three months (in my project to get my Engineering Degree) trying to work my MIDlet which used the BT (SPP) and HTTP connections but I didn't get it!
    http://discussion.forum.nokia.com/fo...ad.php?t=87666

    Although I updated the firmware to the last available version, the same problem appeared again! Nowadays, it continues arising again!

    My staff then decided to buy a new Nokia phone, the N93 model, so we discovered in October that the SPP worked perfectly! On the contrary, we have found one JVM Error, not only in the N93 phone, in Sony-Ericsson models too, but this is another story!

    To sum up, I think that it is possibly a JVM/Symbian problem because the KERN-EXEC or the E32USER reasons always arise!

    Read this table with all the Symbian errors that I had while I was testing the Nokia 9500 with my MIDlet application:

    TEST PROGRAM REASON CODE REASON NUMBER
    1 Main KERN-EXEC 3
    2 jes-39c-java-comms@14437e KERN-EXEC 3
    3 jes-c8-java-comms@144378 E32USER-Cbase 40
    4 Main USER 42
    5 jes-121-java-comms@14437e E32USER-Cbase 40
    6 jes-f5-java-comms@144375 E32USER-Cbase 40
    7 jes-290-java-comms@14437e KERN-EXEC 3
    8 jes-f4-java-comms@14437d E32USER-Cbase 40
    9 jes-1ba-java-comms@14435d E32USER-Cbase 40
    10 jes-11a-java-comms@14435d E32USER-Cbase 40
    11 JFServerMidp2[00000000]0001 KERN-EXEC 3
    12 jes-dc-java-comms@14435d E32USER-Cbase 40
    13 jes-e3-java-comms@14435d E32USER-Cbase 40
    14 jes-d4-java-comms@14436b KERN-EXEC 0

    Those are the possible causes of the KERN-EXEC panic code:

    Category: KERN-EXEC

    These panics represent program errors which are detected by the Kernel Executive. Typically, they are caused by passing bad or contradictory parameters to functions. Threads which cause exceptions also raise a KERN-EXEC panic.

    The thread causing the panic is terminated.

    0


    This panic is raised when the Kernel Executive cannot find an object in the object index for the current process or current thread using the specified object index number (the raw handle number).

    1


    This panic is raised as a result of trying to suspend a thread, set the priority of a thread or set the priority of a process. The panic occurs when:

    *

    the process, which is the target of the set priority operation, is protected and is not the same as the process invoking the set priority operation
    *

    the thread, which is the target of the suspend or set priority operation, is protected and is not the same as the thread invoking the suspend or set priority operation.

    3


    This panic is raised when an unhandled exception occurs. Exceptions have many causes, but the most common are access violations caused, for example, by dreferencing NULL. Among other possible causes are: general protection faults, executing an invalid instruction, alignment checks, etc.

    4


    This panic is raised when the Kernel attempts to free a message, an RMessage, when that message is not in the accepted state. This panic is probably caused by a breakdown in client/server relations.

    6


    This panic is raised by the Kernel when the current thread attempts to read from a chunk using RChunk::Read() and the specified start position is one of:

    *

    negative
    *

    greater than or equal to the current number of bytes committed to the chunk. i.e. the value returned by the RChunk::Size().

    7


    This panic is raised by the Kernel when the current thread attempts to write to a chunk using RChunk::Write() and one of the following is true:

    *

    the specified start position is negative
    *

    the specified start position is greater than or equal to the current number of bytes committed to the chunk, i.e. the value returned by RChunk::Size()
    *

    the specified start position plus the length of the descriptor passed to RChunk::Write() is greater than the current number of bytes committed to the chunk, i.e. the value returned by RChunk::Size().

    9


    This panic is raised by the Request() member function of the DLogicalChannel() Kernel object, which issues asynchronous requests to a device. The panic is caused when a request, as identified by the specified request number, has previously been made and this request is still outstanding.

    10


    This panic is raised by the Request() member function of the DLogicalChannel() Kernel object, which issues asynchronous requests to a device. The panic is caused when the specified request number is greater than or equal to the maximum number of requests supported per device driver (defined by the constant KMaxRequests in k32std.h). The panic also occurs if the request is invalid.

    12


    This panic is raised by Kern::EventCaptureHook() if an event capture hook has already been designated.

    13


    This panic is raised by Kern::EventReleaseHook() if the current thread is not the designated event capture hook.

    14


    This panic is raised when an attempt is made to set the priority of a user process to an illegal value, or to set the priority of a user thread to an illegal value.

    The permitted priority values for a user process are a subset of the values defined by the TProcessPriority enum. The permitted values are:

    *

    EPriorityLow
    *

    EPriorityBackground
    *

    EPriorityForeground
    *

    EPriorityHigh

    The permitted priority values for a user thread are a subset of the values defined by the TThreadPriority enum. The permitted values are:

    *

    EPriorityMuchLess
    *

    EPriorityLess
    *

    EPriorityNormal
    *

    EPriorityMore
    *

    EPriorityMuchMore
    *

    EPriorityRealTime
    *

    EPriorityAbsoluteVeryLow
    *

    EPriorityAbsoluteLow
    *

    EPriorityAbsoluteBackground
    *

    EPriorityAbsoluteForeground
    *

    EPriorityAbsoluteHigh

    15


    This panic is raised when a timer event is requested from an asynchronous timer service, an RTimer, and a timer event is already outstanding. It is caused by calling either the At(), After() or Lock() member functions after a previous call to any of these functions but before the timer event requested by those functions has completed.

    17


    The panic is raised when the Kernel tries to close a thread's heap and finds that the access count is negative. As the heap may be shared, the owning process is panicked.

    18


    This panic is raised by the Request() member function of the DLogicalChannel() Kernel object, which issues asynchronous requests to a device. The panic is caused when the current thread is different from the thread which created the channel.

    19


    This panic is raised by the Kernel when a server program makes a request to receive a message, i.e. when it calls the Receive() member function of RServer, the handle to the Kernel side server object. The panic occurs when a receive message request has previously been made and is still outstanding.

    20


    This panic is raised by the Kernel when a request for an event (as originated by a call to UserSvr::RequestEvent(), defined in e32svr.h) is made while a previously made request is still outstanding.

    21


    This panic is raised when registering the screen-switch-on handler; the panic occurs when the handler is not the window server.

    24


    Introduced in 6.0: This panic is raised when the maximum length of the descriptor passed to RProcess::CommandLine() is smaller than tbe length of the command line data.
    Can you give me the code test that hypothetically works in the Nokia 9500? Would you be able to paste that code in this thread again? Thanks in advance. I would like to test it in the Nokia 9500 and change it to focus the problem!

    Please, keep me inform if you find out some light and news concerning to this issue!

    I hope this comment will help you and all the people with Symbian panic errors using the BT SPP and the Nokia 9500 phone!

    BR.

    Summerman.

  10. #10
    Registered User
    Join Date
    Feb 2007
    Posts
    18

    Re: Using Bluetooth serial port in MIDlets (nokia 9500 issue)

    Hi Summerman,

    Thanks for your reply. The code of the other mildet works not just hypothetically but in real life too! It may contain the solution for this problem, but it's too long and complex to paste here. But I can send it to you if you write me a letter (I can't write a letter to you because it's disabled). Once the solution is found we can paste the final results and share it in this thread.

    Thx!
    Örs

  11. #11
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    150

    Lightbulb Re: Using Bluetooth serial port in MIDlets (nokia 9500 issue)

    Hi orteglasy,

    Please, active the reception of e-mails from Forum Nokia members in the options of your personal account! I haven't be able to write to you! Now, my account is temporarily available to receive e-mails from other Forum Nokia members so please, write to me that code you mentioned or those comments that you consider very important information!

    BR.

    Summerman.
    Last edited by Summerman; 2007-03-11 at 20:26.

  12. #12
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105

Similar Threads

  1. ###Upgrading Firmware###
    By zahid44 in forum General Development Questions
    Replies: 27
    Last Post: 2008-10-21, 07:17
  2. Nokia Mobile VPN Client
    By marcyl in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2003-12-01, 14:47
  3. Nokia 6310i bluetooth link with Sony laptop
    By MikeCrouch in forum Bluetooth Technology
    Replies: 1
    Last Post: 2002-10-30, 16:48

Posting Permissions

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