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

Serial on Linux causes the Arduino to reset #2

Open
frankvanbever opened this issue Apr 18, 2020 · 3 comments
Open

Serial on Linux causes the Arduino to reset #2

frankvanbever opened this issue Apr 18, 2020 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@frankvanbever
Copy link
Member

Observed behaviour:

  • Whenever the application is started or serial communication is lost using a Linux host the microcontroller is reset.
  • There is a discrepancy between the behaviour on Linux and Windows. On Windows the reset is explicityly disabled.

AC:

  • The microcontroller is not reset whenever the connection is (re)established.
@frankvanbever frankvanbever added the bug Something isn't working label Apr 18, 2020
@frankvanbever frankvanbever self-assigned this Apr 18, 2020
@frankvanbever
Copy link
Member Author

frankvanbever commented Apr 18, 2020

Ok, it seems that setting DTR (Data Terminal Ready) and RTS (Ready To Send) are set in one fell swoop in the Linux CDC ACM kernel (I'm looking at a different version but the logic should be the same).

static void acm_port_dtr_rts(struct tty_port *port, int raise)
{
	struct acm *acm = container_of(port, struct acm, port);
	int val;
	int res;

	if (raise)
		val = ACM_CTRL_DTR | ACM_CTRL_RTS;
	else
		val = 0;

	/* FIXME: add missing ctrlout locking throughout driver */
	acm->ctrlout = val;

	res = acm_set_control(acm, val);
	if (res && (acm->ctrl_caps & USB_CDC_CAP_LINE))
		dev_err(&acm->control->dev, "failed to set dtr/rts\n");
}

This means that either RTS or DTR can trigger DTR high.

The solution might be as simple as setting SerialPort.RtsEnable to false like the code already does with DTR.

@TomBruyneel if you've got the time can you check this? I'll try to get a .Net development environment set up on my Linux machine but that'll take some time.

@TomBruyneel
Copy link
Member

If you want to try the csharp daemon code on linux you will need the following:

  • .net core 3.1 sdk
  • visual studio code with the c# extension from the marketplace

I'll adjusted the code but don't have a linux machine or arduino to test :)

Still, it seemed to me that even without my code running the arduino was reset as soon as it was plugged in

@TomBruyneel
Copy link
Member

A new docker image with the rtsEnable set to false is now available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants