/
MeadowOS.cs
802 lines (690 loc) · 26.5 KB
/
MeadowOS.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
using Meadow.Cloud;
using Meadow.Hardware;
using Meadow.Logging;
using Meadow.Peripherals.Sensors;
using Meadow.Update;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using RTI = System.Runtime.InteropServices.RuntimeInformation;
namespace Meadow;
/// <summary>
/// The entry point of the .NET part of Meadow OS.
/// </summary>
public static partial class MeadowOS
{
//==== internals
private static bool _startedDirectly = false; // true when this assembly is the entry point
//==== properties
internal static IMeadowDevice CurrentDevice { get; private set; } = null!;
private static IApp App { get; set; } = default!;
private static ILifecycleSettings LifecycleSettings { get; set; } = default!;
private static IMeadowCloudSettings MeadowCloudSettings { get; set; } = default!;
/// <summary>
/// The cancellation CancellationTokenSource used to signal the application to shut down
/// </summary>
/// <remarks>This is used by the UpdateService</remarks>
public static CancellationTokenSource AppAbort = new();
/// <summary>
/// The value of the processor clock register when `Main` was entered
/// </summary>
public static int StartupTick { get; set; }
/// <summary>
/// The entry point for Meadow applications
/// </summary>
/// <param name="args">Command line arguments</param>
/// <returns></returns>
public static async Task Main(string[] args)
{
StartupTick = Environment.TickCount;
_startedDirectly = true;
await Start(args);
}
/// <summary>
/// Initializes and starts up the Meadow Core software stack
/// </summary>
public static Task Start(string[]? args)
{
return Start(args, null);
}
/// <summary>
/// Initializes and starts up the Meadow Core software stack
/// </summary>
public static Task Start(IApp app, string[]? args = null)
{
return Start(args, app);
}
/// <summary>
/// Initializes and starts up the Meadow Core software stack
/// </summary>
private static async Task Start(string[]? args, IApp? app)
{
bool systemInitialized = false;
try
{
systemInitialized = Initialize(args, app);
if (!systemInitialized)
{
// device initialization failed - don't try bring up the app
Resolver.Log.Error("Device (system) Initialization Failure");
}
}
catch (Exception e)
{
ReportAppException(e, "Device (system) Initialization Failure");
}
var crashReporter = new CrashReporter();
Resolver.Services.Add(crashReporter);
// check for any crash reports
if (crashReporter.CrashDataAvailable)
{
try
{
App.OnBootFromCrash(crashReporter.GetCrashData());
}
catch (Exception ex)
{
// if the app crashes in the crash report handler, we don't want to restart or we'll infinite loop!
Resolver.Log.Error($"Crash Report Handler error: {ex.Message}");
}
}
Resolver.Services.Add<ISensorService>(new SensorService());
if (systemInitialized)
{
var stepName = "App Initialize";
try
{
Resolver.Log.Trace("Initializing App");
await App.Initialize();
stepName = "App Run";
Resolver.Log.Trace("Running App");
await App.Run();
AppAbort.Token.WaitHandle.WaitOne();
}
catch (Exception e)
{
ReportAppException(e, $"App Error in {stepName}: {e.Message}");
try
{
// let the app handle error conditions
await App.OnError(e);
}
catch (Exception ex)
{
Resolver.Log.Error($"Exception in OnError handling: {ex.Message}");
}
// set the cancel token so any waiting Tasks, etc can abort cleanly
AppAbort.Cancel();
}
try
{
// let the app handle shutdown
Resolver.Log.Trace($"App shutting down");
AppAbort.CancelAfter(millisecondsDelay: LifecycleSettings.AppFailureRestartDelaySeconds * 1000);
await App.OnShutdown();
}
catch (Exception e)
{
// we can't recover while shutting down
Resolver.Log.Error($"Exception in App.OnShutdown: {e.Message}");
}
finally
{
if (App is IAsyncDisposable { } da)
{
try
{
await da.DisposeAsync();
}
catch (Exception ex)
{
Resolver.Log.Error($"Exception in App.Dispose: {ex.Message}");
}
}
}
}
// final shutdown process
Shutdown();
// we should never get to this point
}
private static void ReportAppException(Exception e, string? message = null)
{
Resolver.Log.Error(message ?? " System Failure");
Resolver.Log.Error($" {e.GetType()}: {e.Message}");
Resolver.Log.Error(e.StackTrace);
if (e is AggregateException ae)
{
foreach (var ex in ae.InnerExceptions)
{
Resolver.Log.Error($" Inner {ex.GetType()}: {ex.InnerException.Message}");
Resolver.Log.Error(ex.StackTrace);
}
}
else if (e.InnerException != null)
{
Resolver.Log.Error($" Inner {e.InnerException.GetType()}: {e.InnerException.Message}");
Resolver.Log.Error(e.InnerException.StackTrace);
}
try
{
using var file = System.IO.File.CreateText(Path.Combine(MeadowOS.FileSystem.DataDirectory, "meadow.error"));
file.Write(e.ToString());
}
catch
{
// we're already in an error condition - nothing we can really do about this
}
}
private static Dictionary<string, string> LoadSettings()
{
IAppSettings settings;
var configPath = Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
"app.config.yaml");
if (File.Exists(configPath))
{
Console.WriteLine($"Parsing app.config.yaml...");
// testing shows this takes ~375ms (7/20/23) on F7
var yml = File.ReadAllText(configPath);
// testing shows this takes ~1100ms (7/20/23)
settings = AppSettingsParser.Parse(yml);
}
else
{
Console.WriteLine($"Using default app.config.yaml...");
settings = new MeadowAppSettings(); // defaults
}
Resolver.Log.ShowTicks = settings.LoggingSettings.ShowTicks;
Resolver.Log.LogLevel = settings.LoggingSettings.LogLevel.Default;
Resolver.Log.Info($"Log level: {settings.LoggingSettings.LogLevel.Default}");
LifecycleSettings = settings.LifecycleSettings;
MeadowCloudSettings = settings.MeadowCloudSettings;
// cascade cloud enable
if (MeadowCloudSettings.EnableUpdates)
{
MeadowCloudSettings.Enabled = true;
}
if (MeadowCloudSettings.EnableHealthMetrics)
{
MeadowCloudSettings.Enabled = true;
}
return settings.Settings;
}
private static Type[] FindAppType(string? root)
{
Resolver.Log.Trace($"Looking for app assembly...");
Assembly? appAssembly;
if (_startedDirectly)
{
// support app.exe or app.dll
appAssembly = FindByPath(new string[] { "App.dll", "App.exe", "app.dll", "app.exe" }, root);
if (appAssembly == null) throw new Exception("No 'App' assembly found. Expected either App.exe or App.dll");
}
else
{
appAssembly = Assembly.GetEntryAssembly();
}
// === LOCAL METHOD ===
static Assembly? FindByPath(string[] namesToCheck, string? root = null)
{
root ??= AppDomain.CurrentDomain.BaseDirectory;
foreach (var name in namesToCheck)
{
var path = Path.Combine(root, name);
if (File.Exists(path))
{
Resolver.Log.Trace($"Found '{path}'");
try
{
return Assembly.LoadFrom(path);
}
catch (Exception ex)
{
Resolver.Log.Warn($"Unable to load assembly '{name}': {ex.Message}");
}
}
}
return null;
}
Resolver.Log.Trace($"Looking for IApp...");
var searchType = typeof(IApp);
var resultList = new List<Type>();
foreach (var type in appAssembly.GetTypes())
{
if (searchType.IsAssignableFrom(type) && !type.IsAbstract)
{
resultList.Add(type);
}
}
return resultList.ToArray();
}
private static MeadowPlatform DetectPlatform()
{
if (RTI.IsOSPlatform(OSPlatform.Windows))
{
return MeadowPlatform.Windows;
}
else if (RTI.IsOSPlatform(OSPlatform.OSX))
{
return MeadowPlatform.OSX;
}
else if (RTI.IsOSPlatform(OSPlatform.Linux))
{
// could be an embedded linux, could be desktop
// how do we determine? ARM v Other?
return RTI.ProcessArchitecture switch
{
Architecture.Arm => MeadowPlatform.EmbeddedLinux,
Architecture.Arm64 => MeadowPlatform.EmbeddedLinux,
_ => MeadowPlatform.DesktopLinux
};
}
else if (Directory.Exists("/meadow0"))
{
// we're an F7 - but with the current OS we can't tell exctly what type of F7
}
return MeadowPlatform.Unknown;
}
private static Type FindDeviceTypeParameter(Type type)
{
if (type.IsGenericType)
{
var dt = type.GetGenericArguments().FirstOrDefault(a => typeof(IMeadowDevice).IsAssignableFrom(a));
if (dt != null) return dt;
}
return FindDeviceTypeParameter(type.BaseType);
}
private static (Type appType, Type deviceType)? FindAppForPlatform(MeadowPlatform platform)
{
var allApps = FindAppType(null);
if (allApps.Length == 0)
{
throw new Exception("Cannot find an IApp implementation");
}
// find an IApp that matches our target platform
switch (platform)
{
case MeadowPlatform.Windows:
// look for Desktop or Windows
// (wish C# supported static properties on an interface, they type could then tell what platforms it supports)
(Type, Type)? windowsTypeTuple = null;
foreach (var app in allApps)
{
var devicetype = FindDeviceTypeParameter(app);
if (devicetype.FullName == "Meadow.Desktop")
{
return (app, devicetype);
}
else if (devicetype.FullName == "Meadow.Windows")
{
// keep a ref in case Desktop isn't found
windowsTypeTuple = (app, devicetype);
}
}
if (windowsTypeTuple != null)
{
return windowsTypeTuple;
}
throw new Exception("Cannot find an IApp that targets Desktop or Windows");
case MeadowPlatform.OSX:
(Type, Type)? macTypeTuple = null;
foreach (var app in allApps)
{
var devicetype = FindDeviceTypeParameter(app);
if (devicetype.FullName == "Meadow.Desktop")
{
return (app, devicetype);
}
else if (devicetype.FullName == "Meadow.Mac")
{
// keep a ref in case Desktop isn't found
macTypeTuple = (app, devicetype);
}
}
if (macTypeTuple != null)
{
return macTypeTuple;
}
throw new Exception("Cannot find an IApp that targets Desktop or Mac");
case MeadowPlatform.DesktopLinux:
(Type, Type)? linuxTypeTuple = null;
foreach (var app in allApps)
{
var devicetype = FindDeviceTypeParameter(app);
if (devicetype.FullName == "Meadow.Desktop")
{
return (app, devicetype);
}
else if (devicetype.FullName == "Meadow.Linux")
{
// keep a ref in case Desktop isn't found
linuxTypeTuple = (app, devicetype);
}
}
if (linuxTypeTuple != null)
{
return linuxTypeTuple;
}
throw new Exception("Cannot find an IApp that targets Desktop or Linux");
case MeadowPlatform.EmbeddedLinux:
// TODO: improve this by finding a way to specifically differentiate Linux ARM
foreach (var app in allApps)
{
var devicetype = FindDeviceTypeParameter(app);
switch (devicetype.FullName)
{
case "Meadow.RaspberryPi":
case "Meadow.JetsonNano":
case "Meadow.JetsonXavierAgx":
case "Meadow.SnickerdoodleBlack":
return (app, devicetype);
}
}
throw new Exception("Cannot find an IApp that targets a supported ARM Linux");
case MeadowPlatform.Unknown:
Interop.HardwareVersion hw = Interop.HardwareVersion.Unknown;
try
{
hw = Interop.Nuttx.meadow_os_hardware_version();
}
catch (Exception)
{
// OS is probably too old to provide this, so just go with the first F7* implementation
}
// look for the first F7 app type (no way to determine it before creating the device implementation yet)
foreach (var app in allApps)
{
var devicetype = FindDeviceTypeParameter(app);
switch (hw)
{
case Interop.HardwareVersion.Unknown:
if (allApps.Length > 1)
{
Resolver.Log.Warn("Multi-targeting of F7 devices is only supported on OS 1.9 and later");
}
return (app, devicetype);
case Interop.HardwareVersion.F7FeatherV1:
if (devicetype.FullName == "Meadow.Devices.F7FeatherV1")
{
return (app, devicetype);
}
break;
case Interop.HardwareVersion.F7FeatherV2:
if (devicetype.FullName == "Meadow.Devices.F7FeatherV2")
{
return (app, devicetype);
}
break;
case Interop.HardwareVersion.F7CoreComputeV2:
if (devicetype.FullName == "Meadow.Devices.F7CoreComputeV2")
{
return (app, devicetype);
}
break;
}
}
throw new Exception($"Cannot find an IApp that targets a {(hw == Interop.HardwareVersion.Unknown ? "Meadow F7" : hw)} device");
default:
throw new Exception($"Cannot find an IApp that targets platform '{platform}'");
}
}
private static bool Initialize(string[]? args, IApp? app)
{
try
{
var now = Environment.TickCount;
now = Environment.TickCount;
Resolver.Services.Add(new Logger());
Resolver.Log.AddProvider(new ConsoleLogProvider());
Console.WriteLine($"Initializing OS... ");
}
catch (Exception ex)
{
// must use Console because the logger failed
Console.WriteLine($"Failed to create Logger: {ex.Message}");
return false;
}
//capture unhandled exceptions
AppDomain.CurrentDomain.UnhandledException += StaticOnUnhandledException;
// TODO: allow user injection of this
Resolver.Services.Add<IJsonSerializer>(new MicroJsonSerializer());
var settings = LoadSettings();
var platform = DetectPlatform();
var appTypes = FindAppForPlatform(platform);
Type appType = appTypes!.Value.appType;
var deviceType = appTypes!.Value.deviceType;
try
{
// Initialize strongly-typed hardware access - setup the interface module specified in the App signature
var b4 = Environment.TickCount;
var et = Environment.TickCount - b4;
// is there an override arg for "root"?
string? root = null;
if (args != null)
{
for (var i = 0; i < args.Length; i++)
{
if (args[i] == "--root" && args.Length > i)
{
root = args[i + 1];
_startedDirectly = true;
break;
}
}
}
try
{
if (Activator.CreateInstance(deviceType) is not IMeadowDevice device)
{
throw new Exception($"Failed to create instance of '{deviceType.Name}'");
}
et = Environment.TickCount - b4;
Resolver.Log.Trace($"Creating '{deviceType.Name}' instance took {et}ms");
CurrentDevice = device;
Resolver.Services.Add<IMeadowDevice>(CurrentDevice);
}
catch (Exception ex)
{
Resolver.Log.Trace($"Creating instance failure : {ex.Message}");
return false;
}
Resolver.Log.Trace($"Device Initialize starting...");
CurrentDevice.Initialize(platform);
Resolver.Log.Trace($"PlatformOS Initialize starting...");
CurrentDevice.PlatformOS.Initialize(CurrentDevice.Capabilities, args); // initialize the devices' platform OS
// initialize file system folders and such
// TODO: move this to platformOS
Resolver.Log.Trace($"File system Initialize starting...");
InitializeFileSystem();
if (app == null)
{
// Create the app object, bound immediately to the <IMeadowDevice>
b4 = Environment.TickCount;
Resolver.Log.Trace($"Creating instance of {appType.Name}...");
if (Activator.CreateInstance(appType, nonPublic: true) is not IApp capp)
{
throw new Exception($"Failed to create instance of '{appType.Name}'");
}
app = capp;
et = Environment.TickCount - b4;
Resolver.Log.Trace($"Creating '{appType.Name}' instance took {et}ms");
}
// feels off, but not seeing a super clean way without the generics, etc.
if (appType.GetProperty(nameof(IApp.CancellationToken)) is PropertyInfo pi)
{
if (pi.CanWrite)
{
pi.SetValue(app, AppAbort.Token);
}
}
if (appType.GetProperty(nameof(IApp.Settings)) is PropertyInfo spi)
{
if (spi.CanWrite)
{
spi.SetValue(app, settings);
}
}
App = app;
var cloudConnectionService = new MeadowCloudConnectionService(MeadowCloudSettings);
Resolver.Services.Add<IMeadowCloudService>(cloudConnectionService);
var commandService = new MeadowCloudCommandService(cloudConnectionService);
Resolver.Services.Add<ICommandService>(commandService);
var updateService = new MeadowCloudUpdateService(
CurrentDevice.PlatformOS.FileSystem.FileSystemRoot,
cloudConnectionService);
Resolver.Services.Add<IUpdateService>(updateService);
if (MeadowCloudSettings.EnableUpdates)
{
updateService.Start();
}
var healthReporter = new HealthReporter();
Resolver.Services.Add<IHealthReporter>(healthReporter);
if (MeadowCloudSettings.EnableHealthMetrics)
{
if (MeadowCloudSettings.HealthMetricsIntervalMinutes > 0)
{
healthReporter.Start(MeadowCloudSettings.HealthMetricsIntervalMinutes).RethrowUnhandledExceptions();
}
else
{
Resolver.Log.Warn($"Health metrics interval of {MeadowCloudSettings.HealthMetricsIntervalMinutes} is invalid.");
}
}
if (MeadowCloudSettings.Enabled
|| MeadowCloudSettings.EnableUpdates
|| MeadowCloudSettings.EnableHealthMetrics)
{
Resolver.Log.Info($"Meadow cloud base features: {(MeadowCloudSettings.Enabled ? "enabled" : "disabled")}");
Resolver.Log.Info($"Meadow cloud updates: {(MeadowCloudSettings.EnableUpdates ? "enabled" : "disabled")}");
Resolver.Log.Info($"Meadow cloud health metrics: {(MeadowCloudSettings.EnableHealthMetrics ? "enabled" : "disabled")}");
cloudConnectionService.Start();
}
else
{
Resolver.Log.Info("All cloud features are disabled.");
}
return true;
}
catch (Exception e)
{
Resolver.Log.Error(e.ToString());
return false;
}
}
private static ManualResetEvent _forceTerminate = new ManualResetEvent(false);
/// <summary>
/// Cancel the meadow OS application Run call and allow the process to exit
/// </summary>
public static void TerminateRun()
{
AppAbort.Cancel();
_forceTerminate.Set();
}
private static void Shutdown()
{
AppAbort.Cancel(true);
// stop the update service
if (Resolver.Services.Get<IMeadowCloudService>() is { } cloudService)
{
cloudService.Stop();
}
// schedule a device restart if possible and if the user hasn't disabled it
ScheduleRestart();
// Do a best-attempt at freeing memory and resources
GC.Collect(GC.MaxGeneration);
Resolver.Log.Debug("Shutdown");
// just put the Main thread to sleep (don't exit) because we want the Update service to still be able to work
_forceTerminate.WaitOne();
}
/// <summary>
/// Creates the named OS directories if they don't exist, and makes sure
/// the `/Temp` directory is emptied out.
/// </summary>
internal static void InitializeFileSystem()
{
CreateFolderIfNeeded(FileSystem.CacheDirectory);
CreateFolderIfNeeded(FileSystem.DataDirectory);
CreateFolderIfNeeded(FileSystem.DocumentsDirectory);
EmptyDirectory(FileSystem.TempDirectory);
CreateFolderIfNeeded(FileSystem.TempDirectory);
}
private static void EmptyDirectory(string path)
{
if (Directory.Exists(path))
{
foreach (var file in Directory.GetFiles(path))
{
File.Delete(file);
}
}
}
private static void CreateFolderIfNeeded(string path)
{
if (!Directory.Exists(path))
{
try
{
Directory.CreateDirectory(path);
}
catch (Exception ex)
{
Resolver.Log.Error($"Failed: {ex.Message}");
}
}
}
private static void ScheduleRestart()
{
if (LifecycleSettings.RestartOnAppFailure)
{
int restart = 5;
if (LifecycleSettings.AppFailureRestartDelaySeconds >= 0)
{
restart = LifecycleSettings.AppFailureRestartDelaySeconds;
}
if (CurrentDevice != null && CurrentDevice.PlatformOS != null)
{
Resolver.Log.Info($"CRASH: Meadow will restart in {restart} seconds.");
Thread.Sleep(restart * 1000);
CurrentDevice.PlatformOS.Reset();
AppAbort.Cancel();
}
else
{
Resolver.Log.Info($"Initialization failure prevents automatic restart.");
}
}
}
private static void StaticOnUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
// unsure how this would ever happen, but trap it anyway
if (e.ExceptionObject is Exception ex)
{
ReportAppException(ex, "UnhandledException");
}
// final shutdown - which really is just an infinite Sleep()
Shutdown();
}
}
internal static partial class Interop
{
public enum HardwareVersion
{
//#define MEADOW_F7_HW_VERSION_NUMB_F7V1 (1)
//#define MEADOW_F7_HW_VERSION_NUMB_F7V2 (2)
//#define MEADOW_F7_HW_VERSION_NUMB_CCMV2 (3)
Unknown = 0,
F7FeatherV1 = 1,
F7FeatherV2 = 2,
F7CoreComputeV2 = 3,
}
public static partial class Nuttx
{
[DllImport("nuttx")]
public static extern HardwareVersion meadow_os_hardware_version();
}
}