#NOTE: Communication the right way
Start: 10:00
- Okay, so I guess my concerns about the programs running at different speeds were not unfounded.
- To solve this problem it takes multiple cycles to send and receive data. Before I was worried about loss of data, but the cycles should be fast enough, that the polling rate won’t suffer.
- The first initializing pass, gets both devices to a Ready state. After this parts done, the program goes through its first loop and the buffer is loaded with the first set of data.
- On the second loop, it first checks to see if there is any data in the buffer, if there is it locks the buffer til data is sent. After this happens it will check to see if it received any messages. If it has not, it will send a ReadyToSend(RTS) message across the wire and wait for a ClearToSend(CTS) response. If it has it will change to a CTS state and send a response.
- On the “third” loop, the RTR side will send a message of send 1 of x packets and will wait for a response before sending the next packet. This will take x amount of loops to send all the data.
- Once all the packets are received the sending side goes into done state and the receiving side goes into a processing state. When the data is done being ingested the reciever will respond done and the sender will go into a CTS state and the original receiver will have a chance to send its data.
- If the original receiver has no data to send it will send a no data message which will trigger the original sender to either go into a RTS or READY state depending on if it has data or not.
- I think I finally get how to do this properly. Just need to edit my states to mirror the process outlined above.
- I have realized that the only thing that each side really cares about is the State of the other side. I took out all the command and response variables for each side and replaced them with a simple local state and remote state. When sending and receiving occurs, a special message with state and packets of total is sent.
- Got rid of master flag as it is no longer needed.
- Made sure the the class always tries to receive before sending. This eliminated a need for a separate response method and makes it so both types messages are the same format.
- Got rid of some other methods which were the product of over thinking the problem
- For now only 1 packet will be sent at a time to simplify troubleshooting.
End: 6:00
