Hello;
The following link will take you to the Siemens support webpage that allows you to download a modbus driver (master or slave) for the serial CPs of the S7-300/400; you will also find programming manuals for the implementation of Modbus function calls; you can basically copy the functions< blocks in your program and modify them to suit your needs.
For this to work, you will need to buy a Modbus driver licence from Sieemns (it actually consists of a hardware dongle you install in thje CP341, so it can't be copied); you will also need to install the P-to-P CP parameters software (downloadable fron<m the same site, also comes with the Modbus dongle).
Hope this helps,
Daniel Chartier