Not sure how the old modbus routines worked, but if you end up having to do a significant amount of work, I have a chart that may help you out. I’ve been using it for all my modbus communication that uses the current library. I’m not going to post it on here, as I would like it to be tested on more equipment first.
Configuration of the chart is like this:
//Comm Handles - You can set multiple comm handles to talk through different serial ports / TCP ports
SetCommunicationHandleValue("tcp:127.0.0.1:502", chModbus);
potModbusCommHandles[0] = &chModbus;
ntModbusCommType[0] = 2; //Comm Type: 0=Serial RTU, 1=Serial ASCII, 2=TCP
fModbusErrorValue=-32768;
And then I specify the modbus address and register I want to store in my PAC Control variable in a configuration string table with the following format (Example below)
Modbus Configuration Fields:
1- Interval (seconds),
2- Port Index (pointer table to the comm handle)
3- Device Address
4- Function Type: 1=Coil Status, 2=Input, 3=Holding Reg, 4=Input Reg
5- Starting Register Number
6- Data Type:
–0 = 16bit unsigned
–1 = 16bit signed
–2 = Floating Pt.
–3 = Floating Pt.(Swapped)
–4 = 32bit signed
–5 = 32bit signed(Swapped)
7- Multiplier - (0 to ignore and not store)
8- Storage variable name - Float, Int32 variables and tables supported
9- Allow Write: 0=Read Only, 1=Read/Write
Continuation Line
This is when the registers are consecutive, you ommit the first 5 parameters
1- * (asterisk indicates the this register number is one higher (or more depending on the previous data type) than the previous so we can do a read multiple
2- Data Type
3- Multiplier
8- Storage variable
9- Allow Write
*, Data type, Multiplier, Store Variable
Example:
stModbusReadConfiguration[0] = "1,0,1,3,1,0,.01,ntData[0],1"; //int16 holding register 1
stModbusReadConfiguration[1] = "*,1,.1,ntData[1],1"; //2
stModbusReadConfiguration[2] = "*,1,1,ntData[2],1"; //3
stModbusReadConfiguration[3] = "*,1,10,ntData[3],1"; //4
stModbusReadConfiguration[4] = "*,1,100,ntData[4],1"; //5
stModbusReadConfiguration[5] = "*,3,1.0,ftData[0],1"; //float holding register (32bit) 6
stModbusReadConfiguration[6] = "*,3,0.5,ftData[1],1"; //8
stModbusReadConfiguration[7] = "*,5,1,nData,1"; //int32 holding register 10
stModbusReadConfiguration[8] = "1,0,1,1,7,0,1,ntData[8],1"; //Coil 7
stModbusReadConfiguration[9] = "*,0,1,ntData[9],1"; //Coil 8
stModbusReadConfiguration[10] = "1,0,1,2,1,0,1,ntData[5],0"; //Digital Input 1
stModbusReadConfiguration[11] = "1,0,1,4,1,3,1,ftData[2],0"; //Input Register 1
stModbusReadConfiguration[12] = ""; //Last one must be empty string
From there I can read write to the PAC Control variables and the chart does the rest.
If this will help you, send me a PM with your e-mail address and I’ll send it over.