-
Notifications
You must be signed in to change notification settings - Fork 789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arduino Mega ADK and NAK bug #238
Comments
Hello, I have a similar problem, that I am getting a lot of NAK. I did my testing with several examples and I am having always the NAK Issue when I am using this lib. (If I am using the follwoing lib the communication is more stable: https://github.com/aoabook/Arduino) To give a better understandig what I did so far: 1.) modived the example [https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/adk/ArduinoBlinkLED/ArduinoBlinkLED.ino] if (millis() - timer >= 300) { // Send data every 1s
timer = millis();
timer2 = timer;
rcode = adk.SndData(sizeof(timer), (uint8_t*)&timer);
timer = millis();
Serial.print(F("\r\nTimer: "));
Serial.print(timer2);
Serial.print(F(" - "));
Serial.print(timer);
Serial.print(F(" Delta: "));
Serial.print(timer - timer2);
if (rcode == hrNAK) {
Serial.print(F("\r\nNACK: "));
}
} 2.) Then I get the following output on the Serial Monitor:
3.) at the same time I am missing data on my android device. (Which is more or less in line with the NACK Outputs)
When I am using the change provided here I am get in the Serial Monitor and Android the same amount of data, but It takes very long to process on the Arduino side. Which leads into very high delay regarding the timestamps (way more than the defined 300ms), Also some how the data which is received on the Android side not matches 100% to the Arduino side:
Addtional Hint: When I am removing the read data function on Arduino side the delay is gone and the execution is again on a regular base. It would be great if somebody could look into that issue. |
Hi
We're working on a project with Android and Arduino Mega ADK, and we're hitting the NAK bug when using USB Host Shield 2 libraries.
We use a very simple protocol: Android writes a request, Arduino processes, writes back OK or error, Android reads and continues. In the Android side, the application is a C application running on top of the kernel reading and writing directly to the /dev/usb_accessory file, no Java or JNI involved.
With this configuration, I tried a simple LED blink test, and this happens:
After looking for the error in our code and failing, we looked at the Arduino libraries. This line was the issue (adk.cpp L.50):
epInfo[i].bmNakPower = (i) ? USB_NAK_NOWAIT : USB_NAK_MAX_POWER;
It looks like the first device doesn't repeat transmission in case of hitting the NAK bug. I don't know why the code is this way, but we changed the line to:
epInfo[i].bmNakPower = USB_NAK_MAX_POWER;
This solved our issue.
Why is there a special case for the first device? Can it be removed? Did anyone hit the same problem before?
Thanks
The text was updated successfully, but these errors were encountered: