A colleague helped fix it. It's not the prettiest solution, but it works perfectly. From setup, there is a try-catch statement. If it's caught, a boolean (portOpen) is set at false. After that, the program goes on towards draw() like normal. At the beginning of draw, it looks at that boolean (portOpen). As long as it is false, it calls on a new method which tries to open the Serial-communication. When the port is opened, the boolean is set as true and the draw() function goes back to reading data from the port as if nothing happened.
In the extra method, exceptions are still caught and the boolean remains false. There are no freezes or crashes.
I still haven't pinpointed which program sometimes hogs the COM-port, so suggestions are still welcome.
In the extra method, exceptions are still caught and the boolean remains false. There are no freezes or crashes.
I still haven't pinpointed which program sometimes hogs the COM-port, so suggestions are still welcome.