The following operations are provided to service messages:
| Operation | Description |
|---|---|
| Sending message | Setting a non-zero value to the S42 register causes sending a message. Only 1 message can be sent at a time. |
| Status of sending message | If the message sending process is in progress, then S44 register contains a non-zero value. |
| Aborting sending message | Writing a non-zero value to the S43 register during sending a message process, causes aborting this operation (not immediately - to be sure check the S44 register). |
| Sending message error code | After sending message has completed, the major and minor return codes of this operation are stored into the S45 and S49 registers respectively. |
| Specifyng a message address (mandatory argument) | The S30 register specifies, which address file should be used. Value stored in the S30 register is treated as an extension to the address file (e.g. if S30=5 then file address.5 will be used). Valid values are 1..32768. |
| Specifying a message body | The S31 register specifies, which body file should be used. Value stored in the S31 register is treated as an extension to the body file (e.g. if S31=2 then file body.2 will be used). Valid values are 0..32768, where 0 doesn't include body into the sent message. |
| Specifying a message attachment | The S32 register specifies, which attachment file should be used. Value stored in the S32 register is treated as an extension to the attachment file (e.g. if S32=3 then file attachment.3 will be used). Valid values are 0..32768, where 0 doesn't include attachment into the sent message. |
| Specifying a number of records | The S33 register specifies, how many records should be attached to the sent message. Values from 1 to the max. length of circular buffer specify the number of records. A zero causes sending all records. Register S33 has its meaning only if S32 contains a non-zero value. In case of the specified number of records being greater than the number of records available on the buffer, WCA will wait until the required number of records will be written to the buffer. |
This example below shows how to send a message, when both input I1 and input I2 are equal true.
Example 5-1. Sending simple message
/* trigger */
I1 && I2 ==> B0;
/* check trigger and status
* of completing previous sending action
*/
B0 && !S44 ==>
/* specify the filename ("/home/address.1")
* for template of address
*/
S30 = 1,
/* optionally specify the filename
* ("/home/body.3") for template of body
*/
S31 = 3,
/* don't need attachment - it's short message */
S32 = 0,
/* send message */
S42 = 1;
|
Contents of the "/home/address.1" file
mailto:<tracelisting@dot.com>?from=Recorder <WebEmbed@dot.com> |
Contents of the "/home/body.3" file
Gate opened.
Current Date: &IOString(S22)/&IOString(S23)/&IOString(S21)
Time: &IOString(S25):&IOString(S26):&IOString(S27) |
This example shows how to send a message, containing the trace information for analog input D1 and D2.
Example 5-2. Sending complex message
/* record value of D1 at every minute */
not S27 :
/* write D1 to the first argument of record */
S50 = D1,
/* write D2 to the second argument of record */
S51 = D2,
/* write a new record to the circular buffer */
S40 = 1;
/* check usage level of buffer, if more than 50% */
S46 > (S47 / 2) ==> B0;
/* send a message, if previous was finished only */
B0 && !S44 :
/* specify the filename ("/home/address.10")
* for template of address
*/
S30 = 10,
/* specify the filename ("/home/body.10")
* for template of body
*/
S31 = 10,
/* specify the filename ("/home/attachment.10")
* for template of body
*/
S32 = 10,
/* send all records */
S33 = 0,
/* send message */
S42 = 1; |
Contents of the "/home/address.10" file
mailto:<security@dot.com>?from=Gate 1 <WebEmbed@dot.com> |
Contents of the "/home/body.10" file
History of D1 and D2 analog inputs.
+-----------------+------+------+
| Time | D1 | D2 |
+-----------------+------+------+ |
Contents of the "/home/attachment.10" file
| %t | %4d | %4d | |
Hypotetical e-mail output
From MAILER-DAEMON Sat Dec 16 16:49:09 2000
Date: Sat, 16 Dec 2000 16:49:09 +0100 (CET)
From: Gate 1 <WebEmbed@dot.com>
Subject:
History of D1 and D2 analog inputs.
+-----------------+------+------+
| Time | D1 | D2 |
+-----------------+------+------+
| Dec 16 13:01:00 | 1234 | 3 |
| Dec 16 13:02:00 | 234 | 23 |
| Dec 16 13:03:00 | 34 | 123 |
| Dec 16 13:04:00 | 123 | 1456 |
| Dec 16 13:05:00 | 3034 | 743 |
| Dec 16 13:06:00 | 54 | 2123 |
.
.
. |
The following table shows description of returned major/minor error codes.
| Major Error Code (S45) | Description | Hints |
|---|---|---|
| 0 | Message sent successfully. | |
| 1 | Transmission aborted on user request. | Result of setting S43 to a non-zero value. |
| 2 | Cannot open requested file. | Check (according to values stored into the S30, S31, S32 registers) if appropriate files exist. |
| 3 | Error while reading file. | File system is probably corrupted. |
| 4 | Syntax error | Check syntax in configuration files. |
| 5 | Communication error. | Check also minor error description. |
| Minor Error Code (S49) | Description |
|---|---|
| 0 | No error. |
| 1 | Syntax error in "From" address. |
| 2 | Syntax error in "To" address. |
| 3 | Syntax error in "CC" address. |
| 4 | Bad character in the "From" address. |
| 5 | Bad character in the "To" address. |
| 6 | Bad character in the "CC" address. |
| 7 | Bad character in the "Subject" address. |
| 8 | Error opening socket. |
| 9, 10, 13, 15, 17, 23 | SMTP server returning error code. |
| 12 | Error while sending data (HELO) to the SMTP server. |
| 14, 16, 18, 20, 22, 24, 301, 302 | Socket communication error. |
| 100 | Error while sending data (field TO:) to the SMTP server. |
| 101 | SMTP server returning error code (filed TO:). |
| 200 | Error while reading data from SMTP server. |
| 202 | Internal buffer overflow while reading data from SMTP server. |
| 300 | Bad character in sending message. |
| 400 | Error while sending data (field CC:) to the SMTP server. |