Porting C# application onto GRV native linux

Interesting thought, though the team wants to standardize on C#

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!

Has anyone tried running the .net core Linux ARM64 ARM32 runtime on EPIC?

Edit: ARM32… getting ahead of myself…

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?

Click on the menu in the top right corner.
Then on Manage Palette.
Then on the Install Tab.
Type in Opto for the search term.

1 Like

If I have no internet access directly, is there a place where one can put the files and have them show up?

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…

1 Like

Yes and use Linux all the time except at work. LOL

Sent you a PM. Check your forum inbox.

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.

2 Likes

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.

Thanks for feedback

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.

I think the above approach is easiest, but you can also install the core runtime on the epic if you wish by using wget of the runtime direct from microsoft (https://download.visualstudio.microsoft.com/download/pr/60d21925-7f8f-4004-9afe-aebd041d2d4a/0db2946738642d7f88f71f7800522e8c/dotnet-runtime-3.1.0-linux-arm.tar.gz) and extract it to a folder. You will have to set a dot net root environment variable. See https://docs.microsoft.com/en-us/dotnet/core/install/runtime?pivots=os-linux

2 Likes

This is great Philip. I think I can make this play.

I can confirm that asp.net core 3.1 apps will run on EPIC as well.

An update for all. I downloaded the dotnet CLI Core 3.1 and manually installed to EPIC. There are three environment variables to set and then it works well. At least I was able to compile and run a .NET HelloWorld from the SSH Shell. I used the scp command to ssh copy files over as needed and then shell into the epic machine and make things play. I will post back here some instructions as soon as I get to where I can do that. (working through several levels of virtual remote computing here at the moment.)

2 Likes

I am working from home at the moment (WA state). I can successfully use the Optommp4.dll with VS Studio Community 2019 on my Win10 machine to run a simple c# console program to read from EPIC. I noticed the dependency on Framework vs Core. It would be very nice if a build against Core 3.1 (etc) could be provided.

I do have the dotnet cli running on EPIC directly. It is not clear to me if the Optommp4.dll is dependent on a non-arm (Windows/Intel hardware). I plan to give it a try by adding the reference to dotnet on arm and see if it will run with it.

I will also be playing with the C++ SDK too. I could do a few simple functions that get called from the C# code as in a library or such.

Yes it would be nice if the Managed MMP SDK was recompiled to target core. As I mentioned before, I wrote my own managed MMP library before Opto22 had one. It was based off the C++ SDK, which included source code. I changed the target from .net framework to .net core and recompiled and it worked, no changes needed.

I’ve attached the c# source of my library. This works fine for the applications I’ve used it for - all PAC stuff. I’ve only tested it with EPIC for this forum thread, so be sure to test it thoroughly.

Opto22LibraryCore.zip (21.8 KB)

Thanks Philip, darn useful!

An update for folks interested. I have been able to “port” (a console application which runs in the Windows environment) over to the EPIC by simply copying the files to a directory where I have created a dotnet project (using dotnet new console).

dotmet run and it builds and goes! Performing I/O and displaying messages on the shell console.