-
Notifications
You must be signed in to change notification settings - Fork 586
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The call to Dns.GetHostEntry() may fail on MacOS (#1927)
* The call to Dns.GetHostEntry() may fail on MacOS ... only ever seen there. * Build on one CPU only Maybe this avoids the concurrency problems? * Revert "Build on one CPU only" This reverts commit 7ee8124. * Make sure there's only one .csproj per directory Therefore split up sample folders containing multiple projects into subfolders. This fixes the macOS build and also some weird issues on other operating systems (such as the debugger getting confused about which one to execute) * Also update the solution files
- Loading branch information
Showing
41 changed files
with
149 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
188 changes: 94 additions & 94 deletions
188
src/devices/Bmxx80/samples/Bme680.sample.cs → ...es/Bmxx80/samples/Bme680/Bme680.sample.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,94 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Device.I2c; | ||
using System.Threading; | ||
using Iot.Device.Bmxx80; | ||
using Iot.Device.Common; | ||
using UnitsNet; | ||
|
||
Console.WriteLine("Hello BME680!"); | ||
|
||
// The I2C bus ID on the Raspberry Pi 3. | ||
const int busId = 1; | ||
// set this to the current sea level pressure in the area for correct altitude readings | ||
Pressure defaultSeaLevelPressure = WeatherHelper.MeanSeaLevel; | ||
|
||
I2cConnectionSettings i2cSettings = new(busId, Bme680.DefaultI2cAddress); | ||
I2cDevice i2cDevice = I2cDevice.Create(i2cSettings); | ||
|
||
using Bme680 bme680 = new Bme680(i2cDevice, Temperature.FromDegreesCelsius(20.0)); | ||
|
||
while (true) | ||
{ | ||
// reset will change settings back to default | ||
bme680.Reset(); | ||
|
||
// 10 consecutive measurement with default settings | ||
for (var i = 0; i < 10; i++) | ||
{ | ||
// Perform a synchronous measurement | ||
var readResult = bme680.Read(); | ||
|
||
// Print out the measured data | ||
Console.WriteLine($"Gas resistance: {readResult.GasResistance?.Ohms:0.##}Ohm"); | ||
Console.WriteLine($"Temperature: {readResult.Temperature?.DegreesCelsius:0.#}\u00B0C"); | ||
Console.WriteLine($"Pressure: {readResult.Pressure?.Hectopascals:0.##}hPa"); | ||
Console.WriteLine($"Relative humidity: {readResult.Humidity?.Percent:0.#}%"); | ||
|
||
if (readResult.Temperature.HasValue && readResult.Pressure.HasValue) | ||
{ | ||
var altValue = WeatherHelper.CalculateAltitude(readResult.Pressure.Value, defaultSeaLevelPressure, readResult.Temperature.Value); | ||
Console.WriteLine($"Altitude: {altValue.Meters:0.##}m"); | ||
} | ||
|
||
if (readResult.Temperature.HasValue && readResult.Humidity.HasValue) | ||
{ | ||
// WeatherHelper supports more calculations, such as saturated vapor pressure, actual vapor pressure and absolute humidity. | ||
Console.WriteLine($"Heat index: {WeatherHelper.CalculateHeatIndex(readResult.Temperature.Value, readResult.Humidity.Value).DegreesCelsius:0.#}\u00B0C"); | ||
Console.WriteLine($"Dew point: {WeatherHelper.CalculateDewPoint(readResult.Temperature.Value, readResult.Humidity.Value).DegreesCelsius:0.#}\u00B0C"); | ||
} | ||
|
||
// when measuring the gas resistance on each cycle it is important to wait a certain interval | ||
// because a heating plate is activated which will heat up the sensor without sleep, this can | ||
// falsify all readings coming from the sensor | ||
Thread.Sleep(1000); | ||
} | ||
|
||
// change the settings | ||
bme680.TemperatureSampling = Sampling.HighResolution; | ||
bme680.HumiditySampling = Sampling.UltraHighResolution; | ||
bme680.PressureSampling = Sampling.Skipped; | ||
|
||
bme680.ConfigureHeatingProfile(Bme680HeaterProfile.Profile2, Temperature.FromDegreesCelsius(280), Duration.FromMilliseconds(80), Temperature.FromDegreesCelsius(24)); | ||
bme680.HeaterProfile = Bme680HeaterProfile.Profile2; | ||
|
||
// 10 consecutive measurements with custom settings | ||
for (int i = 0; i < 10; i++) | ||
{ | ||
// Perform an asynchronous measurement | ||
var readResult = await bme680.ReadAsync(); | ||
|
||
// Print out the measured data | ||
Console.WriteLine($"Gas resistance: {readResult.GasResistance?.Ohms:0.##}Ohm"); | ||
Console.WriteLine($"Temperature: {readResult.Temperature?.DegreesCelsius:0.#}\u00B0C"); | ||
Console.WriteLine($"Pressure: {readResult.Pressure?.Hectopascals:0.##}hPa"); | ||
Console.WriteLine($"Relative humidity: {readResult.Humidity?.Percent:0.#}%"); | ||
|
||
if (readResult.Temperature.HasValue && readResult.Pressure.HasValue) | ||
{ | ||
var altValue = WeatherHelper.CalculateAltitude(readResult.Pressure.Value, defaultSeaLevelPressure, readResult.Temperature.Value); | ||
Console.WriteLine($"Altitude: {altValue.Meters:0.##}m"); | ||
} | ||
|
||
if (readResult.Temperature.HasValue && readResult.Humidity.HasValue) | ||
{ | ||
// WeatherHelper supports more calculations, such as saturated vapor pressure, actual vapor pressure and absolute humidity. | ||
Console.WriteLine($"Heat index: {WeatherHelper.CalculateHeatIndex(readResult.Temperature.Value, readResult.Humidity.Value).DegreesCelsius:0.#}\u00B0C"); | ||
Console.WriteLine($"Dew point: {WeatherHelper.CalculateDewPoint(readResult.Temperature.Value, readResult.Humidity.Value).DegreesCelsius:0.#}\u00B0C"); | ||
} | ||
|
||
Thread.Sleep(1000); | ||
} | ||
} | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Device.I2c; | ||
using System.Threading; | ||
using Iot.Device.Bmxx80; | ||
using Iot.Device.Common; | ||
using UnitsNet; | ||
|
||
Console.WriteLine("Hello BME680!"); | ||
|
||
// The I2C bus ID on the Raspberry Pi 3. | ||
const int busId = 1; | ||
// set this to the current sea level pressure in the area for correct altitude readings | ||
Pressure defaultSeaLevelPressure = WeatherHelper.MeanSeaLevel; | ||
|
||
I2cConnectionSettings i2cSettings = new(busId, Bme680.DefaultI2cAddress); | ||
I2cDevice i2cDevice = I2cDevice.Create(i2cSettings); | ||
|
||
using Bme680 bme680 = new Bme680(i2cDevice, Temperature.FromDegreesCelsius(20.0)); | ||
|
||
while (true) | ||
{ | ||
// reset will change settings back to default | ||
bme680.Reset(); | ||
|
||
// 10 consecutive measurement with default settings | ||
for (var i = 0; i < 10; i++) | ||
{ | ||
// Perform a synchronous measurement | ||
var readResult = bme680.Read(); | ||
|
||
// Print out the measured data | ||
Console.WriteLine($"Gas resistance: {readResult.GasResistance?.Ohms:0.##}Ohm"); | ||
Console.WriteLine($"Temperature: {readResult.Temperature?.DegreesCelsius:0.#}\u00B0C"); | ||
Console.WriteLine($"Pressure: {readResult.Pressure?.Hectopascals:0.##}hPa"); | ||
Console.WriteLine($"Relative humidity: {readResult.Humidity?.Percent:0.#}%"); | ||
|
||
if (readResult.Temperature.HasValue && readResult.Pressure.HasValue) | ||
{ | ||
var altValue = WeatherHelper.CalculateAltitude(readResult.Pressure.Value, defaultSeaLevelPressure, readResult.Temperature.Value); | ||
Console.WriteLine($"Altitude: {altValue.Meters:0.##}m"); | ||
} | ||
|
||
if (readResult.Temperature.HasValue && readResult.Humidity.HasValue) | ||
{ | ||
// WeatherHelper supports more calculations, such as saturated vapor pressure, actual vapor pressure and absolute humidity. | ||
Console.WriteLine($"Heat index: {WeatherHelper.CalculateHeatIndex(readResult.Temperature.Value, readResult.Humidity.Value).DegreesCelsius:0.#}\u00B0C"); | ||
Console.WriteLine($"Dew point: {WeatherHelper.CalculateDewPoint(readResult.Temperature.Value, readResult.Humidity.Value).DegreesCelsius:0.#}\u00B0C"); | ||
} | ||
|
||
// when measuring the gas resistance on each cycle it is important to wait a certain interval | ||
// because a heating plate is activated which will heat up the sensor without sleep, this can | ||
// falsify all readings coming from the sensor | ||
Thread.Sleep(1000); | ||
} | ||
|
||
// change the settings | ||
bme680.TemperatureSampling = Sampling.HighResolution; | ||
bme680.HumiditySampling = Sampling.UltraHighResolution; | ||
bme680.PressureSampling = Sampling.Skipped; | ||
|
||
bme680.ConfigureHeatingProfile(Bme680HeaterProfile.Profile2, Temperature.FromDegreesCelsius(280), Duration.FromMilliseconds(80), Temperature.FromDegreesCelsius(24)); | ||
bme680.HeaterProfile = Bme680HeaterProfile.Profile2; | ||
|
||
// 10 consecutive measurements with custom settings | ||
for (int i = 0; i < 10; i++) | ||
{ | ||
// Perform an asynchronous measurement | ||
var readResult = await bme680.ReadAsync(); | ||
|
||
// Print out the measured data | ||
Console.WriteLine($"Gas resistance: {readResult.GasResistance?.Ohms:0.##}Ohm"); | ||
Console.WriteLine($"Temperature: {readResult.Temperature?.DegreesCelsius:0.#}\u00B0C"); | ||
Console.WriteLine($"Pressure: {readResult.Pressure?.Hectopascals:0.##}hPa"); | ||
Console.WriteLine($"Relative humidity: {readResult.Humidity?.Percent:0.#}%"); | ||
|
||
if (readResult.Temperature.HasValue && readResult.Pressure.HasValue) | ||
{ | ||
var altValue = WeatherHelper.CalculateAltitude(readResult.Pressure.Value, defaultSeaLevelPressure, readResult.Temperature.Value); | ||
Console.WriteLine($"Altitude: {altValue.Meters:0.##}m"); | ||
} | ||
|
||
if (readResult.Temperature.HasValue && readResult.Humidity.HasValue) | ||
{ | ||
// WeatherHelper supports more calculations, such as saturated vapor pressure, actual vapor pressure and absolute humidity. | ||
Console.WriteLine($"Heat index: {WeatherHelper.CalculateHeatIndex(readResult.Temperature.Value, readResult.Humidity.Value).DegreesCelsius:0.#}\u00B0C"); | ||
Console.WriteLine($"Dew point: {WeatherHelper.CalculateDewPoint(readResult.Temperature.Value, readResult.Humidity.Value).DegreesCelsius:0.#}\u00B0C"); | ||
} | ||
|
||
Thread.Sleep(1000); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.