I've got an asp.net mvc website up and running great on the pi, and I'm even blinking an led - however, I would like to take a picture from the site using the raspberry pi camera board. I am attempting to use the following code:
Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "/bin/bash";
proc.StartInfo.Arguments = "raspistill -o image.jpg";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
However, every time I try to do that I get the error
user/bin/raspistill: /usr/bin/raspistill: cannot execute binary file
Does anyone have any idea why this isn't working, or how I can run a bash command from mono/C#?
-
have you tried to run the same command from the terminal? what was the result?lenik– lenik2013年09月09日 00:19:36 +00:00Commented Sep 9, 2013 at 0:19
-
1How are you running asp.net and mono on your Pi? I tried installing mono and xsp2 and xsp4 but couldn't get a simple web page to run.HeatfanJohn– HeatfanJohn2013年09月09日 01:18:14 +00:00Commented Sep 9, 2013 at 1:18
-
@lenik - when done from the terminal it works exactly as intended.Steve French– Steve French2013年09月09日 01:46:16 +00:00Commented Sep 9, 2013 at 1:46
-
@HeatfanJohn - I followed this tutorial exactly and it worked quite well codewithmac.com/2013/05/asp-net-mvc-on-your-raspberry-pi - the key is installing Debian, not RaspianSteve French– Steve French2013年09月09日 01:47:18 +00:00Commented Sep 9, 2013 at 1:47
-
Ah, I'm not running soft-floatHeatfanJohn– HeatfanJohn2013年09月09日 02:32:57 +00:00Commented Sep 9, 2013 at 2:32
1 Answer 1
Update
You need to add the -c
option to the argument string for /bin/bash
:
proc.StartInfo.Arguments = "-c raspistill -o image.jpg";
I get the same cannot execute binary file
when I try to run /bin/bash /usr/bin/raspistill -?
from the command line.
raspberrypi ~ $ /bin/bash /usr/bin/raspistill -?
/usr/bin/raspistill: /usr/bin/raspistill: cannot execute binary file
Running /bin/bash -c /usr/bin/raspistill -?
works from the command line.
Also, according to this SO article try running /usr/bin/raspistill
directly from Process.Start()
as shown below:
Process.Start("/usr/bin/raspistill", "-?");
-
That's the one! It works perfectlySteve French– Steve French2013年09月13日 02:07:49 +00:00Commented Sep 13, 2013 at 2:07