I wrote a piece of code to set up MQTT communication very similar to https://infosys.beckhoff.com/english.php?content=../content/1033/tf6701_tc3_iot_communication_mqtt/54043198920281355.html&id= and I tested it using a virtual PLC. It works perfectly. Now I'm trying to run the same code on a Beckhoff PLC (the CX5010). On this PLC runs windows embedded CE 6.0.
The first problem that I encountered was that when I activated the configuration and restarted TwinCAT in run mode it was still in configuration mode. I uncommented my MQTT program in my main program and after that it did start in run mode after activating the configuration. When the MQTT program is commented I only have a counter in the main (to test if the PLC is running).
So the next thing I tried was restarting the PLC in run mode while the MQTT program was commented. When the PLC was restarted in run mode I uncommented the MQTT program in main and logged in with a download I got the error "'TcSysSrv' (10000): Error starting TCIOTDRIVERSW32.dll server. Win32 Error(0x0000007e).". The code of my MQTT program is shown below.
PROGRAM PrgMqtt
VAR
fbMqttClient : FB_IotMqttClient; // MQTT client
bSetParameter : BOOL := TRUE; // set parameters once at start up
bConnect : BOOL := TRUE; // if TRUE it will trigger MQTT client cyclically
END_VAR
// set parameters once when connecting to the mqtt broker
IF bSetParameter THEN
bSetParameter := FALSE;
fbMqttClient.sHostName := '172.16.1.51';
fbMqttClient.nHostPort := 1883;
fbMqttClient.sTopicPrefix := '';
fbMqttClient.ipMessageQueue := fbMessageQueue;
END_IF
// MQTT client must be triggered cyclically
fbMqttClient.Execute(bConnect);
The strangest thing is that the code actually runs after logging in (it does not connect to the MQTT broker, but it still runs). I'm very confused right now. How do I update the IoT drivers?
I solved the problem by updating Windows embedded and TwinCAT 3.
User contributions licensed under CC BY-SA 3.0