Slow USB Serial Connect

It takes me something like 30 seconds from when my core boots until it is connectable via /dev/ttyACM0. Just after program start, the device pops up, but trying to get the output from there gives me:

$ cat /dev/ttyACM0
cat: /dev/ttyACM0: Device or resource busy

Is this usual, or is something derped up on my admittedly hackedy Linux Mint Laptop?

Hi @MattyG

The core will not appear as a USB device until your setup() function is run and Serial.begin(baud) executes, so some of that time is the core start-up and finding WiFi networks. Once you see the breathing cyan LED, it should be only a second or two at most.

What happens with your laptop when you plug in other USB devices? Do they take a long time too?

i have found after you start the serial you will need to do a

while (!Serial.available());

otherwise it will say port in use…

once your terminal opens you will have to push enter to get your program to continue

I also do something along the lines of

Serial.begin(9600);
sleep(5000);

to give a little boot-up delay that won’t hang up the rest of the code if I never use a console and press a key.

The best is :smile:

while (!Serial.available()) SPARK_WLAN_Loop();

That way you don’t lose cloud connection and OTA. :smile:

2 Likes

Good call… i removed that when i turned the Wifi and Cloud off so it didnt create bugs (stupid slow internet here wont let it connect reliably)

I’ve also got a timeout on it now, and 2 modes… push a button and it changes between serial on and off. that way i don’t have to reset the core to get a terminal open the second time. Normal mode the core scans fingerprints continuously and the Programming mode lets me add users and fingerprints

1 Like

Interesting notes all around. The boot up time of ~30 seconds was measured from the start of the aqua-“breathing” state. I am assuming setup() gets run moments after that, in which I do have the serial.begin() call.

Compared to the reports of others this seems long. Other usb devices (BBB/Arduino) come up quickly. I recall now adding a udev rule for the BBB which might be fuddling things, but I will check that in a bit. I only use the serial as debugging terminal really having to send something initially to get things primed seems a bit annoying. I will try it to see that that aids in the boot-time.

That while loop seems to be a good trick, thanks.