Programming in C#


#1

Hi, is there any way to program the BrickPi or Raspberry Pi in C# or is it just in C and Python?


#2

Hey Zewwo! Not yet. Can you program in C# on the Raspberry Pi? And if so, has anyone opened up the GPIO’s on the RPi for that?


#3

Well, I haven’t started programming my RPi yet so no I haven’t.
I heard there was Mono-C# but I’m not sure it will work or not with the BrickPI.


#4

I am just trying to get it running. But I did not succeed yet. The serial interface is working in loopback with mono. But the brick is not answering when I send the message to it.


#5

Just as I wrote it I got the solution. There is a bug in mono for which there is a workaround given in http://stackoverflow.com/questions/13206524/error-with-high-baud-rates-using-serialport-on-mono-linux

Now I will implement a class for communication with the BrickPi …


#6

Ok … First implementation is done … The Touch-Sensor example is already working … if someone is interested please let me know.


#7

Hey Pingineer, we’re really interested. Have you considered sharing the code? Maybe you can put it up online?


#8

I am still testing … the motors are not working yet. I can put it up when I managed at least that.


#9

Where should I publish the C#-code? I think it is working so far.


#10

Hey Pingineer! We would love to see the code! If you have a github repo, we would love to take a look at the code, try it out. Do you have a github account?

Also, what did you have to do to get this setup and running? Did you make any changes to the Pi? What image did you start with?


#11

You can find the code here.

I took the recommended BrickPi Wheezy Image. Then I installed the mono package with something like that

sudo apt-get install mono-complete

I am using ‘geany’ as editor for the files. The command

gmcs -out:BrickPi.exe BrickPi.cs BrickTest.cs

compiles the source code. With

mono BrickPi.exe

you can start the program.