It appears that the system thread management functions for avoiding cross-talk on the Serial usb connection do not work.
I am using system threading and want to make sure that the Serial port isn’t being used by the application thread when I try to flash my Electron via USB.
The Particle Guide on this subject says that you need to use either the TRY LOCK(Serial) or WITH_LOCK(Serial) wrapper methods described in the Synchronizing Access to Shared Resources section:
I believe those are tagged for 0.5.0 which is coming to the web IDE build very soon but has not been announced yet. I just checked and 0.4.9 is the latest available this writing but I know 0.5.0 is coming shortly.
If you can compile locally with gcc from the 0.5.0 release candidate you can use these.
These locking features are already available in 0.4.9 (for the Photon), but @macdonaldtomw is building for the Electron which is still running 0.4.8 and as such does not yet support SYSTEM_THREAD(ENABLED) on the Electron either.
It’s a pitty that the docs fail to mention this fact. But this should be temporary since 0.5.0 is just round the corner.
So for bleading edge dev, local building might be the way to go.
I’m building using Cloud compilation, Electron running 0.4.8
I can confirm that multithreading is working fine because I tried it with the blinky example sketch and the on-board LED started blinking immediately before the GSM modem even started trying to connect.
See screenshot (notice firmware version in sidebar, and compilation success message at bottom of screen):
0.4.8 does in fact include the full multithreading code on the Electron, but the stack size was too small, leading to random code crashes after connecting to the cloud via UDP, which is why we were saying that multithreading wasn’t supported in 0.4.8 on the Electron. 0.5.0 fixes this.