Skip to content

Commit 6e4d1e2

Browse files
committed
Update Serial Communication sample
- Add access to ReadBufferSize property. - Improve explanation for ESP32 targets. - Update NuGet packages.
1 parent 9c4993f commit 6e4d1e2

File tree

4 files changed

+37
-49
lines changed

4 files changed

+37
-49
lines changed

samples/SerialCommunication/SerialCommunication/Scenario1_ConfigureDevice.cs

+19-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//
1+
//
22
// Copyright (c) .NET Foundation and Contributors
33
// See LICENSE file in the project root for full license information.
44
//
@@ -11,16 +11,18 @@
1111
using nanoFramework.Hardware.Esp32;
1212
#endif
1313

14-
//////////////////////////////////////////////////////////////////////////////
15-
//////////////////////////////////////////////////////////////////////////////
16-
/// ///
17-
/// NOTE: when working with ESP32 edit the nfproj file and add ///
18-
/// BUIID_FOR_ESP32 to the DefineConstants, like this: ///
19-
/// ///
20-
/// <DefineConstants>$(DefineConstants);BUIID_FOR_ESP32;</DefineConstants> ///
21-
/// ///
22-
//////////////////////////////////////////////////////////////////////////////
23-
//////////////////////////////////////////////////////////////////////////////
14+
///////////////////////////////////////////////////////////////////////////////////
15+
///////////////////////////////////////////////////////////////////////////////////
16+
/// ///
17+
/// NOTE: when working with ESP32 edit the nfproj file and add ///
18+
/// BUIID_FOR_ESP32 to the DefineConstants, like this: ///
19+
/// ///
20+
/// <DefineConstants>$(DefineConstants);BUIID_FOR_ESP32;</DefineConstants> ///
21+
/// ///
22+
/// You'll also need to add a reference to 'nanoFramework.Hardware.Esp32' NuGet ///
23+
/// ///
24+
///////////////////////////////////////////////////////////////////////////////////
25+
///////////////////////////////////////////////////////////////////////////////////
2426

2527
namespace SerialCommunication
2628
{
@@ -54,15 +56,19 @@ public static void Main()
5456
///////////////////////////////////////////////////////////////////////////////////////////////////
5557
// COM6 in STM32F769IDiscovery board (Tx, Rx pins exposed in Arduino header CN13: TX->D1, RX->D0)
5658
// open COM6
57-
_serialDevice = new SerialPort("COM2");
59+
_serialDevice = new SerialPort("COM6");
5860
#endif
5961
// set parameters
6062
_serialDevice.BaudRate = 9600;
61-
_serialDevice.Parity = Parity.None ;
63+
_serialDevice.Parity = Parity.None;
6264
_serialDevice.StopBits = StopBits.One;
6365
_serialDevice.Handshake = Handshake.None;
6466
_serialDevice.DataBits = 8;
6567

68+
// if dealing with massive data input, increase the buffer size
69+
_serialDevice.ReadBufferSize = 2048;
70+
71+
// open the serial port with the above settings
6672
_serialDevice.Open();
6773

6874
// uncomment the scenario to test (!!note that none of these returns!!)

samples/SerialCommunication/SerialCommunication/SerialCommunication.nfproj

+10-20
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,20 @@
2727
<Compile Include="Scenario4_DataReceivedEvent.cs" />
2828
</ItemGroup>
2929
<ItemGroup>
30-
<Reference Include="mscorlib, Version=1.11.7.2, Culture=neutral, PublicKeyToken=c07d481e9758c731">
31-
<HintPath>packages\nanoFramework.CoreLibrary.1.11.7\lib\mscorlib.dll</HintPath>
32-
<Private>True</Private>
30+
<Reference Include="mscorlib">
31+
<HintPath>packages\nanoFramework.CoreLibrary.1.12.0-preview.9\lib\mscorlib.dll</HintPath>
3332
</Reference>
34-
<Reference Include="nanoFramework.Hardware.Esp32, Version=1.3.3.0, Culture=neutral, PublicKeyToken=c07d481e9758c731" Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($(DefineConstants), '^(.*;)*BUIID_FOR_ESP32(;.*)*$'))">
35-
<HintPath>packages\nanoFramework.Hardware.Esp32.1.3.3-preview.12\lib\nanoFramework.Hardware.Esp32.dll</HintPath>
36-
<Private>True</Private>
37-
<SpecificVersion>True</SpecificVersion>
33+
<Reference Include="nanoFramework.Runtime.Events">
34+
<HintPath>packages\nanoFramework.Runtime.Events.1.10.0-preview.8\lib\nanoFramework.Runtime.Events.dll</HintPath>
3835
</Reference>
39-
<Reference Include="nanoFramework.Hardware.Esp32, Version=1.3.4.3, Culture=neutral, PublicKeyToken=c07d481e9758c731">
40-
<HintPath>packages\nanoFramework.Hardware.Esp32.1.3.4\lib\nanoFramework.Hardware.Esp32.dll</HintPath>
41-
<Private>True</Private>
36+
<Reference Include="nanoFramework.System.Text">
37+
<HintPath>packages\nanoFramework.System.Text.1.1.3-preview.15\lib\nanoFramework.System.Text.dll</HintPath>
4238
</Reference>
43-
<Reference Include="nanoFramework.Runtime.Events, Version=1.9.2.3, Culture=neutral, PublicKeyToken=c07d481e9758c731">
44-
<HintPath>packages\nanoFramework.Runtime.Events.1.9.2\lib\nanoFramework.Runtime.Events.dll</HintPath>
45-
<Private>True</Private>
39+
<Reference Include="System.IO.Ports">
40+
<HintPath>packages\nanoFramework.System.IO.Ports.1.0.3-preview.33\lib\System.IO.Ports.dll</HintPath>
4641
</Reference>
47-
<Reference Include="nanoFramework.System.Text, Version=1.1.2.3, Culture=neutral, PublicKeyToken=c07d481e9758c731">
48-
<HintPath>packages\nanoFramework.System.Text.1.1.2\lib\nanoFramework.System.Text.dll</HintPath>
49-
<Private>True</Private>
50-
</Reference>
51-
<Reference Include="System.IO.Ports, Version=1.0.2.3, Culture=neutral, PublicKeyToken=c07d481e9758c731">
52-
<HintPath>packages\nanoFramework.System.IO.Ports.1.0.2\lib\System.IO.Ports.dll</HintPath>
53-
<Private>True</Private>
42+
<Reference Include="System.IO.Streams">
43+
<HintPath>packages\nanoFramework.System.IO.Streams.1.0.0-preview.12\lib\System.IO.Streams.dll</HintPath>
5444
</Reference>
5545
</ItemGroup>
5646
<ItemGroup>

