Source of corruption
Thursday, January 25th, 2007I think I finally tracked down the source of the variable corruption mentioned in an earlier post. When the monitor program uploads the data, I am using the fork command which makes a duplicate copy of the running program, one of the programs continues running, the other one calls the shell script to upload the data and then is suppose to die. Well, there was one last command it was running. Im not sure what it did exactly, but it had something to do with resetting the serial port. I think it was changing some setting on the serial port which then caused the monitor program that kept running to not read the incoming data correctly. Everything is running smoothly after adding a call to exit() right after the call to the shell script.
Another change that I think is going to be a huge improvement, is monitoring the door sensor for state changes instead of watching for the switch to be hit. The problem with watching for it to be hit is, if the door lingered in a certain position it would just constantly be registering door hits. Changing to looking for a state change means that another door hit cant be registered until the door sensor registers going into an off state. So even if the door lingers in that one position, it will only register one door hit.
I also discovered what I think is a bug in the arduino code. I was comparing two variables, and if one was less than the other then I wanted to execute some code, but I was having some problems, because the code seemed to be executing when it shouldn’t be. It turned out that when the two variables were exactly the same, that for some reason, the arduino thought they were different. So taking that into consideration I changed the if statement and now things seem to be working as they should.