Found bug.  The Hitachi code length is 692bits.
However the bits of length is uint8_t = 256 + 256 + 180.
So we see 180bits before because of overflow.

Change the type of length to int and the type of buffer to char.
The missed code problem is gone.

I also found some code meanings.