I have written some simplified code to represent my problem. When either file is used separately, it works perfectly. However, when I try to utilize both, I have the "Connection closed . . ." error.
I have attached a small file that will throw this error. I am using an Arduino Mega with a YUN shield. I am loving this thing, except for this quirk.
Interesting. Possibly a firmware difference? I am using the latest firmware on the Yun shield. I debugged mine bit more. The updated code has some console statements that I used to debug. I managed to get the code to work by adding the time process. I have no idea why this makes any difference. I thought maybe it was the delay. So, I tried to replace it with a delay of 20 seconds. That didn't work. So, I went back to using the time process. Without it, the code would get stuck on the read or println statements, depending on the order of the files.
Does anyone have a clue on this? Why does the time process make a difference?
Model Dragino v2
Firmware Version Dragino-v2 common-2.0.5
Kernel Version 3.3.8
Are you also using an Arduino Mega R3? Mine is the Android version. So, it has the extra USB port to plug in a phone or tablet.
Maybe the issue is with the IDE.
I am running version 1.6.3 on Windows 8. I had to add the "Arduino Mega 2560 -- Yun" to the list of boards. I installed Samba server on the Yun and added two shared folders.
Amazing! That solved it. It is sooo much faster now when compiling, running, and executing. I believe the IDE was the issue. I am supposedly running the same version that I was running. But, it actually looks a little different. I had installed version 1.6.3 and upgraded to 1.6.5. However, removing and re-installing was the answer. Thank you for assisting me with this. Good job.