Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to set the serial port state #54

Open
Void-Overflow opened this issue Jan 30, 2021 · 0 comments
Open

unable to set the serial port state #54

Void-Overflow opened this issue Jan 30, 2021 · 0 comments

Comments

@Void-Overflow
Copy link

Hi I'm using the Arduino Sketch Uploader to upload some code to my arduino. I have set everything like the com port and fiile, and it gets through that part without any exception. Only, when I connect my arduino through usb and click my upload button, the entire form freezes until I disconnect my arduino. Afterwards it gives me the error "unable to set the serial port state" below you will find my code -

private void button2_Click(object sender, EventArgs e) { button2.Text = "Uploading..."; foreach (string s in checkedListBox1.CheckedItems) { if (s == "Arduino Nano R3 (Recommended )") { model = ArduinoModel.NanoR3; }

            `else if (s == "Arduino Nano R2")
            {
                model = ArduinoModel.NanoR2;
            }

            else if (s == "Arduino Mega")
            {
                model = ArduinoModel.Mega2560;
            }

            else if (s == "Arduino Micro")
            {
                model = ArduinoModel.Micro;
            }

            else if (s == "Arduino Uno")
            {
                model = ArduinoModel.UnoR3;
            }

            else
            {
                model = ArduinoModel.NanoR3;
            }
        }

        foreach (string s in checkedListBox2.CheckedItems)
        {
            port = s;
        }

        var uploader = new ArduinoSketchUploader(
          new ArduinoSketchUploaderOptions()
          {
              FileName = @file,
              PortName = port,
              ArduinoModel = model
          });

        try
        {
            uploader.UploadSketch();
        }
        catch (Exception ex)
        {
            errs = ex.Message;
        }

        msg = (string)( "Uploading: " + file + ";" + model + ";" + port);

        if (errs.Length > 0)
        {
            label12.Text = errs;
            label12.BackColor = Color.Red;
            button2.Text = "Failed";
        }
        else
        {
            label12.Text = msg;
            label12.BackColor = Color.YellowGreen;
            button2.Text = "Uploaded";
        }
        
    }`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant