  void Panda::set_power_saving(bool power_saving) {
    usb_write(0xe7, power_saving, 0);
  }
  
  void Panda::set_usb_power_mode(cereal::PandaState::UsbPowerMode power_mode) {
    usb_write(0xe6, (uint16_t)power_mode, 0);
  }
  
  void Panda::send_heartbeat() {
    usb_write(0xf3, 1, 0);
 
</s> remove void hardware_control_thread(Panda *panda) {
  LOGD("start hardware control thread");
 </s> add void peripheral_control_thread(Panda *panda) {
  LOGD("start peripheral control thread"); </s> remove void panda_state_thread(PubMaster *pm, Panda *panda, bool spoofing_started) {
  LOGD("start panda state thread");
  uint32_t no_ignition_cnt = 0;
  bool ignition_last = false;
  Params params = Params();
 </s> add bool send_panda_state(PubMaster *pm, Panda *panda, bool spoofing_started) {
  health_t pandaState = panda->get_state(); </s> remove #endif
 </s> add   } else {
    ps.setVoltage(pandaState.voltage);
    ps.setCurrent(pandaState.current);
  }

  uint16_t fan_speed_rpm = panda->get_fan_speed();
  ps.setUsbPowerMode(cereal::PeripheralState::UsbPowerMode(pandaState.usb_power_mode));
  ps.setFanSpeedRpm(fan_speed_rpm);

  pm->send("peripheralState", msg);
}

void panda_state_thread(PubMaster *pm, Panda * peripheral_panda, Panda *panda, bool spoofing_started) {
  Params params;
  bool ignition_last = false;

  LOGD("start panda state thread");

  // run at 2hz
  while (!do_exit && panda->connected) {
    send_peripheral_state(pm, peripheral_panda);
    ignition = send_panda_state(pm, panda, spoofing_started);
void Panda::set_usb_power_mode(cereal::PeripheralState::UsbPowerMode power_mode) {
  void Panda::set_power_saving(bool power_saving) {
    usb_write(0xe7, power_saving, 0);
  }
  
void Panda::set_usb_power_mode(cereal::PeripheralState::UsbPowerMode power_mode) {
    usb_write(0xe6, (uint16_t)power_mode, 0);
  }
  
  void Panda::send_heartbeat() {
    usb_write(0xf3, 1, 0);
keep keep keep keep replace keep keep keep keep keep
 Split pandaState into peripheralState and pandaState (#22385)

* publish peripheralState from boardd

* refactor consumers

* rename thread

* peripheralState has panda type too

* add to process replay

* fix device build

* properly remove hardware unsupported alert

* latest peripheralState

* remove pandaState from thermal_monitor

* put that back

* add back harness check

* fix cloudlog

* needs pandaState

* Update selfdrive/thermald/tests/test_power_monitoring.py

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

* dont conflate

* Update selfdrive/thermald/tests/test_power_monitoring.py

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

* pigeon is peripheral

* cleanup

* less global

* comment

* move rtc to peripheral_control_thread

* better diff?

* whitespace

* get msg

* bump cereal

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> 
selfdrive/boardd/panda.cc