gergelytakacs/AutomationShield

FloatShield: hallPeriodCounter(); Interrupt on Timer2 conflict

gergelytakacs opened this issue · 1 comments

I have tried to pull in FloatShield to master, but forgot to check branch CI. After I completed the pull, I saw that master fails to build.

Issue:
The hallPeriodCounter(); interrupt definition conflicts with other modules, such as the TugShield, BobShield etc. and the Sampling examples.

The issue is, that all the cpp files are built in the library, even if the given Shield is not in used. E.g. Float can be in conflict with BOB, even if only one is used. The problem is the multiple definition of the interrupt vector.

Not only the UNO counters have conflicted but at least one of the others, I think it was TC4 for the Due/Zero.

Possible workaround
Float will only have a "h" file, but not CPP, just like with the Servo boards. That way, the cpp is not automatically turned into an object and there are no conflicts. If you have a better idea, let me know.

Here is a section of the Travis CI check, or click on the build link:

The command "arduino --verify --board arduino:avr:uno $PWD/examples/TugShield/TugShield_PID/TugShield_PID.ino" exited with 1.
3.37s$ arduino --verify --board arduino:avr:uno $PWD/examples/TugShield/TugShield_Identification/TugShield_Identification.ino
Picked up JAVA_TOOL_OPTIONS: 
Loading configuration...
Initializing packages...
Preparing boards...
Verifying...
libraries/AutomationShield/FloatShield.cpp.o (symbol from plugin): In function `hallPeriodCounter()':
(.text+0x0): multiple definition of `__vector_7'
sketch/TugShield_Identification.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
exit status 1
The command "arduino --verify --board arduino:avr:uno $PWD/examples/TugShield/TugShield_Identification/TugShield_Identification.ino" exited with 1.
3.33s$ arduino --verify --board arduino:avr:uno $PWD/examples/TugShield/TugShield_SelfTest/TugShield_SelfTest.ino
Picked up JAVA_TOOL_OPTIONS: 
Loading configuration...
Initializing packages...
Preparing boards...
Verifying...
Sketch uses 8080 bytes (25%) of program storage space. Maximum is 32256 bytes.
Global variables use 741 bytes (36%) of dynamic memory, leaving 1307 bytes for local variables. Maximum is 2048 bytes.

Temporary patch: commented out the incriminating lines defining (multiply) the interrupt. Of course, Float will not be working (at least the hall sensor module) in its current form.

image
and
image
image

@PeterChmurciak @erik1392

I have moved the FloatShield.cpp into FloatShield.h. Not very pretty, but works. This is essentially the same problem (as described above) as with the Timer 1 multiple definitions in all the other shields that have Servos. They use the same workaround. If you can think up a better solution, by all means have a go at it.

I have wasted a lot of time last year with BOB solving this, but couldn't really come up with a nicer solution given our problems and constraints.