Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

Commit

Permalink
Device change for GNSS only: remove device from global list when no p…
Browse files Browse the repository at this point in the history
…oweroff (#147)

The following code should be valid to recover from a situation in which the GNSS device is disconnected/connected or powered up.

  while((uret = uDeviceOpen(&gDeviceCfg,
          &device_handle)) != U_ERROR_COMMON_SUCCESS) {
  	uPortTaskBlock(5000);
  }

The current implementation fails with U_ERROR_COMMON_INVALID_PARAMETER with no recovery option, this loop is infinite connecting GNSS will have no affect.  The reason is that the static function removeDevice() is called with powerOff=false and this results in not removing the device from the global device list.

When the device is opened again it is already found within the list by pGetGnssInstanceTransportHandle(), which is called by uGnssAdd(); uGnssAdd() then returns U_ERROR_COMMON_INVALID_PARAMETER.

The software should release any resources attached to a device regardless of poweron/poweroff, the resources are logical and may be created when required.  This commit removes the device from the list in the case that poweroff was not requested.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
  • Loading branch information
alonbl authored Oct 15, 2023
1 parent 7df8ac9 commit b3aa942
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions common/device/src/u_device_private_gnss.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ static int32_t removeDevice(uDeviceHandle_t devHandle, bool powerOff)
uPortFree(pContext);
}
} else {
uGnssRemove(devHandle);
uPortFree(pContext);
}
}
Expand Down

0 comments on commit b3aa942

Please sign in to comment.