Check if SIP phone is busy over IAX trunk

I have a setup which has two Asterisk machines using IAX between them with a SIP box connected to each LAN. I would like to check whether the phone line is busy before trying to Dial a phone over the IAX trunk but I don’t seem to be able to find a function or set of functions which will make this check for me.

Would be grateful for any ideas.