GithubHelp home page GithubHelp logo

Change COM Port and reconnect about ardity HOT 5 CLOSED

dwilches avatar dwilches commented on July 24, 2024
Change COM Port and reconnect

from ardity.

Comments (5)

dwilches avatar dwilches commented on July 24, 2024 1

Hello,

To do what you ask, I can think of a bit of a hack: you could call Destroy with the SerialController (not the GameObject but the MonoBehaviour). Then attach a new SerialController to the same GameObject using AddComponent. You can configure the newly created component before your function ends, and those values will be respected by the initialization code of the SerialController.

But, have you tried these options?

  • Arduinos come with a "reset" button, have you tried pressing it instead of physically reconnecting it? Maybe it doesn't change the COM number in this way.
  • Have you inquired into why the COM port used is different each time? Usually, reconnecting a device on the same USB port gives the same COM port. Anyway, have you gone to the "Device Manager" > Find your device > "Properties" and assign a fixed COM port there?

Regards.

from ardity.

dwilches avatar dwilches commented on July 24, 2024

Hello,
Is your issue solved?

from ardity.

DarioScocco avatar DarioScocco commented on July 24, 2024

from ardity.

tlondero avatar tlondero commented on July 24, 2024

I dont know if it's too late, but I've solved the problem creating a public methon inside the SerialController class:

public void ChangeCOM(string COM) {
OnDisable();
portName = COM;
OnEnable();
}

Maybe it's not the best way to solve the issue, but it works for me.

from ardity.

WoutStandaert avatar WoutStandaert commented on July 24, 2024

Hey guys, @tlondero 's solution is working, but @dwilches 's solution of creating the component from code doesn't. This is what I'm trying to do:

_serialController = gameObject.AddComponent<SerialController>();
_serialController.baudRate = 115200;
_serialController.portName = "COM7";

-> and anyway it will try to open COM3.

I think eventually there should be a proper way to create the SerialController class from code, because in my case for example I'm setting the COM port with a config file. For now, @tlondero 's solution is working but it's a bit hacky.

from ardity.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.