A surgical circular stapler has a handle assembly a shaft a stapling assembly and a firing assembly. The shaft extends distally from the handle assembly. The stapling assembly is secured to a distal end of the shaft. Longitudinal translation of the firing assembly causes the stapling assembly to drive a plurality of staples in a circular array to secure two lumens of tissue together. The stapling assembly may further drive a blade to sever any excess tissue interior of the circular array of staples. The stapler further includes a lockout assembly configured to control firing of the stapling assembly. The lockout assembly may include one or more switches the actuation of which is configured to prevent or permit firing of the stapling assembly. The lockout assembly may additionally or alternatively include one or more mechanical lockout features configured to control firing of the stapling assembly.