Processing Sketch on Macbook Air Won’t Connect with XBee

HELP! My Macbook Air, running a Processing sketch, doesn’t connect with my XBee,
There are several anomalies that really have me confused. In fact, I’m totally stuck. Here are the details:

Hardware- The XBee is a Series 2 configured as a API Router. It is inserted into an XBee Explorer (SparkFun) and connected to my Macbook Air through a USB cable and an Apple USB-C to USB adapter.

Software- The MacBook Air is running OSX 10.14.6 (Mojave) and Processing 3.5.4. The FTDI driver is the native Apple driver.

Processing Sketch- I’ve snipped for brevity. And I’ve highlighted where the errors occur.
I started with a Null Pointer Exception and worked backwards to discover that the myXBee.open command fails:

/*
 * 2018 Desktop Application to receive and display sensor data via XBee network
 *
 * XBee Setup - Adapted from Sketch that draws a set of thermometers for incoming XBee Sensor data
 * by Rob Faludi http://faludi.com
 */
// Included Files
import java.util.Date;
import java.text.SimpleDateFormat;
import processing.serial.*; // used for communication via xbee api
import org.apache.log4j.PropertyConfigurator; // used to write to log file
import com.rapplogic.xbee.api.ApiId;
import com.rapplogic.xbee.api.PacketListener;
import com.rapplogic.xbee.api.XBee;
import com.rapplogic.xbee.api.XBeeResponse;
import com.rapplogic.xbee.api.wpan.RxResponseIoSample;

// Global Variables
// XBee Variables
XBee myXBee;                // creates, does not initialize a new XBee object
//String mySerialPort = "/dev/tty.usbserial-A700eE3B";    // This is the primary XBee port- the iMac
String mySerialPort = "/dev/tty.usbserial-A8004xCJ";    // This is the secondary XBee port- the Laptop
MyXBeeSample myXBeeSample;  // creates, does not initialize a new MyXBeeSample object
snip

void setup() {
snip

  try {
 **THIS DOES NOT FAIL**
  myXBee=new XBee();
  }
  catch (Exception e) {
    println("** Error creating xbee object: " + e + " **");
  }
  try {
 **THIS FAILS**
   myXBee.open(mySerialPort, 9600);    // opens the serial port defined above, at 9600 baud
  }
  catch (XBeeException e) {
    println("** Error opening XBee port: " + e + " **");
    println("Port--> "+mySerialPort);
  }
snip

void draw() {
try { 
**THIS FAILS as well**  
  myXBeeSample = new MyXBeeSample(myXBee);
  }
  catch (Exception e) {
    println("** Error assigning myXBeeSample: " + e + " **");
  }
   snip

Anomalies

  • This exact same Processing sketch and the exact same XBee(same XBee Explorer and same USB cable without the adapter) runs without any problem on my desktop iMac. The iMac is running OSX 10.13.6 (High Sierra) but it is still running Processing 3.5.4. This really baffles me. Why the difference in behavior between the desktop iMac and the Macbook Air ???

  • Using the Macbook Air, I can connect with this same XBee (same XBee Explorer and same USB cable with adapter) using XCTU. I can “see” the XBee network packets being received via a serial port opened by XCTU. Why the difference in behavior between XCTU and my Processing sketch ???

  • Using the Macbook Air and the Arduino IDE (1.8.12), I have no problem connecting with my Arduino boards and uploading sketches. Different USB cable. I thought this was important because both the XBee Explorer and the Arduino use FTDI chips. Why the difference in behavior between my Processing sketch and the Arduino IDE ???