You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old November 28th, 2008, 05:51 AM   #1
Pete:-)
Member
Belgium

Pete:-) is offline
 
Join Date: Nov 2008
Location: SML
Posts: 4
Beckhoff twincat SMTP supplement

Hi,

This is my first post on this forum and I would like to say that it very neat to see people helping each other on the plc related things.

For the moment I have a problem with Beckhoff SMTP supplement that does not want to work.

1) Program is running locally on a pc with twincat installed and running.
2) The IO device I am using to do local test is the virtual ethernet device.
3) The program itself is made in Twincat plc control.
4) Now I have a program that I have been running locally more then once. All this seems to work.

Now comes the problem. The program compiles without any error. So library,.....are all OK.
I have added the function block FB_SMTPV2 for sending emails from the plc.

"Here you have the complete code = copy from infosys"
I have replaced all the private stuff with XXXX.
When I run this program I get the error coming from the function block 1798 which is an ADS Error something to do with parameter values.

What could be the problem? Again all this is working locally on 1 pc and there is nothing connected to the pc itself.

PROGRAM EMAIL
VAR
fb_smtp1 :FB_SmtpV2 ;
bSend : BOOL;
bBusy : BOOL;
bError : BOOL;
nErrID : UDINT;
Zeit: TON;
bIn: BOOL;
msg: STRING[254];
bytemsg: ARRAY [0..511999] OF BYTE;
cbWrite: UDINT;
i: INT;
init: BOOL := FALSE;
sUsername: STRING;
sPassword: STRING;
END_VAR

Zeit(
IN:= bIn,
PT:= t#10S,
Q=> bSend,
ET=> );
IF NOT init THEN
cbWrite := MEMCPY(ADR(bytemsg), ADR(msg), LEN(msg));
i:=0;
FOR i := 0 TO 254 DO
msg :=CONCAT(msg, 'X');
END_FOR
FOR i := 0 TO 1960 DO
cbWrite := cbWrite + MEMCPY(ADR(bytemsg) + cbWrite, ADR(msg), LEN(msg)-1);
END_FOR
init := TRUE;
END_IF
fb_smtp1(
sNetId:= '192.168.2.112.1.1',
sSmtpServer:= 'Here I used the same SMTP outgoing server as configured in my outlook',
sUsername := 'XXXXXX',
sPassword := 'XXXXXX',
nAuth:=2,
sFrom:= 'From me',
sTo:= 'X@X.X ,
sCc:= '' ,
sBcc:= '' ,
sSubject:= 'TcSmtp Service Test',
pMessage:= ADR(bytemsg) ,
cbMessage:= cbWrite,
bExecute:= bSend,
tTimeout:= t#20s,
bBusy=> bBusy,
bError=> bError,
nErrId=> nErrID
);
IF bBusy = TRUE THEN
bIn:= FALSE;
ELSIF bBusy = FALSE THEN
bIn:= TRUE;
END_IF
  Reply With Quote
Old November 30th, 2008, 07:52 AM   #2
Archie
Member
United States

Archie is offline
 
Join Date: May 2002
Location: Orangeburg, SC
Posts: 1,772
I have never used the SMTP server, but I will take a stab at this. According to the documentation there are two things that must occur:

1) The TwinCAT ADS SMTP service must be running on the remote ADS device (sounds like this is your local PC), so that the byte stream can be received and processed into an e-mail. Is this service running on your PC?

2) Note that password checking must be disabled on the SMTP server, since the TwinCAT ADS SMTP service does not register on the server via password checking.

Also, if the SMTP server is also running on the same PC as TwinCAT, I would set sNetId='' just to eliminate any possible AZMS Net ID typos.
  Reply With Quote
Old November 30th, 2008, 02:51 PM   #3
Pete:-)
Member
Belgium

Pete:-) is offline
 
Join Date: Nov 2008
Location: SML
Posts: 4
1) The TwinCAT ADS SMTP service must be running on the remote ADS device (sounds like this is your local PC), so that the byte stream can be received and processed into an e-mail. Is this service running on your PC?

I suppose it is running. How can I check if it running? The only thing I did is installing the Twincat supplement for SMS/SMTP for xp.
I red the following "If you use the Win32 version a logfile called TcMailSrv.log will be created in the TwinCAT directory." When you open it contains stuff like this
"28/11/2008 9:01:08 - Service started
28/11/2008 9:01:38 - Service started
28/11/2008 10:03:39 - Service started
28/11/2008 10:08:43 - Service started
28/11/2008 10:14:12 - Service started
28/11/2008 11:01:59 - Service started
28/11/2008 11:08:24 - Service started
28/11/2008 11:09:41 - Service started
28/11/2008 11:28:16 - Service started
28/11/2008 11:34:33 - Service started
28/11/2008 14:57:44 - Service started
28/11/2008 15:02:06 - Service started
28/11/2008 15:28:46 - Service started
28/11/2008 15:30:21 - Service started
28/11/2008 15:30:23 - Service started
28/11/2008 15:30:36 - Service started
28/11/2008 15:30:40 - Service started
28/11/2008 17:00:00 - Service started
28/11/2008 17:04:47 - Service started
28/11/2008 17:16:49 - Service started
28/11/2008 17:16:53 - Service started
28/11/2008 17:19:28 - Service started
28/11/2008 17:22:20 - Service started
28/11/2008 17:22:23 - Service started
28/11/2008 17:26:31 - Service started
28/11/2008 17:26:48 - Service started
29/11/2008 7:41:31 - Service started
29/11/2008 10:18:12 - Service started
29/11/2008 13:52:13 - Service stopped
29/11/2008 13:53:58 - Service started
29/11/2008 18:26:30 - Service stopped
29/11/2008 18:28:11 - Service started
29/11/2008 22:02:27 - Service started
30/11/2008 0:09:32 - Service stopped
30/11/2008 20:56:41 - Service started
30/11/2008 21:29:27 - Service stopped
30/11/2008 21:29:30 - Service started"


