Program to interface barcode scanner with arduino uno

I am using the Sparkfun USB host shield with Arduino Uno. And using the attached code for Keyboard interface (slightly modified the sample coding.) When I interface a USB type Keyboard with the USB HID host shield, it is working in a nice way.

I am trying to use the same code to interface Symbol Barcode Scanner instead of Keyboard, I am facing below issue. Sometimes, I got the expected barcode scanned value in Arduino Serial Monitor. But most of the time, my COM port in PC disappears and not getting any result in serial monitor. Barcode scanner is properly powered up every time.

Is there any issue in my code? Need help to resolve this.

Thanks in advance.

usbTest_c.zip (1.69 KB)