Trying to switch between android Bluetooth control and auto obstacle avoidance

I have created a bot that can be controlled over Bluetooth via motion. It is using the amarino library and is an event passed program. I can not get it to switch over to obstacle avoidance at all, every time I push p it just kicks up "Error: 112" i've tried sending 112 instead but can not get it to work. If I use the same setup but change from an input to to just a variable being changed to true, when the stop function is called, it switches fine. I can not for the life of me figure out why trying to send a command wont work but switching a variable when stop is called will work.

Help would be greatly appreciated. See attached code

switching: Dropbox - Switching.txt - Simplify your life
not switching: Dropbox - Not Switching.txt - Simplify your life