Hello,
I have a sensor attached to the data station plus, which has several modbus registers i read from.
Forexample register 40038 is a 32 bit floating point measuring value and the next register 40040 has the parameter ID, parameter id 20 = RPM.
I am sending those values to a RAM6000 using Modbus TCP/IP and setting up my webplatform as a MQTT broker and sending my measurement values to the webplatform I am using.
The problem with this is that the measurement values I am sending has no context, so what I am trying to do is to get both the measurement value and the parameter ID into the same string so I can identify what parameter the measuring value has.
I have managed to make strings from arrays using the raw serial port using this program:
// declare local variable
int port = 2;
int i;
int j;
// clear the port's buffer
//ClearRx();
// print stop out of Port 2
PortPrint(port, "do sample\r\n"); //NB!! Return carriage and linefeed
int in = PortRead(2, 255);
// loop while there is data in the buffer, populating the array
while(in != -1) {
Zpulse.Array[i++] = in;
in = PortRead(2, 255);
Rs232.String();
// if something was received, build a string with byte 0-25
if(i > 0) {
Zpulse.Response = "";
for(j =0; j<=25;j ++){
Zpulse.Response += Zpulse.Array[j];
}
}
}
But I am strugling to get two Modbus registers into the same string, is this doable when the modbus registers have two different data types?
I have a sensor attached to the data station plus, which has several modbus registers i read from.
Forexample register 40038 is a 32 bit floating point measuring value and the next register 40040 has the parameter ID, parameter id 20 = RPM.
I am sending those values to a RAM6000 using Modbus TCP/IP and setting up my webplatform as a MQTT broker and sending my measurement values to the webplatform I am using.
The problem with this is that the measurement values I am sending has no context, so what I am trying to do is to get both the measurement value and the parameter ID into the same string so I can identify what parameter the measuring value has.
I have managed to make strings from arrays using the raw serial port using this program:
// declare local variable
int port = 2;
int i;
int j;
// clear the port's buffer
//ClearRx();
// print stop out of Port 2
PortPrint(port, "do sample\r\n"); //NB!! Return carriage and linefeed
int in = PortRead(2, 255);
// loop while there is data in the buffer, populating the array
while(in != -1) {
Zpulse.Array[i++] = in;
in = PortRead(2, 255);
Rs232.String();
// if something was received, build a string with byte 0-25
if(i > 0) {
Zpulse.Response = "";
for(j =0; j<=25;j ++){
Zpulse.Response += Zpulse.Array[j];
}
}
}
But I am strugling to get two Modbus registers into the same string, is this doable when the modbus registers have two different data types?