An automatic span line switch for PCM communication lines is disclosed which isolates alarm conditions to an actual span line failure, as distinguished from failures in the terminal equipment. In addition, the switch uses a specific code transmission to provide fast switching and to permit identification of the direction of failure. Although the circuit is capable of switching span segments individually and independently, it can transmit an alarm to a distant central office and automatically establish an appropriate test loop in the presence of test transmissions when needed to permit single-end troubleshooting. The switch further tests the dead line continuously and stringently for error-free data transmission, and automatically resets without disturbing traffic when the trouble has been corrected. An extremely flexible priority system for selected channels is also provided, and the circuitry on both ends of all channels (including the protective channel) is identical to minimize parts inventory costs.