-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Hi stefan,
For a proof of concept project I wanted to use your library to get PLC data to a MQTT broker on a server I own. When I tested it by making a counter count up and sending it as a string to my broker everything worked fine. But when I increased the string size the pointer to that string stopped working and is giving me a "Dereference of invalid pointer" when I try to run it. I tried to increase the string sizes in the project and increased the dynamic memory allocation to 20000 but nothing changed. The payload is a JSON string that looks like:
{"Context":1,"Description":"Test message","ReportText":"Maintenance","Status":2,"Priority":"M"} With this being the shortest one. Could you please explain me how to solve this?
Code is as follows:
`PROGRAM MQTT_Test
VAR
init : BOOL;
MQTT_IN_OUT : MQTT.MQTT_IN_OUT;
Publish : MQTT.MqttPublish;
Send : BOOL;
tnDelay: TON;
Topic : STRING(255) := 'plc/data' ;
PayloadString : STRING(1024);
END_VAR'
`PayloadString := Create_POST.Create_PUB;
IF NOT init THEN
Publish.SetMqttInOut(MQTT_IN_OUT);
init := TRUE;
END_IF
tnDelay(IN:= TRUE, PT:= T#5S , Q=> Send, ET=> );
MQTT_IN_OUT.clientFB(
MQTT_IN_OUT:= MQTT_IN_OUT,
ENABLE:= TRUE,
URL:= 'Admin:[email protected]:1883',
TLS:= FALSE
);
Publish(
Topic:= ADR(Topic),
PayloadString:= ADR(PayloadString),
PublishAsString:= TRUE,
Payload:= ,
PayloadLength:= ,
QoSIn:= 0,
MRetain:= FALSE,
send:= Send,
done=> ,
sendActive=> ,
SendTimeout=> ,
CountSend=> );
IF Publish.done THEN
Send:= FALSE;
tnDelay(IN:= FALSE);
END_IF`
Thanks in advance!