Added synchronization logic into the getNextFrame method to ensure reading until sync byte is one byte at a time