I’ve got an xbee xsc series radio and I’m trying to use binary command mode. This requires that that CMD/RTS pin be asserted high then a binary version of the command is sent to the radio. The CMD/RTS pin is then returned to low and the return read back from the radio. I cannot get this to work. (I have multiple radio’s communicating and non-binary (AT mode) works fine.) I’m using the spark fun regulated xbee explorer (with the RSSI LED removed to make it compatible with the new radios). To access the CMD pin I soldered a lead wire to the hole labelled CMD/RTS. I assert this HIGH by connecting it to a voltage divider connected to digital pin 7. (The voltage divider should deliver 3.3V from the 5V of the digital pin.
The code to send the command looks like this:
digitalWrite(CMD_PIN, HIGH);
Serial1.write(0x1c);
Serial1.flush();
digitalWrite(CMD_PIN, LOW);
Serial.println("Binary command sent");
int val1 = waitForByte(5000);
Serial.println("Return: ");
Serial.print(val1);
the waitForByte() method looks like this:
int waitForByte(int milliSecondTimeOut)
{
int inByte = -1;
int delayCounter = 0;
while (!Serial1.available() && delayCounter < milliSecondTimeOut) {
delay(1000);
delayCounter += 1000;
Serial.print(".");
}
if (delayCounter < milliSecondTimeOut) {
inByte = Serial1.read();
} else {
Serial.println("No value returned");
}
return(inByte);
}
Does anyone have working code that uses binary commands?