Start: 9:30
- Confirmed that the PC is not sending data by opening the serial console in the arduino IDE and sending 1 byte manually. The arduino’s receive light blinked and the sending light turned on continuously as expected. It has occurred to me, that it should not be sending messages continuously.
- Now that the state machine is in better order, I can make the initialization non-blocking. This was a untested, temporary solution and may be the cause of the PC not sending.
- Made a change to the windows ComMgr so it will return false if the port does not open properly. This will trigger an ERROR state, which will print out a “cannot open port” message from ComUtil. The arduino, being the slave, does not need to worry about this.
- Sending messages and state changes are now only done after a message is received. The computer will send the first message on initialization. Once this happens they will take turns updating each other on their states. This will hopefully fix the problem with a constant stream of messages.
- On testing the changes, I have found that the port is opening properly but windows is still not sending anything. I did make a change to the way the send method works, so maybe I broke it. The remote state is now properly reporting 0, which is the default state if no message is received. For some reason, it was reporting 13 before, which made no sense as its not even a valid state.
- Manual testing of the Arduino with serial console shows that it is now only sending when it receives a message. The response seems to be corrupted though. Maybe I am just sending bad data.
- Found that I was casting the message char as a char*, instead of passing the reference to the char(&char). Continuing to test with the arduino, but this may solve the windows not sending problem.
- Tried an echo test once I saw the ardino’s state was not changing. For some reason it echos back the ascii code. When the value is set internally it successfully sets and returns ‘0’ but when I send ‘0’ it returns 48.
- Received data was not being cast to char. Considering this feeds into a character array which is later ingested by data dictionary, this is actually very important. This might be the source of all the problems I have had with prior attempts. The PC would receive good data from anything originating in the arduino, while the data which depended on the PC communication would come back corrupted. This gave the illusion it was working when I was looking at sensor data.
- Defined states needed to be characters so I had to put single quotes around them. I was doing the states differently before.
- Tested states and it seems to be good for the most part. There are some possible conflicts with messages and data which need to be resolved. Since I made it so the packets are 127 bytes instead of 128, I can put the message at the beginning of the packet.
- Changed and traced the logic of the states. This was tricky but I think I got something that will work now.
- Set up testing for large data passing. I will start this tomorrow.
End: 5:30
