What is problem when serial don't work?
Here is line:

Call sendserial(getselectedtool())

It seems to get stuck... Have anyone solution?