C#
Secondary Develop Elastel Gateways by C#
Elastel gateways are built on an Open Linux OS embedded computer, allowing users to create custom applications using C#. it support running C# applications by installing the .NET runtime environment on Elastel embedded computer.
Typical use cases like:
- High-performance data processing and device control
- Serial, network, and protocol communication (e.g., Modbus RTU/TCP, MQTT, TCP/UDP)
- Real-time control and edge logic processing
- Integration with low-level device drivers or GPIO access
1. Supported Models
Series | Model | Processor Type | Support Status |
---|---|---|---|
Industrial Raspberry Pi Series | EG500, EG410, ElastBox400 | Arm64 | Supported |
ARM-based IIoT Gateway Series | EG324 (Ubuntu OS) | Arm32 | Supported |
EG324 Lite | Arm64 | Supported | |
EC212, EC211 | Arm32 | Not Supported (limited storage) |
✅ EG500/EG410/ElastBox400/EG324L use Arm64 processors.
✅ EG324 uses Arm32 processors.
❌ EC212 and EC211 do not support C# due to limited storage.
2. C# Runtime Environment Setup (Elastel Gateway)
Different Elastel gateway uses different types of ARM processors, requiring the download of corresponding software package versions. The embedded computer does not require the full SDK; only the runtime is needed, such as ASP.NET Core Runtime or .NET Runtime.
- .NET Runtime Download
Open the official download page:https://dotnet.microsoft.com/en-us/download/dotnet/6.0
(using .NET 6.0 as an example).- For EG500/EG410/ElastBox400/EG324L (64-bit processors), select the Arm64 version for download.
- For EG500/EG410/ElastBox400/EG324L (64-bit processors), select the Arm64 version for download.
- For EG324 (32-bit processors), select the Arm32 version for download.
-
Decompress and Set Environment Variables
On the embedded computer, download the file using thecurl
command and decompress it to the/usr/local/dotnet
directory:sudo mkdir -p /usr/local/dotnet
curl -SL https://builds.dotnet.microsoft.com/dotnet/aspnetcore/Runtime/6.0.36/aspnetcore-runtime-6.0.36-linux-arm64.tar.gz | sudo tar -xz -C /usr/local/dotnetNoteThe URL in the
curl
command example above is for the Arm64 version of ASP.NET Core Runtime 6.0.36. Please download the appropriate version and type (ASP.NET Core Runtime or .NET Runtime) as needed.Set the system environment variables (based on the actual decompression path):
export PATH=/usr/local/dotnet:$PATH
You can then use the
dotnet --info
command to check the .NET version number.
3. C# SDK Environment Setup (Windows System)
This section uses Visual Studio 2022 as an example; please install VS2022 beforehand.
- .NET SDK Download
Open the official download page:https://dotnet.microsoft.com/en-us/download/dotnet/6.0
, and download the Windows version of the SDK (e.g., for a 64-bit Windows system). - SDK Installation
Download and install the SDK to complete the PC-side development environment setup.
4. Programming Example: LED Control (ledtest)
The following program controls the system LED blinking via /dev/led
:
using System;
using System.IO;
using System.Threading;
FileStream fs = File.Open("/dev/led", FileMode.Open, FileAccess.Write, FileShare.None);
while (true)
{
fs.WriteByte(0);
fs.Flush();
Thread.Sleep(500);
fs.WriteByte(1);
fs.Flush();
Thread.Sleep(500);
}
fs.Close();
4.1. Compiling the Test Program
Copy the C# test program to the PC. Here take above ledtest
as an example.
Open the project in Visual Studio 2022 and set the target CPU type.
- For EG500/EG410/ElastBox400/EG324L (64-bit ARM processors), select
ARM64
. - For EG324 (32-bit ARM processors), select
ARM32
.
If the desired option is not in the dropdown, click "Configuration Manager" in the options, then select "New" in the pop-up Configuration Manager, and choose the required platform.
Finally, in the VS2022 menu, click "Build" → "Build Solution" to complete the compilation.
4.2. Upload and Run on the Gateway
Copy the compiled folder from the bin
directory of the test program's source to the embedded computer.
Method 1: Upload via Web Terminal (Check ElastPro for more details)
-
Open browser at
http://192.168.1.1
→ System → Terminal → Upload Files -
Move the uploaded file to persistent path:
sudo mv /tmp/terminal/testfile /home/admin/
Method 2: Using MobaXterm / Xshell
- Drag and drop via SFTP to
/home/admin/
.
Run the program:
cd /home/admin
dotnet ledtest.dll
The LED will blink every 0.5 seconds, indicating successful control.
5. Recommended Practices
- Use built-in interfaces (e.g., serial ports, GPIO, LED) for development
- Configure
/etc/init.d/rcS
for startup services or usecrontab
for scheduled runs.
6. Appendix Tables
EG324 Peripheral Resource | Device Interface Name |
---|---|
COM1 | /dev/ttyAMA0 |
COM2 | /dev/ttyAMA1 |
COM3 | /dev/ttyAMA2 |
COM4 | /dev/ttyAMA3 |
SYS LED Indicator | /dev/led |
SYS2 LED Indicator | /dev/led2 |
Buzzer | /dev/buzzer |
Ethernet Port 1 | eth0 |
Ethernet Port 2 | eth1 |
For other models, please contact Elastel support or refer to models hardware manuals for Peripheral Interface tables.
- Official Website:
https://www.elastel.com
- Support Email:
support@elastel.com