Announcement

Collapse
No announcement yet.

xpwLib write is very very slow

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • xpwLib write is very very slow

    I am having an issue where it takes 5-10 seconds for data that I transmit using the xpw.serialTransmit() xpwLib call to show up on UART channel 1 of the xPico dev kit. The gist of what I'm doing is below and the trimmed down javascript code is given further down:

    1) HTML page kicks off and in the page load section I:
    a) Queue up a bunch of queries to be sent to the xPico part and over the
    UART port. A response is expected from an attached MCU back over
    the web link.
    b) Then, kick off a function that checks for queued up writes/queries and
    sends the next available query/write to the xPico part. There is 100 ms
    between subsequent query/write.

    A few things to note:
    - The firmware has not been updated in 3 months
    - This is my first project involving any of AJAX/JS/HTML/CSS. I am largely a C# app and embedded C software guy. I could have done something very unintelligent with my AJAX control and that's the problem.
    - A decent number of images are displayed on the web page. Not sure if that has any bearing on xPico performance.

    :::Code:::

    const CMD_INTERPRETER_REFRESH_RATE_ms = 100;

    function CMD_GetInputFromHost()
    {
    var response = null;
    var clearedBuffer = false;

    if (DEBUG_MOCK_USER_INPUT === false)
    {
    xpw.serialTransact({
    line: "1",
    message: "", // required
    m: "1", // Optional, number of milliseconds to wait for
    done: function(data)
    {
    // Took out control code here for the sake of clarity
    // Non-time intensive stuff is done here
    }
    });
    }

    if (CMD_IsBusy === false)
    {
    CMD_CurrEntry = CMD_KeyOrRequest_Take();

    if (CMD_CurrEntry.cmdType != null)
    {
    CMD_IsBusy = true;
    CMD_SendKeyOrRequestUpdate(CMD_CurrEntry);
    }
    }

    setTimeout(function(){CMD_GetInputFromHost();},
    CMD_INTERPRETER_REFRESH_RATE_ms);
    }

    function CMD_SendKeyOrRequestUpdate(entry)
    {
    switch (entry.cmdType)
    {
    case CMD_COMMAND_TYPE.KEY:
    CMD_SendKeyUpdate(entry.payload);
    break;
    case CMD_COMMAND_TYPE.REQUEST:
    CMD_RequestParameter(entry.payload);
    break;
    default:
    console.warn("Key/Request update does not exist! Threw it
    away...");
    }
    }

    function CMD_RequestParameter(paramToken)
    {
    var theMessage = "REQUEST" + "," + paramToken;

    if (CMD_TOKEN_LIST[parseInt(paramToken, 10)] != null)
    {
    CMD_TxCmd(theMessage);
    }
    else
    {
    console.warn("The parameter requested does not exist!");
    }
    }

    function CMD_TxCmd(theMessage)
    {
    theMessage = theMessage + CMD_FRAME_TERM;

    if (DEBUG_MOCK_WEBPAGE_OUTPUT === false)
    {
    xpw.serialTransmit(
    {
    // Must be "1", "2" or "CDC_ACM" (new 1.5 firmware), if omitted or
    // some other value, defaults to "1"
    line: UART_Channel,
    message: theMessage,
    callback: function(data)
    {
    if (data.success === true)
    {
    // @todo do something here
    }
    else
    {
    console.log("Did not transmit serial data properly.");
    }
    }
    });
    }

    console.log("To UART: " + theMessage);
    }

  • #2
    A few things:

    - How do you determine that it takes 5-10 seconds? Is that based on actual hitting a button on web page to data coming out serial port, or is it based on the console log of the browser?
    - I noticed a typo in the documentation of the xpw JS library. The callback function for serialTransmit should be passed as "done:" parameter, not "callback:" parameter. I just pushed an update to the documentation in Github. Please change that in your code, otherwise your callback won't be executed.
    - Can you update to 1.5.0.0A17 and retry? There's speed improvements to WebAPI in 1.5 firmware (http://forums.lantronix.com/showthread.php?t=1291)
    - If you still see the issue with this firmware, can you capture Wireshark and the console log (Chrome or Firefox dev tools), and an FAE can help you analyze it

    Mariano

    Comment


    • #3
      Thanks Mariano, I will try updating the firmware and change 'callback' to 'done'.

      I did a few things to determine the 5-10 second delay (and truthfully, when 10+ messages are sent, some don't even get through). What I did:
      - Did console.log() just before the each message was sent using the xpwlib method call.
      - Monitored UART output using TeraTerm (looked at console, not log).
      - Saw that that the console.log() output had the correct timing, but the messages on the UART take forever or never show up. For instance, I might see 5 messages show up in the debug log (i.e. the xpwlib method call was invoked 5 times) in the web browser before the first message shows up in TeraTerm.

      Comment


      • #4
        Hmm, I can't replicate that. I would double check all flow control settings on the serial port. I'll also send you an email with contact information for the Field Applications Engineer for your area so that you can work directly to have them duplicate your issue.

        Mariano

        Comment

        Working...
        X