Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7526977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:59:09+00:00 2026-05-30T03:59:09+00:00

I am trying to write a MATLAB GUI that uses the XBee-API interface to

  • 0

I am trying to write a MATLAB GUI that uses the XBee-API interface to talk to an XBee wireless radio on board an Arduino. The GUI mostly does data collection and parses incoming packets.

I want to do an addPacketListener as defined in the Developer’s Guide (see section “Receiving Packets”) to wait for packets to process. In Java, this is how it would be done:

xbee.addPacketListener(new PacketListener() {
    public void processResponse(XBeeResponse response) {
        // handle the response
    }
});

In MATLAB, I would do an addlistener() and set its callback to do my processing.

I don’t know much at all about Java, so I was wondering if it’s possible to set up the processResponse code a la MATLAB: can I do something like as follows:

function processResponse
    #% do response here
end 

>> xbee.addPacketListener(@processResponse)

I’m not sure if this made complete sense; basically what I’m trying to accomplish is to execute a callback once new packets are available for my XBee (which in Java is handled by addPacketListener).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:59:10+00:00Added an answer on May 30, 2026 at 3:59 am

    Let me know if I’m wrong, but it looks like you basically want to intercept XBee’s calls to PacketListener.processResponse(XBeeResponse x) and have MATLAB process the contents of the incoming XBeeResponse object. I’m not much of a MATLAB guru, but is it even possible to implement a Java class using MATLAB code, and then pass that class back to Java? My guess is probably not, but I could be wrong.

    I think the issue you’re dealing with here stems from the fact that it’s easy to make MATLAB calls on Java objects, but not the other way around. What I’d do is make a really simple implementation of PacketListener using Java code, and then use a third-party library like matlabcontrol to make function calls from your Java PacketListener implementation back out to MATLAB.

    I had to deal with this issue on a large software project that required a GUI written in Java to make calls on back-end code written in MATLAB, so I can vouch for matlabcontrol’s capabilities. Another important resource when controlling MATLAB from within Java, should you go this route, is undocumentedmatlab.com.

    EDIT

    One other thing to be wary of is threading on the Java side. You can have any number of Java threads making MatLab calls simultaneously, but MatLab will “sequentialize” all of the calls from Java. Let’s say Java needs to call the MatLab functions “f1” and “f2”. You set up two Java threads and each one calls either f1 or f2, simultaneously. MatLab will force one to wait for the other one to finish before starting the second function call, and it’s completely indeterminate which one will actually get called first.

    The reason I’m saying this is, whatever Java Thread calls the processResponse(XBeeResponse x) function will be blocked if it makes a call to MatLab and MatLab is already busy doing something else. It might be best to have your PacketListener cache incoming XBeeResponse instances so that XBee doesn’t get stuck waiting for MatLab to process data. Just something to keep in mind.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a Matlab code that, given a matrix, outputs 3 matrices
I'm trying to write a program that cleans data, using Matlab. This program takes
I am trying to write a Matlab program that accepts variables for a system
I am trying to write a function in Matlab that takes an RGB image
I'm trying to write a script in MATLAB that finds the location of the
I am trying to write a matlab mex function which uses libhdf5; My Linux
Trying to write a PowerShell cmdlet that will mute the sound at start, unless
Trying to write a couple of functions that will encrypt or decrypt a file
im trying to write an app that will display a list off lines from
I'm trying to write a regex function that will identify and replace a single

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.