Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results
The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.
Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/
Hello all,
For DPS310 pressure sensor, to convert pressure unit from pascal to hectopascal, the pressure value has to be divided by 10^2. For example, from driver side, if we send 932.34 hPa (after conversion), the application retrieves it as 93234 hPa (without decimal). If we send the pressure in Pa value divided by 10^5, only then the application retrieves it as 932.34 hPa (as expected). Can someone reach out to this?
Thanks,
Subashini.
Upcoming OSR Seminars | ||
---|---|---|
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead! | ||
Writing WDF Drivers | 12 September 2022 | Live, Online |
Internals & Software Drivers | 23 October 2022 | Live, Online |
Kernel Debugging | 14 November 2022 | Live, Online |
Developing Minifilters | 5 December 2022 | Live, Online |
Comments
entirely internal to your implementation. How do you expect to get help
here?
Mark Roddy
What data type are you using to communicate these values between your driver and application?
@Mark_Roddy, @MBond2 :
I used the application reference: https://github.com/microsoft/Windows-universal-samples/tree/main/Samples/Barometer/cpp
From driver: Here the resultant pressure value is stored in m_CachedData. Its datatype is float.
From application: BarometerReading is a class. Pressure value from driver is retrieved using its method GetCurrentReading().
void Scenario2_Polling::ScenarioGetData(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
if (nullptr != sensor)
{
BarometerReading^ reading = sensor->GetCurrentReading();
if (nullptr != reading)
{
ScenarioOutput_hPa->Text = reading->StationPressureInHectopascals.ToString();
}
}
else
{
rootPage->NotifyUser("No barometer found", NotifyType::ErrorMessage);
}
}
OK, but where is the spec that tells you what units you need to store in m_CachedData? Does the hardware deliver Pa?
Tim Roberts, [email protected]
Providenza & Boekelheide, Inc.
DPS310 datasheet is referred.
you clearly have some kind of data type or unit conversion problem. careful review of all declarations and interface contracts is how to find a problem like this. Code snips without the declarations and links to large documents don't help much. But on thing to consider is an expression like this
m_Pressure = ((UINT32)DataBuffer[0] << 16) | ((UINT32)DataBuffer[1] << 8) | (UINT32)DataBuffer[2];
I spend most of my time reviewing code written by others and this is the sort of thing that I routinely insist is rewritten. Not because it produces the wrong result necessarily, but because it requires a detailed analysis of the operator associativity and precedence of each part to determine exactly what it means. And an equivalent sequence that is unambiguous will produce the same machine code.
please feel free to ignore my ranting on this point