Changed error(...) to a weak function

Made error(...) a weak function so that it can be overridden in
production projects. Also fixed several serial_api.c files that required
stdlib.h, but were getting it from error.h.
Merge pull request #239 from neilt6/master

Changed error(...) to a weak function