drivers/foc/foc_dummy.c: update dummy device state only if dev opened

This is fix for seg fault for sim/foc configuration
This commit is contained in:
raiden00pl 2023-10-02 12:53:04 +02:00 committed by Xiang Xiao
parent ddb87d3b86
commit c52188f0bf

View File

@ -687,13 +687,18 @@ void foc_dummy_update(void)
dev = &g_foc_dev[i];
/* Get SIM data */
/* Update dummy driver state only if device opened */
sim = FOC_DUMMY_DATA_FROM_DEV_GET(dev);
if (sim->state == true)
if (dev->ocount > 0)
{
foc_dummy_notifier_handler(dev);
/* Get SIM data */
sim = FOC_DUMMY_DATA_FROM_DEV_GET(dev);
if (sim->state == true)
{
foc_dummy_notifier_handler(dev);
}
}
}