Reading can message twice before setting a state

Hi,

I'm checking the state of can messages in my car. If certain states are set I'm sending a message which activates a function in my car. Now before I want to send the message I want to check the can message double so i know the state hasn't changed in the meantime.

Also reading the initial state of the light switch is not always working, this is because if the id in the buffer is different than the id that I want to do something with it just skips the if statement. Is there a way to wait till that ID has passed?

At last I'm now sending a byte in my flaOn message and to do it nicely i would like to read the current byte and only change the bit and send that changed byte.

I hope my questions are clear :-).

Thanks in advance for the help!

My code current: