It looks to me like your COM has not been initialized properly and like Vinay mentioned try exporting the value of hr or any other variable just as a test first. There are two things I feel might have gone wrong here.
1) Make sure all your COM port parameters are set properly, I can't see where you are initializing them. (For eg: Baud rate, data bits, parity, stop bits, Flow control etc)
2) Check all your connections obviously (which I'm sure you have done): which COM port, serial connection etc.
I'm not sure if this would help or not, but I usually use:
at the beginning of each function. (standard DLL accessing procedure for me).