I have firmware that compiles and runs just fine on three Cores. I just got my Photon and tried to compile and upload the identical code. First, I got two compile errors for the Photon what do not give compile errors when I compile the identical source code file for the Core. Offending lines are:
Spark.syncTime();
Wire.setSpeed(COCK_SPEED_100KHZ);
I commented out these two lines and the code compiles for both Photon and Core. I uploaded this code to both a Core and a Photon and it uploaded fine. It runs fine on the Core. On the Photon, it seems to run fine (at least by blinking LEDs) but my Javascript that reads calls Spark.function() does not seem to be executing properly: returns “errornull” (at least that’s what Javascript displays).
This all seems to indicate that there must be some #include that is needed for compiling Core firmware on a Photon. Please help me to understand what I need to do to port 100% solid working Core code over to Photon!
I am using the WebIDE. After downloading the new app to my smartphone and capturing my new Photon, I logged into my Particle development account and selected the Photon (it was there, along with my two earlier Cores). I successfully compiled, uploaded, and executed blink. I then selected SaratogaSIS08 firmware that was previously saved and re-compiled it for the selected device (the Photon). This is where I got the two compile errors listed above (plus a bunch of warnings that have always been there and were never a problem, but p.s. I thought that these extraneous warnings would now be surpressed). On the same web IDE, if I select one of my Cores and compile the identical file, it compiles OK.
As I mentioned previously, this code has been running fine on 3 Cores (2 mine and one owned by my co-developer) for many weeks now. After commenting out these two offending lines, the revised code compiles for both Core and Photon. The revised code uploads to Core OK and runs OK. The revised code uploads to Photon OK but does not run OK. Specifically, I can use the REST interface (via Javascript) and read out the Spark.variable() exposed variables OK. But when I run a function exposed by Spark.function() that causes an update to an exposed variable, my Javascipt returns “errornull” from the Photon but runs just fine on the Core. I also suspect that the I2C is not running properly on the Photon with the revised code (probably because of the commented out clock speed line).
Note that this program requires the Core/Photon to be in a circuit that uses the I2C bus (to write config data to an I2C eeprom) and has 2 digital inputs from 2 RF receivers that are on pins D3 and D4 (uses interrupts).
@mdma: thanks for the headsup about bug fix on Spark.syncTime(). However, there is more going on here. It is almost like the web IDE doesn’t #include the right core library files for Photon when the same code has previously been compiled for Core. Note, however, that I did recompile after selecting the Photon from my device list.
An update: I got my code working on the Photon by commenting out the lines:
Spark.syncTime();
Wire.setSpeed(CLOCK_SPEED_100KHZ);
I understand the Spark.syncTime() is a known bug and will be fixed. Wire.setSpeed(CLOCK_SPEED_100KHZ); may not be needed as it is (presumably) the default, but failure to compile this specified function is a bug and it should be fixed.
My other problem was that two Spark.variable() names were > 12 characters. This is not a problem when compiling for the Core because the name is simply truncated to 12 characters. For some reason, it is a problem when compiling for Photon, as the variables were not exposed to the cloud. I truncated them to the legal 12 chars in my firmware and I am pleased to report that the code is working on Core and on Photon. I don’t count this latter difference as a bug because I had not followed the rules, but it is a difference between how Core and Photon work and I am describing it here in case other people have this same issue.
Particle folks: please do fix the 2 compile issues noted above and kindly let us knoe when they are fixed.
@kennethlimcp: it seems that I need the GitHub password for the Spark account on GitHub to do this. Since i don’t have the passowrd, would you be so kind as to log these two issues for me?
Thanks.
@mdma: thanks. I’ll try this tomorrow and I’ll only report back if there is a problem. I appreciate the quick turnaround on the fix to these compile issues.
@mdma: I added the #include and it does, indeed, compile correctly for the Photon. However, the same file gives compile errors when compiling for Core. Since I have 2 Cores and 1 Photon, I need a single version of code that will compile for both. So there needs to be some sort of #ifdef to add or not add the #include based upon the target device type. Hopefully, this will be OK in the released version. I can wait for the new release (this is the default anyway and the I2C bus seems to work fine with the setSpeed line commented out) but I wanted to make sure that the fixes in new release will compile correctly for both Photon and Core.