Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sdcard etc #110

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions System.IO.FileSystem.UnitTests/DirectoryUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ public void TestEnumerateDirectories()
Directory.CreateDirectory($@"{path}subdir2\");
Directory.CreateDirectory($@"{path}subdir3\");

// Add files to test we don't see files only directories
File.Create($@"{path}file1.txt").Close();
File.Create($@"{path}file2.txt").Close();

var directories = Directory.GetDirectories(path);

Assert.AreEqual(3, directories.Length);
Expand All @@ -119,14 +123,27 @@ public void TestEnumerateFiles()

Directory.CreateDirectory(path);

File.Create($@"{path}file1.txt").Close();
File.Create($@"{path}file2.txt").Close();
File.Create($@"{path}file3.txt").Close();
string file1 = $@"{path}file1.txt";
string file2 = $@"{path}file2.txt";
string file3 = $@"{path}file3.txt";

// Add a mix of directories and files
Directory.CreateDirectory($@"{path}TestDir1");
Directory.CreateDirectory($@"{path}TestDir2");

File.Create(file1).Close();
File.Create(file2).Close();
File.Create(file3).Close();

var files = Directory.GetFiles(path);

Assert.AreEqual(3, files.Length);

// Check correct file names returned
Assert.IsTrue((files[0] == file1), "Invalid file1 in GetFiles()");
Assert.IsTrue((files[1] == file2), "Invalid file2 in GetFiles()");
Assert.IsTrue((files[2] == file3), "Invalid file3 in GetFiles()");

// Clean up after the test
Directory.Delete(path, true);
}
Expand Down
12 changes: 9 additions & 3 deletions System.IO.FileSystem.UnitTests/FileSystemUnitTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,20 @@ public abstract class FileSystemUnitTestsBase
protected SDCard InitializeSDCard()
{
// Example initialization logic
SDCard.SDCardMmcParameters parameters = new SDCard.SDCardMmcParameters
SDCardMmcParameters parameters = new SDCardMmcParameters
{
slotIndex = 0,
dataWidth = SDCard.SDDataWidth._4_bit,
};

SDCardCDParameters cdParameters = new SDCardCDParameters()
{
enableCardDetectPin = true,
cardDetectPin = 21
cardDetectPin = 21,
autoMount = true
};

return new SDCard(parameters);
return new SDCard(parameters, cdParameters);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion System.IO.FileSystem/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

////////////////////////////////////////////////////////////////
// update this whenever the native assembly signature changes //
[assembly: AssemblyNativeVersion("1.1.0.3")]
[assembly: AssemblyNativeVersion("1.1.0.4")]
////////////////////////////////////////////////////////////////

[assembly: InternalsVisibleTo("NFUnitTest, PublicKey=00240000048000009400000006020000002400005253413100040000010001001120aa3e809b3da4f65e1b1f65c0a3a1bf6335c39860ca41acb3c48de278c6b63c5df38239ec1f2e32d58cb897c8c174a5f8e78a9c0b6087d3aef373d7d0f3d9be67700fc2a5a38de1fb71b5b6f6046d841ff35abee2e0b0840a6291a312be184eb311baff5fef0ff6895b9a5f2253aed32fb06b819134f6bb9d531488a87ea2")]
20 changes: 12 additions & 8 deletions System.IO.FileSystem/System.IO.FileSystem.nfproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
<Compile Include="FileMode.cs" />
<Compile Include="FileShare.cs" />
<Compile Include="FileStream.cs" />
<Compile Include="nanoFramework\CardDetectChangedEventArgs.cs" />
<Compile Include="nanoFramework\SDCardCDParameters.cs" />
<Compile Include="nanoFramework\SDCardMmcParameters.cs" />
<Compile Include="nanoFramework\SDCardSpiParameters.cs" />
<Compile Include="NativeFindFile.cs" />
<Compile Include="FileSystemInfo.cs" />
<Compile Include="FileSystemManager.cs" />
Expand All @@ -78,19 +82,19 @@
<Content Include="packages.lock.json" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib, Version=1.15.6.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<Reference Include="mscorlib">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These versions and sing key tokens need to be here.

Copy link
Member Author

@AdrianSoundy AdrianSoundy Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had problems updating to latest nugets so removed and added again and that's what i ended with. Seems to build ok. I can manually add token etc back in.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to manually update version for gitversion in project for it to update properly.

<HintPath>..\packages\nanoFramework.CoreLibrary.1.15.5\lib\mscorlib.dll</HintPath>
</Reference>
<Reference Include="nanoFramework.Runtime.Events, Version=1.11.18.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<Reference Include="nanoFramework.Runtime.Events">
<HintPath>..\packages\nanoFramework.Runtime.Events.1.11.18\lib\nanoFramework.Runtime.Events.dll</HintPath>
</Reference>
<Reference Include="nanoFramework.System.Runtime, Version=1.0.27.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<Reference Include="nanoFramework.System.Runtime">
<HintPath>..\packages\nanoFramework.System.Runtime.1.0.27\lib\nanoFramework.System.Runtime.dll</HintPath>
</Reference>
<Reference Include="nanoFramework.System.Text, Version=1.2.54.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<Reference Include="nanoFramework.System.Text">
<HintPath>..\packages\nanoFramework.System.Text.1.2.54\lib\nanoFramework.System.Text.dll</HintPath>
</Reference>
<Reference Include="System.IO.Streams, Version=1.1.59.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
<Reference Include="System.IO.Streams">
<HintPath>..\packages\nanoFramework.System.IO.Streams.1.1.59\lib\System.IO.Streams.dll</HintPath>
</Reference>
</ItemGroup>
Expand All @@ -104,8 +108,8 @@
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Nerdbank.GitVersioning.3.6.139\build\Nerdbank.GitVersioning.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Nerdbank.GitVersioning.3.6.139\build\Nerdbank.GitVersioning.props'))" />
<Error Condition="!Exists('..\packages\Nerdbank.GitVersioning.3.6.139\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Nerdbank.GitVersioning.3.6.139\build\Nerdbank.GitVersioning.targets'))" />
<Error Condition="!Exists('..\packages\Nerdbank.GitVersioning.3.6.141\build\Nerdbank.GitVersioning.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Nerdbank.GitVersioning.3.6.141\build\Nerdbank.GitVersioning.props'))" />
<Error Condition="!Exists('..\packages\Nerdbank.GitVersioning.3.6.141\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Nerdbank.GitVersioning.3.6.141\build\Nerdbank.GitVersioning.targets'))" />
</Target>
<Import Project="..\packages\Nerdbank.GitVersioning.3.6.139\build\Nerdbank.GitVersioning.targets" Condition="Exists('..\packages\Nerdbank.GitVersioning.3.6.139\build\Nerdbank.GitVersioning.targets')" />
<Import Project="..\packages\Nerdbank.GitVersioning.3.6.141\build\Nerdbank.GitVersioning.targets" Condition="Exists('..\packages\Nerdbank.GitVersioning.3.6.141\build\Nerdbank.GitVersioning.targets')" />
</Project>
50 changes: 50 additions & 0 deletions System.IO.FileSystem/nanoFramework/CardDetectChangedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//

using System;

namespace nanoFramework.System.IO
{
/// <summary>
/// State of card detect
/// </summary>
public enum CardDetectState
{
/// <summary>
/// Card Inserted
/// </summary>
Inserted,

/// <summary>
/// Card removed
/// </summary>
Removed
};

/// <summary>
/// Arguments for Card detect event
/// </summary>
public class CardDetectChangedEventArgs : EventArgs
{
private CardDetectState _cardState;
private uint _slotIndex;

internal CardDetectChangedEventArgs(CardDetectState state, uint SlotIndex)
{
_cardState = state;
_slotIndex = SlotIndex;
}

/// <summary>
/// State of Card Detect.
/// </summary>
public CardDetectState CardState => _cardState;

/// <summary>
/// SD card slot index
/// </summary>
public uint SlotIndex => _slotIndex;
}
}
Loading
Loading