Why can't you use a flag to indicate when to abort? Before CanSend() starts running, you can look at a flag (global variable) to see the resource's availability and set the flag to show the priority of the current frame to transmit. If your priority is higher than what's already being copied, then change the flag to show your priority and start copying data to registers. During the frame-copy loop of CanSend() you can keep checking that flag to see if it has changed to a higher priority, ie another thread took over, and if so, break from the loop and then have CanSend() return a 1 to indicate unsuccessfull transmisison. Then when the function completes a transmisison, have it clear the flag and return a 0 for successful transmission. Then when you call CanSend(), make it repeat the call if it wasn't successfull: while(CanSend(dataStart, priority)); That way it will start from the beginning.
One thing to add. If you're allowing other threads to interrupt the data copy portion, then you're already stalling on high priority frames. You might actually get better performance if you make the frame arbitration occur before you start copying data into the CAN registers and then disable interrupts once you've started.
Message Edited by rhinoceroshead on 04-30-200612:04 PM