コード例 #1
0
        public HighLow Input(int pin)
        {
            var pinObj = pins[pin];
            var value  = PosixUtils.Cat(pinObj.ValueReader);

            return(value == "1" ? HighLow.High : HighLow.Low);
        }
コード例 #2
0
        public void Setup(int pin, Direction direction, PullUpDown pullUpDown)
        {
            Pin pinObj;

            if (pins.ContainsKey(pin))
            {
                pinObj = pins[pin];
            }
            else
            {
                pinObj = new Pin();

                // export pin
                Export(pin);

                // create direction streams
                pinObj.DirectionStream = new FileStream(string.Format(GpioPinDirectionPath, pin), FileMode.Open,
                                                        FileAccess.ReadWrite, FileShare.ReadWrite);
                pinObj.DirectionWriter = new StreamWriter(pinObj.DirectionStream, Encoding.ASCII);
                pinObj.DirectionReader = new StreamReader(pinObj.DirectionStream, Encoding.ASCII);

                // create value streams
                pinObj.ValueStream = new FileStream(string.Format(GpioPinValuePath, pin), FileMode.Open,
                                                    FileAccess.ReadWrite, FileShare.ReadWrite);
                pinObj.ValueWriter = new StreamWriter(pinObj.ValueStream, Encoding.ASCII);
                pinObj.ValueReader = new StreamReader(pinObj.ValueStream, Encoding.ASCII);

                pins.Add(pin, pinObj);
            }

            // set pin direction
            PosixUtils.Echo(pinObj.DirectionWriter, direction == Direction.Input ? "in" : "out");

            // TODO : and pull up down ?
        }
コード例 #3
0
        private void Unexport(int pin)
        {
            if (!IsExported(pin))
            {
                return;
            }

            PosixUtils.Echo(unexportWriter, pin.ToString());
        }
コード例 #4
0
        private void OutputGpio(Pin pin, HighLow value, long duration = -1)
        {
            PosixUtils.Echo(pin.ValueWriter, value == HighLow.High ? "1" : "0");

            if (duration != -1)
            {
                operatingSystemService.NanoSleep(duration);
            }
        }
コード例 #5
0
        public void Start()
        {
            var process =
                PosixUtils.CreateBashCommandProcess(
                    "raspivid -t 0 -w 480 -h 260 -fps 23 -b 800000 -p 0,0,640,480 -o - | gst-launch -v fdsrc !  h264parse ! rtph264pay config-interval=10 pt=96 ! udpsink host=192.168.0.3 port=5000");

            process.Start();
            process.Close();

            started = true;
        }
コード例 #6
0
ファイル: ImageCapture.cs プロジェクト: cyrilbec/RobotSharp
        private Stream GetJpegsInputStream()
        {
            // stdout from pipe
            // sample command line :
            // raspistill -n -e jpg -w 640 -h 480 -q 75 -x none -tl 0 -t 10000 -o - | mono RobotSharp.ImageCapture.exe
            //return Console.OpenStandardInput();

            PosixUtils.ExecuteKillAll("raspistill");

            // start a process and get his stdout's
            imageGeneratorProcess = PosixUtils.CreateBashCommandProcess("raspistill -n -e jpg -w 640 -h 480 -q 75 -x none -tl 0 -o -");
            imageGeneratorProcess.Start();
            return(imageGeneratorProcess.StandardOutput.BaseStream);
        }
コード例 #7
0
 public void Stop()
 {
     PosixUtils.ExecuteKillAll("raspivid");
     started = false;
 }