How to check the CAN bus is free or not
The short answer is that the node must monitor the CAN lines to be idle for a certain time before it attempts to transmit. So if another node is transmitting, it must keep quiet till the other node is done.
A CAN bus is based in differential signalling. The two lines, CAN-High (CAN+) and CAN-Low (CAN-), are both at the same potential when the bus is idle. To send bits, a CAN transmitter puts a differential voltage on the lines of about 2 volts.
A CAN transmitter first sees if the bus is idle and if it is, starts to transmit. How the arbitration works is that a transmitter monitors the bus as it's transmitting. Transmission is done as above by either keeping the two lines at the same potential or at a differential potential. So if the transmitter transmits a bit by keeping the lines at the same potential (sic), but it sees that the two transmit lines have a differential potential, that means that some other node is transmitting and the first transmitter has lost the arbitration. It must then stop transmitting.
When a node first starts transmitting, the bits transmitted are the same until the address of the transmitting node which are obviously different. If two nodes start transmitting together, they will transmit together in sync till the address part is reached. When the address differs, a node will notice a potential difference on the lines even when it is not putting one on the lines. Then it knows it has lost and has to try again. The winning node continues transmitting without knowing that some other node was trying as well. Of course, this logic extends to more than two nodes also.
I hope this helps.
I know of two ways to resolve it:
First, the CAN controller would always monitor the bus; when it detects a message on the bus it begins the receiving process. Now that it's in the receiving state, it knows the bus is in use when a transmit is requested.
Second, by bit stuffing, the CAN transceiver will not have the same bit for more than five cycles (unless a bus error is detected, in which case you'll see up to 12 dominant bits in a row). The exception to this is when nothing is being transmitted on the bus, when a passive bit is always read. A controller just starting could listen to the bus for five cycles before declaring 'probably free'.
I do not guarantee that these are the actual processes, but based on my (limited) knowledge of CAN, these would work.
As CoderTao says - the CAN controller is continually monitoring the bus, so it knows when a transmission is already in progress. So the only time when a collision can happen is when both nodes start to transmit "simultaneously" - within a bit-time of eachother (+a small amount of additional time for bus propagation). Hence those are the only cases you've found in documents :)