Hi.
I would like to tell you about a modbus library I have made and recently released, for Siemens S7-1200 PLC's. I made concept that called Station block which is mapping of registers for one specific modbus rtu device. Station blocks can be made very quickly and can be easily be reused and combined with other station blocks. The library is free under the MIT-license and can be downloaded at github (link bellow). Please check it out, I would like to get some feedback on my work.
https://github.com/olab84/rexhip/
An modbus rtu example:
#mb_master_ctrl(hardware_id := "Local~CB_1241_(RS485)",
baud := 19200, // bps
mb_query := #mb_query );
#mb_query(mb_addr := #mb_addr,
mode := #mb_query.c.read.input_reg,
data_addr := 13,
data_ptr := #resault_data_1);
#mb_query(mb_addr := #mb_addr,
mode := #mb_query.c.write.holding_reg,
data_addr := 55,
data_ptr := #resault_data_2);
// - The library will take care of execute each query, one by one.
// Add as many queries as need. (There no need of a state machine)
// - Queries belonging to one device can be placed inside one FB,
// this FB can later easily be reused.