HTTP File Upload & Text Field Input Working
I recheck my functions to make sure that the three functions are doing the same thing as the one function. It turns it should be. Then, after some hacking and testing, I found out that the string I declared in the main function will be written into the SD card. I tried to declare the string declaration static, the string no longer is written in the SD card. I reported this finding to my supervisor, he told me that is likely a pointer problem. The next time I attempted was to declare the string static and it turns out the three functions is working perfectly. So I go on testing the working three functions with the HTTP upload, instead of declaring the string as static (which should not exist in the upload process because the data string will be transfer from the web browser and not defined in the code), I declared the problematic counter as static, the uploading process works properly for a 350 KB upload.
I again, reported this finding to my supervisor. He suggested me to look into the problem more closely, why and how by declaring a counter or string static would actually solve the problem. I then proceed to look into my functions more carefully. In the end, it turns out that the counter was not initialized everything I called the function. The counter is holding a random number, it messed up the whole process because it writes the data when it is not suppose to write it. By adding another line to always declare the counter zero every time the function is called, the upload works properly without needing to declare the counter as static. There is also a small hiccup during this process that I found my SD card broke because it was not recognized by the PIC and the computer, the adapter is working because I tested with another microSD card. I switched into another SD card that is the small model as the one I was using.
After the file uploading is working, it is time to work on the text field input. I started not getting the text field input to work correctly because it always writes everything including the protocol data. In the end, it turns out that I made a mistake in calculating the correct number to subtract. I subtracted an extra byte which overflow the write counter to its maximum instead zero, so it writes everything into the SD card. After the fix, the text field input is working properly as well.
During all of this testing, I found that the program will occasionally hang. But I did not give much attention to it because I wanted to make sure the basic uploading is working first. After I had done that, I reported to my supervisor about the hanging issue, and he asked me to look into it. It could be a bug in my code that made it hangs. I proceed in trying all kinds of method to make the program hang, but there are not 100% foolproof method in making the program hang. The program just likely to hang when the SD card is removed and reinserted when the program is running. And also the program seems to be continue hanging even if I reset it. After leaving the PIC off or read the card by computer, the program will likely not hang anymore, still it is not foolproof, there is a lot more to understand about it. I tried to put LED indicators into the program code, and it turns out the program was stuck at the initialization stage of the SD card and hangs there, yet this information does not help much.
I again reported my findings to my supervisor, he suggests me to look into the code properly and if necessary, write the whole MDD stack myself. I give a one last shot in trying to debug it, but in the end, I still couldn’t figure it out at all. I then decided to write my own MDD stack and start from scratches.