How to solve problems with missing IoT drivers on PLC - iot

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.

Related

A dual Windows Service / GUI applicaton with Delphi

Is a dual Windows Service / GUI applicaton possible with Delphi?
I mean, when its exeutable file is started normally, it appears as a normal GUI application that is used for something other than its Windows Service function. For example, a configurator for Windows Service.
Or, for example, in GUI mode it could be a database client with TDBGrid etc and in Sevice mode it starts its own HTTP server and acts as a web application. Both are sharing the same database access code.
I looked into TServiceApplication.Run and didn't understand how can I distinguish between normal start and start as a service.
Of course, I could put some command line switch branching around this construct:
if GuiModeSwitch then begin
Forms.Application.Initialize;
Forms.Application.CreateForm(TConfigForm, ConfigForm);
Forms.Application.Run;
end
else begin
SvcMgr.Application.Initialize;
SvcMgr.Application.CreateForm(TMyService, MyService);
SvcMgr.Application.Run;
end;
But I would like that the GUI mode is started when no command line parameters are specified.

Generate PDF using QuickReport from a Windows Service in Delphi

I'm writing a windows service using Delphi XE3. The service is going to read from a database, generate a pdf using quickreport 5.05.1.
I plan to generate the pdf using TQRPDFDocumentFilter.
Everything works fine in a normal VCL application, but when I implement it in a windows service the service hangs (without any exceptions) when I do a QuickRep.Prepare.
I have read that it is possible to use QuickReport in a windows service, but I do not know how. Any suggestions?
Where is the code:
procedure foo
var
pdfFilter: TQRPDFDocumentFilter;
begin
with TForm2.Create(Self) do
begin
ClientDataSet1.Open;
QuickRep1.Prepare;
pdfFilter := TQRPDFDocumentFilter.Create(GetApplicationFolder() + 'test.pdf');
try
QuickRep1.QRPrinter.ExportToFilter(pdfFilter);
finally
pdfFilter.Free;
ClientDataSet1.Close;
end;
end;
end;
Edit:
I have also tried turning off "show progress" on the QuickReport as suggested in another thread.
Writing some code to catch an exception reveals that it indeed throws one. The message is "There is no default printer currently selected".
So this leads me to believe that the local system user that the service is running under does not have any printers installed and that this is the problem.
I have resolved a similar problem (printing to a shared network printer from a Java server running as a Windows service) with these steps:
log on as the user who will run the service
install the printer
IIRC with Delphi applications, the printer name is not case sensitive (with Java it is).

Checking internet connection in delphi

How, i've made a program that uploads files on ftp server, the thing is that whenever i don't have access to the internet, it appears me an error, which stops running the program and says that i am not connected to the internet.
How do i make the program appear that message in a showmessage box, so that it doesn't stop running the program?
For example:
If internetconnection then
begin
end else showmessage ('You are not connected to the internet')
Please try code from this link
Ping
Also you can try to use free Internet Component Suite components that allows to implement test connection to your ftp server.
EDIT:
Since it was found that the author uses IdFTP (Indy) component for upload files on ftp server and my first answer was not good i will take courage to write as i think correct code for checking connection to the ftp server:
with IdFTP1 do begin
Host := ..;
Port := ..;
Username := ..;
Password := ..;
if Connected then Disconnect;
try
Connect;
ShowMessage('FTP IS Connected')
except
ShowMessage('FTP IS NOT Connected');
end;
end;

Connection Timed Out + SSL Connection + TCPIP + Indy10.5.5

I am developed one application for sending files client to server using TCP/IP Components using SSL.
Error is Connection Timed Out is occurred when Sending Large Files at Server Side
Server Side (SSL)
idTCPServer1.IOHandler := IdServerIOHandlerSSLOpenSSL1;
OnExecute
Acontext.Connection.IOHandler.LargeStream := True;
Acontext.Connection.IOHandler.ReadStream(filestream,Filesize); // Error is occurred here.
End;
Client Side (SSL)
idTCPClient1.IOHandler := IdSSLIOHandlerSocketOpenSSL1;
idTCPClient1.IOHandler.LargeStream := True;
idTCPClient1.IOHandler.WriteStream(fms,-1,True);
Connection is established between Client & Server. When send the files after some time Connection Timed out is error is shown at server & at client application going to Not Responding .
Here another scenario is when i connect the Client & Server as Normal using IdIOHandlerStack1 (at Client Side) and server side not assign any Handler. Files transfered successfully with out any problem.
I am using Delphi2010 & Indy10.5.5, DLL Version is 0.9.8.18
anyone guide to me
There is no WriteStream() method, there is a TStream overload of the Write() method instead.
You are telling Write() to send the stream size as a 64-bit integer, but you are not telling ReadStream() to read the stream size, so presumably you have read the full 64-bit file size beforehand using ReadInt64(), correct?
Also, 10.5.5 is an outdated version of Indy. The current version is 10.5.9. Try upgrading to make sure you have all of the latest bug fixes and such, and then report back if you are still having problems.

DataSnap XE2 , Disconnecting with second connection in the same client

Hello : This is an important issue about Datasnap XE2 Tcp transport
I have an old problem , I asked for it before here, but no reply
DataSnap XE2 , Disconnecting with second connection in the same client :
Simple Datasnap server , simple client , ( just call reverse method ) , after few seconds the server destroy one or all the servermethods class , the datasnapserver is tcp protocol , lifecycle=Session , statefull server.
I test the same binary exe on another machines , and another OS ,and I Notice these :
1- The same problem occured when running the server on a computer which linked to router some with WiFi (with / without dhcp ) all OS ( server2003, Win7 ,Winxp ) give the same problem
2- When running the same server on Virtual Machines (all OS ) no problem at all , I use the Oracle Virtual Box , WHY !
3- In Server implemntation I Change the TCP Transport to http Transport , then i have no problem at all !.
4- I test and try every thing possible ( Networking configuration , Reformating , Fresh OS -- all windows versions -- ) the problem on tcp server transport still
5- It occures after (20 seconds -2 minutes ) after calling the client method some times in both connections .
6- I made and test new tcp server (not datasnap) and worked fine , but DataSnapXE2 TCP server made that problem
Is there some thing to do , I Just need to know why , I need expectations to test , I try almost every thing possible
I use C++Builder XE2 , no updates , all updates available have nothing about this problem
I also rebuild in Delphi XE2 , the smae problem
is there somebody know why , good advise , please reply
Note : DataSnap 2010 , same code , works fine !!
Thank you for your reply in advanced
There is something really wrong with the clientdataset in XE2 which all the follow problems:
Socket Server (scktsrvr) terminated due to too many data coming in from .data or as olevariant.
Catastrophic Failure of no reason in XE2. Same code works in D2010 simply will not work
in XE2
You will not be able to move your existing DATASNAP from D2010 or XE to XE2. Even if you
have a complete rewrite from scratch you will get problems.
New Datasnap or Old Datasnap better think twice before moving or wait until bug in XE2 will be settled.

Resources