'ADXRS450 Gyro not reading

I have a roborio 1, with an ADXRS450 gyro plugged in to the SPI port. I have tried to access it with the following code:

...

private ADXRS450_Gyro compass = new ADXRS450_Gyro(SPI.Port.kOnboardCS0);

...

compass.calibrate();

...

if(compass.getAngle() < 180)
  m_robotDrive.arcadeDrive(0, 0.5);
else
  m_robotDrive.arcadeDrive(0, 0);

...

EOF

However, the gyro always reads 0. Is this a software or hardware error, and how can I fix it?



Solution 1:[1]

Hopefully you've figured this out by now, but it was a bug in the 2022 RoboRIO image:

https://docs.wpilib.org/en/stable/docs/yearly-overview/known-issues.html#analog-devices-gyros-don-t-work-properly

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Wowkster