samples/SerialCommunication/SerialCommunication/SerialCommunication.sln

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
21
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.31410.357
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.1.32210.238
54
MinimumVisualStudioVersion = 10.0.40219.1
65
Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "SerialCommunication", "SerialCommunication.nfproj", "{F7E58E73-882C-4B77-9A2A-23A8B4B35D0E}"
76
EndProject
8-
Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "System.IO.Ports", "..\..\..\..\nf-System.IO.Ports\System.IO.Ports\System.IO.Ports.nfproj", "{8D7253CC-A767-4D5D-9CFF-74282D75C1FA}"
9-
EndProject
107
Global
118
GlobalSection(SolutionConfigurationPlatforms) = preSolution
129
Debug|Any CPU = Debug|Any CPU
@@ -19,12 +16,6 @@ Global
1916
{F7E58E73-882C-4B77-9A2A-23A8B4B35D0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
2017
{F7E58E73-882C-4B77-9A2A-23A8B4B35D0E}.Release|Any CPU.Build.0 = Release|Any CPU
2118
{F7E58E73-882C-4B77-9A2A-23A8B4B35D0E}.Release|Any CPU.Deploy.0 = Release|Any CPU
22-
{8D7253CC-A767-4D5D-9CFF-74282D75C1FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23-
{8D7253CC-A767-4D5D-9CFF-74282D75C1FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
24-
{8D7253CC-A767-4D5D-9CFF-74282D75C1FA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
25-
{8D7253CC-A767-4D5D-9CFF-74282D75C1FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
26-
{8D7253CC-A767-4D5D-9CFF-74282D75C1FA}.Release|Any CPU.Build.0 = Release|Any CPU
27-
{8D7253CC-A767-4D5D-9CFF-74282D75C1FA}.Release|Any CPU.Deploy.0 = Release|Any CPU
2819
EndGlobalSection
2920
GlobalSection(SolutionProperties) = preSolution
3021
HideSolutionNode = FALSE
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="nanoFramework.CoreLibrary" version="1.11.7" targetFramework="netnanoframework10" />
4-
<package id="nanoFramework.Hardware.Esp32" version="1.3.4" targetFramework="netnanoframework10" />
5-
<package id="nanoFramework.Runtime.Events" version="1.9.2" targetFramework="netnanoframework10" />
6-
<package id="nanoFramework.System.IO.Ports" version="1.0.2" targetFramework="netnanoframework10" />
7-
<package id="nanoFramework.System.Text" version="1.1.2" targetFramework="netnanoframework10" />
3+
<package id="nanoFramework.CoreLibrary" version="1.12.0-preview.9" targetFramework="netnanoframework10" />
4+
<package id="nanoFramework.Hardware.Esp32" version="1.3.5-preview.7" targetFramework="netnanoframework10" />
5+
<package id="nanoFramework.Runtime.Events" version="1.10.0-preview.8" targetFramework="netnanoframework10" />
6+
<package id="nanoFramework.System.IO.Ports" version="1.0.3-preview.33" targetFramework="netnanoframework10" />
7+
<package id="nanoFramework.System.IO.Streams" version="1.0.0-preview.12" targetFramework="netnanoframework10" />
8+
<package id="nanoFramework.System.Text" version="1.1.3-preview.15" targetFramework="netnanoframework10" />
89
</packages>

0 commit comments

Comments
 (0)