0

I have written a programme in C#.Net Winforms (I'm new to programming) that runs on a Raspberry Pi.

Connected to the Pi is an Afadruit Fona (Sim800L).

I am using the following library: https://github.com/PervasiveDigital/SimComDotNet.git, to communicate with the Fona.

The problem that I am having is that when it tries to perform a single command on the fona, the thread crashes. No matter what command I perform on the fona; I've tried loads, it always crashes after the first attempt.

私が書いた以下のクラスでは、UseExternalAudio コマンドの直後にクラッシュしました。

コードは次のとおりです。

using System.IO;
using System.IO.Ports;
using Molarity.Hardare.AdafruitFona;
using System.ComponentModel;

namespace FAS
{
    public class call
    {
        private BackgroundWorker worker = new BackgroundWorker();
        private string number;
        public bool open_call=false, close_call=false;

        public call(string path)
        {
            number = ReadAllText(path + @"/number");
            worker.DoWork += new DoWorkEventHandler(worker_DoWork);
            if (bw.IsBusy != true) bw.RunWorkerAsync();
        }

        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            SerialPort port = new SerialPort("/dev/ttyUSB0", 115200, Parity.None, 8, StopBits.One);
            FonaDevice fona = new FonaDevice(port);
            fona.UseExternalAudio=true;
            while (true)
            {
                if (open_call) 
                {
                    fona.PhoneCall(number);
                    open_call=false;
                }
                if (close_call)
                {
                    fona.HangUp();
                    close_call=false;
                }
            }
        }
    }
}

誰か助けてくれませんか!?

4

0 に答える 0