I have a c# application that is running on an embedded PC which uses the .NET SDK (the dll) from Opto22 to gather data from I/O processors such as the SNAP-PAC-EB2. This application then interfaces to a larger system.
I would like to port a portion of this application to run natively on a GRV-EPIC-PR1. This would allow me to get rid of the embedded PC. There is a lot of code written in C# that I do not want to rewrite. I was thinking possibly to use mono to run it on Linux.
Has anyone done anything like this or have a better idea?
Unfortunately .NET applications are heavily Windows-based and so they often have issues running on Linux systems. While there are some workarounds like mono, they have a lot overhead when it comes to both resources like RAM and CPU as well as strict software prerequisites that have stopped me from using mono in the past.
Depending on how much experience you have getting software like this running it still might be worth a try, but thereās no go-to way of running C# / .NET applications at this stage.
It is basically a very simple console app. I will explore on a Linux dev system I have and see if it plays. If not I have other options such as porting to C++ and compiling with gcc. I assume one can use the Shell access on the GRV-PR1 to copy over a cross compiled program, or does the PR1 have sufficient resources to run gcc natively? (I have one on order to explore it better when it arrives)
@JerryD GGC version 5.2.0 is preinstalled on groov EPIC and compiles on-board very well in my experience. If you can port to C++ that would certainly be an option worth exploring.
Yes and in fact I have implemented several charts which perform most of the needed tasks as a demonstration and performance test. Timing is critical and there is little to no user interface to be concerned with. The existing application is written in C# running over Windows and the lead developers are very c# savvy.
As soon as the groov hardware arrives I will be exploring both c# and Pac Control.
Regarding this idea of using C++, is there an OptoMMP library on the groov accessible via C++ or does one access the OptoMMP interface via the local port 2000 (IEEE 1394)?
There is an OptoMMP C++ library (PAC-DEV-OPTOMMP-CPLUS), where OptoMMP uses port 2001 on groov EPIC.
Also, if you are going to work with that library I highly recommend checking out the OptoMMP Protocol Guide (form 1465), it has a ton of very useful information!
I am using the .NET OptoMMP now quite successfully and this is running on a Windows machine. C++ is a real possibility. I also started exploring Node RED here on the EPIC-PR1 that just arrived. This is also interesting. Where are the Opto22 Nodes I see in the video. I assume these would allow one to get data from I/O modules?
Not really. You need to copy the .node-red directory from an EPIC that has had the nodes installed.
We have an āimageā of such a an EPIC if you are game.
You need to have SSH installed and be comfortable working in shell which I suspect you areā¦
I tested a .NET core 3.1 console application compiled to ARM32 on EPIC. The app opened port 2001 and wrote a test string to the scratchpad and read it back. Worked just fine.
The binary was a bit large at ~31MB with the .NET core compiled in, but has the benefit of not needing any dependencies being installed - including the framework itself.
Additional info: When installing the .NET core runtime and building the application as framework dependent, the executable size dropped to 117KB. The size of the runtime itself is 74MB. Memory usage when the application is running is about 21MB either way.
The OptoMMP code I used to read and write to the scratchpad is my own library I wrote several years ago before Opto had a managed code SDK. My library was targeting .NET Framework 4.5, I changed this to .NET Core 3.1 and built - no source code changes were needed.
If your developers are set on sticking with C#, this looks like a viable path to me. Maybe Opto could build their managed SDK targeting .NET core for you.
Good information Philip. How exactly did you install and compile this on the ARM32 EPIC? I ask because of my limited connectivity with the EPIC-PR1 to the outside world. However, if you installed using apt-get or some process similar, I will see what I can arrange here.
As I side note, I am able to import the original application into monodevelop on another Linux box by starting with an empty āsolutionā and āaddingā individual files.
I compiled a binary on my PC and transferred it to the EPIC.
I believe these are the minimum steps to get this working. I did other things too in my experimenting so if it doesnāt work, let me know.
I installed Visual Studio 2019 (required for core 3.1) which has .net core 3.1 sdk with it.
I setup the project in VS to target .NET Core 3.1.
I created a new Publish profile - set to Folder.
I then edited the Publish profile, set the Deployment Mode to āSelf-containedā. This ensures all the dependencies are published to your deployment folder so you donāt need to install the sdk or runtime on the EPIC at all.
I set the Target Runtime to linux-arm
I changed the File Publish Options to produce a single file which will compile in all the dependencies into a single binary.
I ran the publish, and then scpād the resulting file to the EPIC. I then chmod +x the binary and then executed it.