Can someone suggest me what changes can be done to make work on function 1
Post complete code! Most people think to know where the error must be but more than often it's in another location than they thought.
Before posting your code fix the identation. The IDE may help you with that with the "Auto Format" (Ctrl-T) tool.
From the ModBus stream output I would guess that you're sending the request CRC in the reply and you're not calculating the reply's CRC.