I suppose this is the proof that the service is running.


2) Note that password checking must be disabled on the SMTP server, since the TwinCAT ADS SMTP service does not register on the server via password checking.

I am using the SMTP server of my ISP. This works with a username and a password. I have no other possibility. I am using the "FB_SmtpV2" block. This one accepts username and password if I understood it well.
This is what they write about the block "The PLC block FB_SmtpV2 allows to send mails from a smtp server that requires authentication."


Also, if the SMTP server is also running on the same PC as TwinCAT, I would set sNetId='' just to eliminate any possible AZMS Net ID typos.

I tried this but it still give the error 1798.

I have been trying to understand how the block works. You have to know that my pc that runs twincat is connected via WIFI with my router. So the block has to sent a message via the WIFI link to my router and then to my ISP. How does the service know to who to send? I am a bit lost.


  Reply With Quote
Old December 12th, 2008, 07:23 AM   #4
dpinezic
Member
Croatia

dpinezic is offline
 
Join Date: Dec 2008
Location: Zagreb
Posts: 15
You need to have installed Beckhoff Twincat TCP/IP server because it uses own TCP/IP socket client/server.
Also I had problems with constructing emails as every e-mail has header like "Content-Type: text/plain; charset=ISO-8859-2; format=flowed$0D$0AContent-Transfer-Encoding: 7bit$0D$0A$0D$0A%S$0D$0A"
so you will need to experiment a little with this.
  Reply With Quote
Old December 12th, 2008, 07:32 AM   #5
tragically1969
Member
United Kingdom

tragically1969 is offline
 
Join Date: Jun 2007
Location: uk
Posts: 1,278
Quote:
Originally Posted by Pete:-) View Post
1) The TwinCAT ADS SMTP service must be

I am using the SMTP server of my ISP. This works with a username and a password. I have no other possibility. I am using the "FB_SmtpV2" block. This one accepts username and password if I understood it well.
This is what they write about the block "The PLC block FB_SmtpV2 allows to send mails from a smtp server that requires authentication."



Sorry dont know anything about the product but if you are in any doubt about the SMTP server you can use one the PC itself, there is plenty of free ones out there, heres one for instance:

http://www.softstack.com/freesmtp.html
  Reply With Quote
Old December 12th, 2008, 08:29 AM   #6
dpinezic
Member
Croatia

dpinezic is offline
 
Join Date: Dec 2008
Location: Zagreb
Posts: 15
Twincat doesn't have SMTP server capabilites, it only acts like Outlook or Thunderbird(as SMTP client) it just opens TCP/IP socket connection on port 25 and sends pretty much raw data to the SMTP server(which can be on local PC or somewhere in the network, there are no restrictions, you can enter either Name or IP address of the server, ex. pop.gmail.com or 192.168.0.2). Firewall can be problem and SMTP servers which are using authentication.
I don't have V2 version of SMTP FB so I can't test authentication method, but I think it is not encrypted connection(http://en.wikipedia.org/wiki/SMTP-AUTH).

For testing purposes I would try with Free SMTP server on Local PC which Tragically1969 suggested. Add some SMTP users, start server and try to send from PLC to your Local PC IP address, of course e-mail to one of the users which you created in your free SMTP server, ex. john@mypcdomian.net(SMTP domain should then be mypcdomain.net).

Last edited by dpinezic; December 12th, 2008 at 08:33 AM.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Beckhoff TwinCat Jon R LIVE PLC Questions And Answers 2 June 14th, 2011 11:39 AM
Saving Data values in Beckhoff Twincat matt_sd LIVE PLC Questions And Answers 6 May 9th, 2008 12:52 AM
Beckhoff TwinCAT New User Quick Start Archie LIVE PLC Questions And Answers 1 November 16th, 2007 11:16 AM
Beckhoff Twincat help matt_sd LIVE PLC Questions And Answers 1 February 17th, 2007 07:20 AM
IEC1131 (Wago I/O Pro, Beckhoff TwinCat, Klockner Moeller XSoft, MultiPROG) zif2 LIVE PLC Questions And Answers 5 September 9th, 2003 08:38 PM


All times are GMT -5. The time now is 08:57 PM.


.