1

ER_BUS_BAD_HEADER_FIELD with Arduino Due?

asked 2014-11-05 08:01:02 -0700

joep gravatar image

updated 2014-11-05 15:25:22 -0700

Hi everyone,

I'm having some trouble getting an Arduino Due + Arduino Ethernet shield talking to a service running on a Linux VM. Here are the details.

I downloaded the alljoyn-suite-14.06.00a-src.tar.gz release from the allseenalliance.org/source-code web page and unpacked it on my Linux VM (running Debian 3.2.60-1+deb7u3 x86_64 in a VirtualBox VM on a OS X 10.9.5 host). I installed all the prerequisites and built the Linux code with

$ scons BINDINGS="cpp,c" SERVICES="about,config,onboarding"

According to "scons -h", the remaining default settings looked correct to me.

For the Arduino Due library, I built the "arduino" target in the "ajtcl" directory and copied the resulting AllJoyn library into my ~/Documents/Arduino/libraries folder on my MacBook.

I built the "AJ_basic_client" sample sketch for the Due board with the Arduino 1.5.8 IDE and uploaded it to the board.

On my Linux VM, I ran the "basic_service" binary from the ".../cpp/bin/samples" directory.

The result is that on the Arduino IDE console, I see this:

621.652 aj_net.cpp:209 AJ_Net_Connect(): connect() success: status=AJ_OK
621.710 aj_helper.cpp:409 AJ_StartClient(): Failed to connect to bus, sleeping for 10 seconds

and on the Linux console, I see this:

549.411 ****** ERROR ALLJOYN iodisp            ...e/src/Message_Parse.cc:862 | Message header has invalid endian flag 0: ER_BUS_BAD_HEADER_FIELD
549.411 ****** ERROR ALLJOYN iodisp            .../src/Message_Parse.cc:1048 | Failed to read message on :tVsDA7V1.7: ER_BUS_BAD_HEADER_FIELD

Before I dive into debugging this, I'd like to know if these sample apps as released in the 14.06.00a release should work as-is? Or is it possible they haven't been updated to the latest alljoyn core code?

UPDATE: Actually, it looks like the very first time the AJ_Main function is called in the AJ_basic_client sketch, everything works as it should. The next time, it fails in the AJ_Authenticate function because g_client.connected() (in AJ_Net_Recv) returns false. Then every second attempt to connect to the bus fails. (I.e. one success, one failure, one success, etc.)

Any suggestions for how to start debugging or fixing this?

Thanks for any advice.

JoeP

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-11-14 15:48:49 -0700

joep gravatar image

So after many hours spent inspecting AllJoyn and Arduino code down to the device driver level, I've come to the conclusion that the errors I'm seeing are actually normal and expected, given how the Arduino sketch is written.

The client sketch on the Due does an initial device discovery phase where it discovers what other devices are on the local network. It then connects to the bus (via the router running on my laptop) and makes a call to an advertised service. It receives a reply, then sleeps for 10 seconds before repeating the entire process.

Notice what's missing from the above description: it never disconnects from the bus, but on the next round, it starts with the discovery and bus connection again. Those messages (particularly the bus connection one) are out of sync with what the router/service are expecting because they think the client is still connected. So the router rejects the 2nd attempt to connect to the bus and disconnects the client. The client sees the rejected bus connection attempt and waits 10 seconds before trying again. This time, however, everything works because the router forcefully disconnected the client on the previous attempt.

Adding code to the client sketch to explicitly disconnect from the bus each "cycle" of the sketch makes everything work perfectly. Reworking the sketch so it only connects once also works.

edit flag offensive delete publish link more

Comments

https://jira.allseenalliance.org/browse/ASACORE-2213

ry.jones ( 2015-07-10 11:36:50 -0700 )edit
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2014-11-05 08:01:02 -0700

Seen: 206 times

Last updated: Nov 14 '14