Vague requirements :
Data types :
autonomous logging data out
instructional packets in
acks and responses out
error packets out
none (running the engine only)
Priority :
Running the engine (no serial code) > Receiving Instructional Packets > Sending Error Packets > Sending Ack and Response Packets > Sending Autonomous Logging Data Packets
For Autonomous logging data :
Code: Select all
Each time period check to see if we should be sending data and if the buffer to receive it is empty
if so, prepare logging packet per mask and transfer to the sending mechanism.
Code: Select all
Check to ensure it is valid
if so, and if it needs a response (with or without ack), prepare response packet and data
if so, and if it doesn't need a response, perform action, if ack required, send ack (pass or fail)
if not, send error packet
In order to get "matching sets" of data for logging, we need to buffer the variables in sets. This can be done in an ISR blocked session on demand, or perhaps all the time such that there is always a packet ready to go (or the contents there of) and they can just be sent when ready.
The receive code should look for a start byte, and receive the header, and the contents, and when the finish byte comes in check it for validity, or when some size limit for a packet is reached, reject it as oversized or something. (data size on the ecu will have a finite limit for sure). Once it has a packet, it should disable receipt of more until it has processed that one and either responded, acked, actioned, etc. Once done, it should re-enable receipt of packets.
To send (either responses or logging) a general handler is required. The handler should take a pointer to an array (and length) of bytes to be sent, add a header to it, send it and add a checksum to the end.
This is probably (certainly) full of holes, but we can work on it and when it's ready to go, I can code it up.
Fred.