Using Arduino FSM libraries

Status
Not open for further replies.

gredpath

Well-known member
We are trying to use the Arduino FSM library from https://github.com/jonblack/arduino-fsm
It builds against the AVR architecture, and the adafruit M0 weatherboard, but it won't compile against Teensy.
Any thoughts?

It comes up with the following messages: -

Arduino: 1.8.4 (Mac OS X), TD: 1.39, Board: "Teensy 3.2 / 3.1, Serial, 96 MHz (overclock), Faster, US English"

/Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/gredpath/Library/Arduino15/packages -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/gredpath/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/gredpath/Documents/Arduino/libraries -fqbn=teensy:avr:teensy31:usb=serial,speed=96,opt=o2std,keys=en-us -ide-version=10804 -build-path /var/folders/l6/vzyfh_313w33y_mxc5gmwlxm0000gn/T/arduino_build_883422 -warnings=none -build-cache /var/folders/l6/vzyfh_313w33y_mxc5gmwlxm0000gn/T/arduino_cache_990763 -verbose /Users/gredpath/Documents/Arduino/libraries/arduino-fsm/examples/light_switch/light_switch.ino
/Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/gredpath/Library/Arduino15/packages -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/gredpath/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/gredpath/Documents/Arduino/libraries -fqbn=teensy:avr:teensy31:usb=serial,speed=96,opt=o2std,keys=en-us -ide-version=10804 -build-path /var/folders/l6/vzyfh_313w33y_mxc5gmwlxm0000gn/T/arduino_build_883422 -warnings=none -build-cache /var/folders/l6/vzyfh_313w33y_mxc5gmwlxm0000gn/T/arduino_cache_990763 -verbose /Users/gredpath/Documents/Arduino/libraries/arduino-fsm/examples/light_switch/light_switch.ino
Using board 'teensy31' from platform in folder: /Applications/Arduino.app/Contents/Java/hardware/teensy/avr
Using core 'teensy3' from platform in folder: /Applications/Arduino.app/Contents/Java/hardware/teensy/avr
Build options changed, rebuilding all
Detecting libraries used...
"/Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -felide-constructors -std=gnu++14 -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=139 -DARDUINO=10804 -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "/var/folders/l6/vzyfh_313w33y_mxc5gmwlxm0000gn/T/arduino_build_883422/sketch/light_switch.ino.cpp" -o "/dev/null"
"/Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -felide-constructors -std=gnu++14 -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=139 -DARDUINO=10804 -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "-I/Users/gredpath/Documents/Arduino/libraries/arduino-fsm" "/var/folders/l6/vzyfh_313w33y_mxc5gmwlxm0000gn/T/arduino_build_883422/sketch/light_switch.ino.cpp" -o "/dev/null"
"/Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -felide-constructors -std=gnu++14 -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=139 -DARDUINO=10804 -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "-I/Users/gredpath/Documents/Arduino/libraries/arduino-fsm" "/Users/gredpath/Documents/Arduino/libraries/arduino-fsm/Fsm.cpp" -o "/dev/null"
Generating function prototypes...
"/Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -felide-constructors -std=gnu++14 -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=139 -DARDUINO=10804 -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "-I/Users/gredpath/Documents/Arduino/libraries/arduino-fsm" "/var/folders/l6/vzyfh_313w33y_mxc5gmwlxm0000gn/T/arduino_build_883422/sketch/light_switch.ino.cpp" -o "/var/folders/l6/vzyfh_313w33y_mxc5gmwlxm0000gn/T/arduino_build_883422/preproc/ctags_target_for_gcc_minus_e.cpp"
"/Applications/Arduino.app/Contents/Java/tools-builder/ctags/5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "/var/folders/l6/vzyfh_313w33y_mxc5gmwlxm0000gn/T/arduino_build_883422/preproc/ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"/Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++" -c -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -fno-exceptions -felide-constructors -std=gnu++14 -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=139 -DARDUINO=10804 -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "-I/Users/gredpath/Documents/Arduino/libraries/arduino-fsm" "/var/folders/l6/vzyfh_313w33y_mxc5gmwlxm0000gn/T/arduino_build_883422/sketch/light_switch.ino.cpp" -o "/var/folders/l6/vzyfh_313w33y_mxc5gmwlxm0000gn/T/arduino_build_883422/sketch/light_switch.ino.cpp.o"
light_switch:6: error: 'on_light_on_enter' was not declared in this scope
State state_light_on(on_light_on_enter, NULL, &on_light_on_exit);
^
light_switch:6: error: 'on_light_on_exit' was not declared in this scope
State state_light_on(on_light_on_enter, NULL, &on_light_on_exit);
^
light_switch:7: error: 'on_light_off_enter' was not declared in this scope
State state_light_off(on_light_off_enter, NULL, &on_light_off_exit);
^
light_switch:7: error: 'on_light_off_exit' was not declared in this scope
State state_light_off(on_light_off_enter, NULL, &on_light_off_exit);
^
Using library arduino-fsm at version 2.2.0 in folder: /Users/gredpath/Documents/Arduino/libraries/arduino-fsm
'on_light_on_enter' was not declared in this scope
 
Apparently, you did not declare the callback functions on_light_on_enter(), on_light_on_exit(), and so on as required by your State declarations. According the tutorial, if callback functions are used as State() constructor parameters, these have to be defined, too. If you don't use callback functions, you can replace these by NULL.

Finally, this does not look a AVR / Teensy problem, but elementary C/C++ knowledge and a little "RTFM until the end..." ;)

But this is only a guess since you did not respect the forum rule and you did not post the code you are actually trying to compile...
 
in the example light_switch, it references functions before they are defined, try moving

Code:
State state_light_on(on_light_on_enter, NULL, &on_light_on_exit);
State state_light_off(on_light_off_enter, NULL, &on_light_off_exit);
Fsm fsm(&state_light_off);
to just in front of setup() function
 
Status
Not open for further replies.
Back
Top