API Mode? Do strings still need a <CR> appending?

I’m trying to set my Node Identity using API Mode, but I get no response?

In AT Command Mode it would be a simple ATNI JASON

Am I supposed to add a (ascii 13 or hex 0D) to the end of the string or not? Either way, it does not repond to the at command frame?

Here is my hex array :-

7E = start delimeter

0 = length LSB

A = 10 length (MSB)

8 = frame id for at command

1 = frame id

4E = N

49 = I

4A = J

41 = A

53 = S

4F = O

4E = N

D =

D5 = checksum

If I change the length to 9 and remove the hex 0D, it still does nothing?

Help anyone? please!!

Ok, which series XBee and which firmware?

According to the 802.15.4 firmware docs, yes the string is terminated with a CR.

The problem with your frame is that the Checksum is incorrect therefore the XBee silently ignores the frame.

Use a checksum of 0xD7 and let us know if it works.

Hi

Firmware : 1147, Series 2.5 , XBP24-B.

I changed the checksum and it worked! Many Thanks!

Do you know any VB.net ??, Here’s my calculation code, I believe I’m only supposed to use the lowest bit of the result?

            ' frame is ready now, calulate checksum
            Dim CHECKSUM_TOTAL As Long = 0
            Dim WRITE_BUFFER(HEX_FRAME_AT_COMMAND.Count) As Byte
            Dim POS As Integer

            ' process hex frame and calculate total checksum
            For POS = 0 To HEX_FRAME_AT_COMMAND.Count - 1
                WRITE_BUFFER(POS) = Convert.ToByte(HEX_FRAME_AT_COMMAND(POS), 16)
                CHECKSUM_TOTAL += WRITE_BUFFER(POS)
            Next

            ' set checksum
            CHECKSUM_TOTAL = CHECKSUM_TOTAL - WRITE_BUFFER(0) - WRITE_BUFFER(1) - WRITE_BUFFER(2) ' exclude first 3 bytes
            Dim LOWEST_BIT As Integer = CHECKSUM_TOTAL Mod &HFF
            Dim CHECKSUM As Integer = &HFF - (LOWEST_BIT)

            ' set checksum
            WRITE_BUFFER(POS) = CByte(CHECKSUM)

I’ve fixed it.

This line of code is wrong

Dim LOWEST_BIT As Integer = CHECKSUM_TOTAL Mod &HFF

&HFF = 255 and should be 256, so the correct line of code is

Dim LOWEST_BIT As Integer = CHECKSUM_TOTAL Mod 256

Thanks for you help in this matter.

Jason - UK :smiley:

Your welcome. That was an easy one.

have fun

I’m trying too, but I cant get X-CTU’s range test to work when the devices are in API Mode?

Put them in AT mode and range test works, same settings in API mode and nothing.

Is this expected?

Thanks

Jason. :?

On the PC Settings tab select the Com port with the API modem and check the API box.

I’ve gotten it to work.

The Range test is kinda funky and can be difficult to get working. So it isn’t just you.

I have the Enable API checked? on both?

It must be the settings, here’s a screen shot??

I set DH on 1 to SH on GCS-ALPHA (device 1)

and DL on 1 to SL on GCS-ALPHA (device 1)

then the reverse for UAV-ALPHA (device 2)

I cant change the MY setting, so I’m not using 16-address?? :?

I’ve read the manual and can’t see my error??

Thanks

Jason.

I do now recall that when I got the Range test working only the XBee connected to the PC was using API commands. The other unit, that had the loop-back, was in AT command mode.

You can not loop-back the serial lines of the XBee when it uses API. The output frames are not the same as the input frames therefore they will be ignored.

I think thats case, no range test for API Mode!

I’ve succesfully sent and received Remote AT Commands now and will be working on data packets today!

What are you using your xbee’s for?? :slight_smile:

What are you using your xbee’s for??

I am using Series 2 XBees with ZigBee firmware.

The network includes temperature, light and humidity sensors in the house, attic, garage and nursery (trees). Some are End devices other are Routers.

There is also a node on my robot with status and commands to/from the PC.

I started with a Digi connect box that allowed remote access from the internet but found this to be unneeded. Now the Coordinator is direct to a 115kbps RS232 Comm port and a Python script handles the interface.

My next project is a handheld ZigBee terminal to get status from any sensor. And I would like to add some XBees to control a few things around the house.

Thats really cool!

I’m experimenting with some UAV stuff, and would really like to use the Xtend device (it’s 900Mhz) and thats illegal in UK, so stuck with 2.4Mhz setup.

Ever had a problem reading a split data packet from your serial read?

The first thing I check is for byte 0 to be 0x7E (start delimiter), but sometimes it’s not, because the previous packet was not a full one, but split, some the current packet is the last X bytes of the previous one?

It’s feels like a serial problem, but it could be the transmitting Xbee setup??

:slight_smile:

I always fully buffer the data out of an XBee then parse out of the data buffer. On the PC the COM driver does the Port buffering and I pull one value at a time. Once the 0xFE, Start of Frame, is obtained then the entire frame is brought in and parsed including comparing the Checksum. The Data Payload is parsed out into a ring buffer for its target Task to use. This allows discontinuous Data Payloads as the Ring buffer is filled by one pointer and emptied by a second pointer. If the Task does have all the data yet and the Ring buffer is Empty, getting the next value is pending, Task waits for more data.

Does that help?

It does.

I was hoping I would’nt have to do this, but it seems like the only way!

Many Thanks

Jason. :smiley:

Ring buffer code is intimidating at first but once you write and use a few you’ll use them for many communication tasks. They do decouple the hardware pieces from the software pieces and removes many timing constraints.

waltr:
Ring buffer code is intimidating at first but once you write and use a few you’ll use them for many communication tasks. They do decouple the hardware pieces from the software pieces and removes many timing constraints.

On the AVRfreaks.net forum, projects section, there are many code samples that use ring buffers.

I don’t bother with the checksum because 802.15.4 has CRC checking for bit errors, with retransmission, etc.