Closed KurtE closed 2 years ago
Notes: @PaulStoffregen ran it on Ubuntu and simple sketch worked fine (did not reproduce the issue) @mjs513 and myself ran it on RPI4 running Ubuntu (RC7) and it worked fine I also tried it on MAC using daily build and it worked fine.
So it looks like Windows Specific thing
Thanks @KurtE. I am also able to reproduce the issue on my Windows machine using arduino-cli monitor
:
$ arduino-cli version
arduino-cli.exe Version: git-snapshot Commit: 64bc4dce Date: 2022-06-17T13:21:10Z
$ arduino-cli monitor --fqbn teensy:avr:teensy41 --port usb:0/1A0000/0/1/5/1/1/1 --protocol teensy
Connected to usb:0/1A0000/0/1/5/1/1/1! Press CTRL-C to exit.
Start of Echo Test
asdf
$ arduino-cli monitor --fqbn teensy:avr:teensy41 --port COM40 --protocol serial
Connected to COM40! Press CTRL-C to exit.
Start of Echo Test
asdf
Received:(asdf
)
And Arduino CLI also behaves as reported after uncommenting the "Alive Count" output line:
$ ./arduino-cli monitor --fqbn teensy:avr:teensy41 --port usb:0/1A0000/0/1/5/1/1/1 --protocol teensy
Connected to usb:0/1A0000/0/1/5/1/1/1! Press CTRL-C to exit.
Start of Echo Test
Alive Count: 1
Alive Count: 2
asdf
Alive Count: 3
Received:(asdf
)
Alive Count: 4
Likewise, the problem does not occur on my Linux machine:
$ ./arduino-cli monitor --fqbn teensy:avr:teensy41 --protocol teensy --port usb3/3-3
Connected to usb3/3-3! Press CTRL-C to exit.
Start of Echo Test
asdf
Received:(asdf
)
This tells me that the issue is not in the Arduino IDE code base. However, I'm not sure whether it is in Arduino CLI or in teensy-monitor. I'll transfer this to the Arduino CLI repo for now as that is at least closer to the correct place even if possibly not exactly it.
@cmaglie @PaulStoffregen @per1234 - Wondering if there is some simple test I can do to help to determine if it is a CLI issue or something with how the Teensy Pluggable Serial monitor code interacts with the CLI?
You may try to manually run the teensy monitor and insert the commands to connect to the port, this way you can completely exclude the Arduino CLI. It's a bit tricky but doable, here is the procedure:
1) first of all you must run a program to listen to a TCP socket. Usually, on Linux/mac I use netcat, the command is nc -l 12345
this will open a socket at port 12345
. Any random port is OK, AFAIK there should be also a netcat for Windows.
2) from another terminal run teensy-monitor.exe
, the program should just wait for some inputs without any prompt. Enter:
HELLO 1 "arduino-cli"
the monitor should answer with a confirmation message in JSON, after that enter:OPEN 127.0.0.1:12345 usb3/3-3
where 127.0.0.1:12345
is the IP:PORT where you are listening, and usb3/3-3
is the address of the teensy port.
3) At this point the monitor should be proxying the data back and forth from the teensy to netcat.If you see the correct output from netcat then the problem is in the Arduino CLI, otherwise, we must search for the bug in the teensy monitor.
@cmaglie Thanks,
I installed ncat on my windows PC. Running with two command prompts:
With the sketch:
elapsedMillis em = 0;
uint32_t alive_count = 0;
void setup() {
pinMode(13, OUTPUT);
while (!Serial)
;
Serial.begin(115200);
delay(1000);
Serial.println("Start of Echo Test");
}
void loop() {
if (Serial.available()) {
digitalToggleFast(13);
Serial.print("Received:(");
int ch;
while ((ch = Serial.read()) != -1) Serial.write(ch);
Serial.println(")");
}
#if 1
if (em > 5000) {
// If I Uncomment the print below it echos???
Serial.printf("Alive Count: %u\n", ++alive_count);
em = 0;
}
#endif
}
So in the simple ncat terminal window:
C:\Program Files\Npcap>ncat -l 12345
Start of Echo Test
Alive Count: 1
Alive Count: 2
Alive Count: 3
abcdefg
Alive Count: 4
Received:(abcdefg
)
Alive Count: 5
...
In the other I ran:
C:\Users\kurte\AppData\Local\Arduino15\packages\teensy\tools\teensy-monitor\1.56.53>teensy-monitor.exe
HELLO 1 "arduino-cli"
{
"eventType": "hello",
"protocolVersion": 1,
"message": "OK"
}
OPEN 127.0.0.1:12345 usb:0/140000/0/1/2
{
"eventType": "open",
"message": "OK"
}
And in this case, like with IDE2, I receive the data I typed in, although delayed until the next Serial output.
But if I change the #if 1 to #if 0 Such that it only prints out something if it received something, it never prints anything
C:\Program Files\Npcap>ncat -l 12345
Start of Echo Test
If at first
It did not echo. back.
I tried typing in several more lines of text, like 18 times the following line:
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
And still nothing echoed back. Tried that in case it was something like waiting for a logical Serial flush operation
Note: I built the sketch with USB Type: Serial
Then, the problem is surely in the teensy-monitor.exe
, since we have completely excluded arduino-cli from the test.
You have produced a very good test case, thanks for that!
Quick followup, this was indeed a bug in teensy-monitor.exe. It has been fixed in version 1.57-beta4.
Describe the problem
Originally I had some comments under: arduino/arduino-ide#1051 which was closed today
But Actually it appears to be a little more involved than I first thought. And probably should be it's own track-able issue. @per1234 @PaulStoffregen - not sure which component this be in? @mjs513 - not sure if you also saw something similar when running on RPI with Ubuntu?
Example sketch:
Without the Serial.printf for alive count, the
To reproduce
Using something like the sketch included
I am using today's daily build, with Teensyduino installed using URL: https://www.pjrc.com/teensy/td_156/package_teensy_index.json with current release actually 1.57 Beta 3
I build for Teensy 4.1, USB Type: Serial Although I saw it on yesterdays build with other USB types as well.
So if I build the above sketch: and run it with Teensy Port selected
Typing something in the text area and hitting CTRL+enter does not echo any of the txt nor change state of LED... But if I then change to COM27 instead:
It does echo and led changes state.
Now the interesting point is now if I uncomment the line that outputs alive count... Then it appears to receive input from the Serial port... But maybe only after it writes something to the Serial Port That is there can be a several second delay (i.e. my 5 second elapsedMillis .
But running on COM27 there is no such delay
Expected behavior
Expect it to work the same, and should receive the data from Serial as soon as the user sends it.
Arduino IDE version
Nightly 20220617
Operating system
Windows
Operating system version
Windows 10
Additional context
No response
Issue checklist