What ASP.NET permissions do I need to access a serial port?

前端 未结 3 1741
被撕碎了的回忆
被撕碎了的回忆 2021-01-20 18:11

I am working on a asp.net application and I want it to communicate to a arduino board via a serial port. I created a windows application that could do that and it worked, b

3条回答
  •  走了就别回头了
    2021-01-20 18:51

    Try open connection and close connection on serial port block command. Ex

     SerialPort COM = new System.IO.Ports.SerialPort("COM14");
    protected void btnRele1_Click(object sender, EventArgs e)
    {
        COM.Open();
        if (btnRele1.BackColor != Color.Green)
        {
            COM.WriteLine("1");
            btnRele1.BackColor = Color.Green;
            btnRele1.ForeColor = Color.White;
            btnRele1.Text = "Rele 1 - ON";
        }
        else
        {
            COM.WriteLine("2");
            btnRele1.BackColor = Color.LightGray;
            btnRele1.ForeColor = Color.Black;
            btnRele1.Text = "Rele 1 - OFF";
        }
        txtSerial.Text = COM.ReadLine();
        COM.Close();
    }
    

提交回复
热议问题