A man who attacked a sheriff's deputy with a baseball bat when he tried to stop him smashing a red light camera, has been charged with attempted murder.

Frederick Gramcko, 53, was found repeatedly hitting the camera with the bat at the intersection of El Camino Real and Encinitas Boulevard, in San Diego, at around 2.30pm.

An officer, responding to reports of vandalism, approached Gramcko and ordered him to drop his bat, according to police reports.

When he refused, he tried to deploy his stun gun on Gramcko but the device malfunctioned, according to NBC 7.

Frederick Gramcko, 53, was attacking a red light camera with a bat in San Diego. When a sheriff's deputy tried to intervene he was also attacked

Detective Adrian Moses said that the suspect took several swings at the deputy in an attempt to hit him.

When the deputy took out his baton to try to subdue him, Gramcko ran from the scene, with the deputy chasing after him.

'When the deputy caught up to the suspect, he turned around and attacked the deputy and a physical altercation between them ensued,' Moses said. 'Other deputies arrived on scene and the suspect was ultimately detained and handcuffed.'

The suspect was restrained with a Wrap device, which is a thick nylon blanket that prevents a suspect from kicking and moving around.

The red light camera suffered several dents after Gramcko smashed it with a baseball bat

He was taken to the hospital for treatment before being booked into the Vista Detention Facility.

The officer suffered several broken bones and was released from Scripps Memorial Hospital Encinitas on Sunday.

Gramcko was charged with attempted murder of a peace officer.