gpb01 / SerialCmd

A Wiring/Arduino library to tokenize and parse commands received over a phisical/software serial port or buffer.
GNU General Public License v3.0
9 stars 3 forks source link

USB reset loop on Teensy 4.1 #3

Closed pearsomark closed 11 months ago

pearsomark commented 11 months ago

Hi, Using Arduino ide 2.2.1 and v1.1.4 of the library, the usb device is reinitialized about every 5 seconds on a Teensy 4.1, there are no issues with a Teensy 3.6.

The problem is fixed by changing strncpy back to strlcpy in SerialCmd::SerialCmd ( Stream &mySerial, char TermCh, char * SepCh ).

Simple test program

#include "SerialCmd.h"

SerialCmd mySerCmd ( Serial );

void setup() {
  Serial.begin(115200);
}

void loop() {
}

This is the repeated message in the ide console

023-10-09T10:28:53.722Z daemon INFO time="2023-10-09T21:28:53+11:00" level=info msg="from discovery builtin:serial-discovery received message type: remove, port: /dev/ttyACM0"
2023-10-09T10:28:53.722Z discovery-log INFO {"eventType":"remove","port":{"matchingBoardsList":[],"port":{"address":"/dev/ttyACM0","label":"","protocol":"serial","protocolLabel":"","propertiesMap":[],"hardwareId":""}},"error":""}
2023-10-09T10:28:53.729Z daemon INFO time="2023-10-09T21:28:53+11:00" level=info msg="from discovery teensy:teensy-discovery received message type: remove, port: usb1/1-4"
2023-10-09T10:28:53.730Z discovery-log INFO {"eventType":"remove","port":{"matchingBoardsList":[],"port":{"address":"usb1/1-4","label":"","protocol":"teensy","protocolLabel":"","propertiesMap":[],"hardwareId":""}},"error":""}
2023-10-09T10:28:54.309Z daemon INFO time="2023-10-09T21:28:54+11:00" level=info msg="from discovery teensy:teensy-discovery received message type: add, port: usb1/1-4"
2023-10-09T10:28:54.310Z discovery-log INFO {"eventType":"add","port":{"matchingBoardsList":[{"name":"Teensy 4.1","fqbn":"teensy:avr:teensy41","isHidden":false}],"port":{"address":"usb1/1-4","label":"/dev/bus/usb/001/060 Serial","protocol":"teensy","protocolLabel":"Teensy Ports","propertiesMap":[["modelID","0x25"],["name","Teensy 4.1"]],"hardwareId":""}},"error":""}
2023-10-09T10:28:54.312Z daemon INFO time="2023-10-09T21:28:54+11:00" level=info msg="from discovery builtin:serial-discovery received message type: add, port: /dev/ttyACM0"
2023-10-09T10:28:54.313Z discovery-log INFO {"eventType":"add","port":{"matchingBoardsList":[],"port":{"address":"/dev/ttyACM0","label":"/dev/ttyACM0","protocol":"serial","protocolLabel":"Serial Port (USB)","propertiesMap":[["pid","0x0483"],["serialNumber","11587060"],["vid","0x16c0"]],"hardwareId":"11587060"}},"error":""}
2023-10-09T10:28:54.314Z discovery-log INFO {"eventType":"add","port":{"matchingBoardsList":[{"name":"Teensy 4.1","fqbn":"teensy:avr:teensy41","isHidden":false}],"port":{"address":"usb1/1-4","label":"/dev/bus/usb/001/060 Serial","protocol":"teensy","protocolLabel":"Teensy Ports","propertiesMap":[["modelID","0x25"],["name","Teensy 4.1"]],"hardwareId":""}},"error":""}
2023-10-09T10:28:54.315Z daemon INFO time="2023-10-09T21:28:54+11:00" level=info msg="from discovery teensy:teensy-discovery received message type: add, port: usb1/1-4"
time="2023-10-09T21:28:54+11:00" level=info msg="from discovery teensy:teensy-discovery received message type: add, port: usb1/1-4"
2023-10-09T10:28:54.315Z discovery-log INFO {"eventType":"add","port":{"matchingBoardsList":[{"name":"Teensy 4.1","fqbn":"teensy:avr:teensy41","isHidden":false}],"port":{"address":"usb1/1-4","label":"/dev/bus/usb/001/060 Serial","protocol":"teensy","protocolLabel":"Teensy Ports","propertiesMap":[["modelID","0x25"],["name","Teensy 4.1"]],"hardwareId":""}},"error":""}
2023-10-09T10:28:54.316Z discovery-log INFO {"eventType":"add","port":{"matchingBoardsList":[{"name":"Teensy 4.1","fqbn":"teensy:avr:teensy41","isHidden":false}],"port":{"address":"usb1/1-4","label":"/dev/bus/usb/001/060 Serial","protocol":"teensy","protocolLabel":"Teensy Ports","propertiesMap":[["modelID","0x25"],["name","Teensy 4.1"]],"hardwareId":""}},"error":""}
2023-10-09T10:28:54.316Z daemon INFO time="2023-10-09T21:28:54+11:00" level=info msg="from discovery teensy:teensy-discovery received message type: add, port: usb1/1-4"
2023-10-09T10:28:54.325Z daemon INFO time="2023-10-09T21:28:54+11:00" level=info msg="from discovery teensy:teensy-discovery received message type: add, port: usb1/1-4"
2023-10-09T10:28:54.325Z discovery-log INFO {"eventType":"add","port":{"matchingBoardsList":[{"name":"Teensy 4.1","fqbn":"teensy:avr:teensy41","isHidden":false}],"port":{"address":"usb1/1-4","label":"/dev/ttyACM0 Serial","protocol":"teensy","protocolLabel":"Teensy Ports","propertiesMap":[["modelID","0x25"],["name","Teensy 4.1"]],"hardwareId":""}},"error":""}
2023-10-09T10:28:54.426Z root WARN Detected a new port that has been already discovered. The old value will be overridden. Old value: {"port":{"address":"usb1/1-4","addressLabel":"/dev/bus/usb/001/060 Serial","protocol":"teensy","protocolLabel":"Teensy Ports","properties":{"modelID":"0x25","name":"Teensy 4.1"}},"boards":[{"fqbn":"teensy:avr:teensy41","name":"Teensy 4.1"}]}, new value: {"boards":[{"fqbn":"teensy:avr:teensy41","name":"Teensy 4.1"}],"port":{"address":"usb1/1-4","addressLabel":"/dev/bus/usb/001/060 Serial","protocol":"teensy","protocolLabel":"Teensy Ports","properties":{"modelID":"0x25","name":"Teensy 4.1"}}}
2023-10-09T10:28:54.427Z root WARN Detected a new port that has been already discovered. The old value will be overridden. Old value: {"port":{"address":"usb1/1-4","addressLabel":"/dev/bus/usb/001/060 Serial","protocol":"teensy","protocolLabel":"Teensy Ports","properties":{"modelID":"0x25","name":"Teensy 4.1"}},"boards":[{"fqbn":"teensy:avr:teensy41","name":"Teensy 4.1"}]}, new value: {"boards":[{"fqbn":"teensy:avr:teensy41","name":"Teensy 4.1"}],"port":{"address":"usb1/1-4","addressLabel":"/dev/bus/usb/001/060 Serial","protocol":"teensy","protocolLabel":"Teensy Ports","properties":{"modelID":"0x25","name":"Teensy 4.1"}}}
2023-10-09T10:28:54.427Z root WARN Detected a new port that has been already discovered. The old value will be overridden. Old value: {"port":{"address":"usb1/1-4","addressLabel":"/dev/bus/usb/001/060 Serial","protocol":"teensy","protocolLabel":"Teensy Ports","properties":{"modelID":"0x25","name":"Teensy 4.1"}},"boards":[{"fqbn":"teensy:avr:teensy41","name":"Teensy 4.1"}]}, new value: {"boards":[{"fqbn":"teensy:avr:teensy41","name":"Teensy 4.1"}],"port":{"address":"usb1/1-4","addressLabel":"/dev/bus/usb/001/060 Serial","protocol":"teensy","protocolLabel":"Teensy Ports","properties":{"modelID":"0x25","name":"Teensy 4.1"}}}
2023-10-09T10:28:54.427Z root WARN Detected a new port that has been already discovered. The old value will be overridden. Old value: {"port":{"address":"usb1/1-4","addressLabel":"/dev/bus/usb/001/060 Serial","protocol":"teensy","protocolLabel":"Teensy Ports","properties":{"modelID":"0x25","name":"Teensy 4.1"}},"boards":[{"fqbn":"teensy:avr:teensy41","name":"Teensy 4.1"}]}, new value: {"boards":[{"fqbn":"teensy:avr:teensy41","name":"Teensy 4.1"}],"port":{"address":"usb1/1-4","addressLabel":"/dev/ttyACM0 Serial","protocol":"teensy","protocolLabel":"Teensy Ports","properties":{"modelID":"0x25","name":"Teensy 4.1"}}}
2023-10-09T10:28:59.046Z daemon INFO time="2023-10-09T21:28:59+11:00" level=info msg="from discovery builtin:serial-discovery received message type: remove, port: /dev/ttyACM0"
2023-10-09T10:28:59.048Z discovery-log INFO {"eventType":"remove","port":{"matchingBoardsList":[],"port":{"address":"/dev/ttyACM0","label":"","protocol":"serial","protocolLabel":"","propertiesMap":[],"hardwareId":""}},"error":""}
2023-10-09T10:28:59.060Z daemon INFO time="2023-10-09T21:28:59+11:00" level=info msg="from discovery teensy:teensy-discovery received message type: remove, port: usb1/1-4"
gpb01 commented 11 months ago

Thanks for the report, I am currently out of the office, but as soon as I can I will look for a solution.

Guglielmo

gpb01 commented 11 months ago

Back in office ... .cpp corrected with a small fix to ensure that strlcpy() is not used only if ARDUINO_ARCH_RENESAS is declared.

Please verify that it works correctly with Teensy 4.1, thanks. ;-)

Guglielmo

pearsomark commented 11 months ago

Thanks, the mod fixes the issue with the Teensy 4.1

Mark