Categories
Programming

PhidgetSBC2 Interactive C# Shell

One cool package for playing around with your phidget(s) is mono-csharp-shell which gives you an interactive C# shell (with tab completion).

apt-get install -y mono-csharp-shell

Once the package is installed, you can open it with csharp but just like with gmcs we have to include the reference to the Phidget library.

csharp -r:Phidget21.NET.dll

It will take a bit of time to get to a csharp prompt but be patient and you will be greeted with this:

Mono C# Shell, type "help;" for help

Enter statements below.
csharp>

And now you can freely use the library to interactively control a Phidget from the command line.

csharp> using Phidgets;
csharp> var kit = new InterfaceKit();                  
csharp> kit.open();                   
csharp> kit.waitForAttachment();
csharp> kit.SerialNumber;
47521
csharp> kit.close();
csharp> quit;

Make sure you close any Phidgets you use otherwise you won't be able to end your shell with quit; or Ctrl+D. If you tried to quit without closing, you will have to suspend the shell with Ctrl+Z and then type kill %csharp to kill the shell.

Leave a Reply

Your email address will not be published. Required fields are marked *