Lift System - No foreign application responded to a DDE initiate (Error 282) 
Author Message
 Lift System - No foreign application responded to a DDE initiate (Error 282)

Hello All,

I'm working on a project for Lift System which I need to receive a
continuous Lift message via RS232 and decode it and then, based on the
decoded message, send value to
a SCADA software. The lift data is sent to my program every 10~300 ms
non-stop.

In order not to put a heavy load on the SCADA software, i have
implemented
i) Only send change of value to SCADA software
ii) have delay (sleep) after sending each lift status to SCADA
software

FYI, the client allows delay of the status update on the SCADA
software by my program

However, no matter how much delay i put, the SCADA will be unavailable
after few minutes to few hours. The error generated is
1) Error 282 No foreign application responded to DDE initiate
2) Error 286 Timeout while waiting for DDE response

I attach the code fragments which involve receiving of Lift data and
updating of SCADA software. Please kindly advise if there is any
improvement to be made. Thanks a lot!!!

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As
Long)
.
.
.
Private Sub MSComm1_OnComm()
On Error GoTo FixErr

Static InputMsg As String
Dim STXLoc As Integer, ETXLoc As Integer
Dim Message As String
Dim Buffer As String

Static counter As Integer

120
If MSComm1.CommEvent = comEvReceive Then
    Buffer = MSComm1.Input
    counter = counter + 1

    If (counter > CInt(DelayFrequency)) Then
        Call FilterValues
        counter = 0
        Exit Sub
    End If
    InputMsg = InputMsg & Buffer

    'Q: Correct to do so for STX and ETX?
    STXLoc = InStr(1, InputMsg, Chr$(&H2))
    ETXLoc = InStr(STXLoc + 1, InputMsg, Chr$(&H3))

130  If STXLoc >= 1 And ETXLoc > STXLoc Then
        Message = InputMsg

        InputMsg = ""
140      Call ProcessLiftMessage(Mid$(Message, STXLoc, ETXLoc - STXLoc
+ 1))
    End If
End If

FixErr:
If Err.Number <> 0 Then
    Print #LogFNo, Format(Now, "YYYY-MM-DD hh:mm:ss") & " Receiving
Message, Error " & Err.Number & " " & _
        Err.Description & " after " & Erl & "."
    logFLineNo = logFLineNo + 1
End If
End Sub

Sub FilterValues()
On Error GoTo FixErr

Dim i As Integer

400
For i = 1 To txtELEDIR.UBound

    'Elevator Running (direction)
    If (txtELEDIR(i).Text <> txtELEDIRbuf(i).Text) Then
        Call SendDDE(txtELEDIR(i), txtELEDIR(i).Text)
        txtELEDIRbuf(i).Text = txtELEDIR(i).Text
        Sleep (500)

    End If

    'mode
    If (txtELEMODE(i).Text <> txtELEMODEbuf(i).Text) Then
        Call SendDDE(txtELEMODE(i), txtELEMODE(i).Text)
        txtELEMODEbuf(i).Text = txtELEMODE(i).Text

        Sleep (500)

    End If

    'error stat
    If (txtELEErr(i).Text <> txtELEErrbuf(i).Text) Then
        Call SendDDE(txtELEErr(i), txtELEErr(i).Text)
        txtELEErrbuf(i).Text = txtELEErr(i).Text
        Sleep (500)

    End If

    'group stat
    If (TxtELEGrp(i).Text <> TxtELEGrpbuf(i).Text) Then
        Call SendDDE(TxtELEGrp(i), TxtELEGrp(i).Text)
        TxtELEGrpbuf(i).Text = TxtELEGrp(i).Text
        Sleep (500)

    End If

    'emergency stat
    If (txtELEEme(i).Text <> txtELEEmebuf(i).Text) Then
        Call SendDDE(txtELEEme(i), txtELEEme(i).Text)
        txtELEEmebuf(i).Text = txtELEEme(i).Text

        Sleep (500)

    End If

    counter = counter + 1
    If (counter > 50) Then
        If txtheartbeat.Text = "0" Then
            Call SendDDE(txtheartbeat, "0")
            txtheartbeat.Text = "1"
        Else
            Call SendDDE(txtheartbeat, "1")
            txtheartbeat.Text = "0"
        End If
        counter = 0
        Sleep (200)
    End If

Next i

FixErr:
   If Err.Number <> 0 Then
        Print #LogFNo, Format(Date, "YYMMDD") & " " & Format(Time,
"HH:mm:ss") & " " & Err.Number & " " & Err.Description & ", Filtering
value after " & Erl & "."
        logFLineNo = logFLineNo + 1

    End If
End Sub

Private Sub SendDDE(txt As TextBox, value As String)
On Error GoTo FixErr
360
    txtPcVue.LinkMode = vbLinkNone
    txtPcVue.LinkItem = txt.LinkItem
    txtPcVue.Text = value
    txtPcVue.LinkMode = vbLinkManual
    txtPcVue.LinkPoke

    Print #LogFNo, Format(Date, "YYMMDD") & " " & Format(Time,
"HH:mm:ss") & " " & "Send " & value & " to " & txtPcVue.LinkItem & "
for " _
        & txt.Tag & "."
    logFLineNo = logFLineNo + 1

FixErr:
   If Err.Number <> 0 Then
        Print #LogFNo, Format(Date, "YYMMDD") & " " & Format(Time,
"HH:mm:ss") & " " & "Sending " & value & " to " & txtPcVue.LinkItem &
", Error " & Err.Number & " " & Err.Description & " after " & Erl &
"."
        logFLineNo = logFLineNo + 1

    End If
End Sub



Sun, 01 Sep 2013 22:09:11 GMT  
 Lift System - No foreign application responded to a DDE initiate (Error 282)

Quote:
> Hello All,

> I'm working on a project for Lift System which I need to receive a
> continuous Lift message via RS232 and decode it and then, based on the
> decoded message, send value to
> a SCADA software. The lift data is sent to my program every 10~300 ms
> non-stop.

> In order not to put a heavy load on the SCADA software, i have
> implemented
> i) Only send change of value to SCADA software
> ii) have delay (sleep) after sending each lift status to SCADA
> software

> FYI, the client allows delay of the status update on the SCADA
> software by my program

> However, no matter how much delay i put, the SCADA will be unavailable
> after few minutes to few hours. The error generated is
> 1) Error 282 No foreign application responded to DDE initiate
> 2) Error 286 Timeout while waiting for DDE response

This sounds like handles to the same object or resource is being open and
not closed, and after around 65536 times, Windows returns an error code.
Since you are using a Timer with period of 10~300 ms, this translates to
655.36 to 19660.8 Seconds, or 10.92 minutes to 5.46 Hours. You can put a
counter in SendDDE to see if this is the case.

This could be caused by either your app or the target app. It maybe related
to DDE, or not, like for example if the target app opens handles to other
stuff but not closing them. To see which one is causing the leak, use Task
Manager and look at "Handle Count" column. Use View-->Select Columns to show
that column.



Sun, 01 Sep 2013 23:56:46 GMT  
 Lift System - No foreign application responded to a DDE initiate (Error 282)

Quote:


> > Hello All,

> > I'm working on a project for Lift System which I need to receive a
> > continuous Lift message via RS232 and decode it and then, based on the
> > decoded message, send value to
> > a SCADA software. The lift data is sent to my program every 10~300 ms
> > non-stop.

> > In order not to put a heavy load on the SCADA software, i have
> > implemented
> > i) Only send change of value to SCADA software
> > ii) have delay (sleep) after sending each lift status to SCADA
> > software

> > FYI, the client allows delay of the status update on the SCADA
> > software by my program

> > However, no matter how much delay i put, the SCADA will be unavailable
> > after few minutes to few hours. The error generated is
> > 1) Error 282 No foreign application responded to DDE initiate
> > 2) Error 286 Timeout while waiting for DDE response

> This sounds like handles to the same object or resource is being open and
> not closed, and after around 65536 times, Windows returns an error code.
> Since you are using a Timer with period of 10~300 ms, this translates to
> 655.36 to 19660.8 Seconds, or 10.92 minutes to 5.46 Hours. You can put a
> counter in SendDDE to see if this is the case.

> This could be caused by either your app or the target app. It maybe related
> to DDE, or not, like for example if the target app opens handles to other
> stuff but not closing them. To see which one is causing the leak, use Task
> Manager and look at "Handle Count" column. Use View-->Select Columns to show
> that column.

Thanks for your reply.
I'm not using a Timer with period of 10~300ms in my program. What i
meant in my post was that the lift system sends the lift data to my
program via a RS232 port every 10-300ms. The handling of the arrival
of data at RS232 in my program is in MSComm1_OnComm()


Mon, 02 Sep 2013 00:15:08 GMT  
 Lift System - No foreign application responded to a DDE initiate (Error 282)

Quote:




>>> Hello All,

>>> I'm working on a project for Lift System which I need to receive a
>>> continuous Lift message via RS232 and decode it and then, based on
>>> the decoded message, send value to
>>> a SCADA software. The lift data is sent to my program every 10~300
>>> ms non-stop.

>>> In order not to put a heavy load on the SCADA software, i have
>>> implemented
>>> i) Only send change of value to SCADA software
>>> ii) have delay (sleep) after sending each lift status to SCADA
>>> software

>>> FYI, the client allows delay of the status update on the SCADA
>>> software by my program

>>> However, no matter how much delay i put, the SCADA will be
>>> unavailable after few minutes to few hours. The error generated is
>>> 1) Error 282 No foreign application responded to DDE initiate
>>> 2) Error 286 Timeout while waiting for DDE response

>> This sounds like handles to the same object or resource is being
>> open and not closed, and after around 65536 times, Windows returns
>> an error code. Since you are using a Timer with period of 10~300 ms,
>> this translates to 655.36 to 19660.8 Seconds, or 10.92 minutes to
>> 5.46 Hours. You can put a counter in SendDDE to see if this is the
>> case.

>> This could be caused by either your app or the target app. It maybe
>> related to DDE, or not, like for example if the target app opens
>> handles to other stuff but not closing them. To see which one is
>> causing the leak, use Task Manager and look at "Handle Count"
>> column. Use View-->Select Columns to show that column.

> Thanks for your reply.
> I'm not using a Timer with period of 10~300ms in my program. What i
> meant in my post was that the lift system sends the lift data to my
> program via a RS232 port every 10-300ms. The handling of the arrival
> of data at RS232 in my program is in MSComm1_OnComm()

It doesn't matter if you are using a Timer specifically, your OnComm event
is called several times a second, and this is close. Also, the timing
figures I posted could be incorrect because you maybe calling SendDDE
several times in the routine.


Mon, 02 Sep 2013 00:23:26 GMT  
 Lift System - No foreign application responded to a DDE initiate (Error 282)


Quote:
> I'm working on a project for Lift System which I need to receive a
> continuous Lift message via RS232 and decode it and then, based on the
> decoded message, send value to
> a SCADA software. The lift data is sent to my program every 10~300 ms
> non-stop.

> In order not to put a heavy load on the SCADA software, i have
> implemented
> i) Only send change of value to SCADA software
> ii) have delay (sleep) after sending each lift status to SCADA
> software

Why did you think Sleep would help after sending DDE information?
Did you have some text somewhere indicating that should be used?
It seems odd to me that you would ask the system to transfer data
and then immediately become unresponsive for so many milliseconds....

Quote:
> Private Sub SendDDE(txt As TextBox, value As String)
> On Error GoTo FixErr
> 360
>     txtPcVue.LinkMode = vbLinkNone
>     txtPcVue.LinkItem = txt.LinkItem
>     txtPcVue.Text = value
>     txtPcVue.LinkMode = vbLinkManual
>     txtPcVue.LinkPoke

This is not the correct method of using DDE.  It would be similar to
trying to have a conversation over the phone where, every time you
wanted to say something, you hang up, and dial their phone number.

It may be the cause of your problem.

Set up the LinkItem and LinkMode once when you want to start
the DDE conversation, and use LinkPoke to send the new values.

See if that helps.
LFS



Tue, 03 Sep 2013 10:24:53 GMT  
 Lift System - No foreign application responded to a DDE initiate (Error 282)
On Thu, 17 Mar 2011 20:24:53 -0600, "Larry Serflaten"

Quote:


>> I'm working on a project for Lift System which I need to receive a
>> continuous Lift message via RS232 and decode it and then, based on the
>> decoded message, send value to
>> a SCADA software. The lift data is sent to my program every 10~300 ms
>> non-stop.

>> In order not to put a heavy load on the SCADA software, i have
>> implemented
>> i) Only send change of value to SCADA software
>> ii) have delay (sleep) after sending each lift status to SCADA
>> software

>Why did you think Sleep would help after sending DDE information?
>Did you have some text somewhere indicating that should be used?
>It seems odd to me that you would ask the system to transfer data
>and then immediately become unresponsive for so many milliseconds....

>> Private Sub SendDDE(txt As TextBox, value As String)
>> On Error GoTo FixErr
>> 360
>>     txtPcVue.LinkMode = vbLinkNone
>>     txtPcVue.LinkItem = txt.LinkItem
>>     txtPcVue.Text = value
>>     txtPcVue.LinkMode = vbLinkManual
>>     txtPcVue.LinkPoke

>This is not the correct method of using DDE.  It would be similar to
>trying to have a conversation over the phone where, every time you
>wanted to say something, you hang up, and dial their phone number.

>It may be the cause of your problem.

>Set up the LinkItem and LinkMode once when you want to start
>the DDE conversation, and use LinkPoke to send the new values.

Take a look at this series of articles:
"DDE - What is It ?"
http://www.softwaretoolbox.com/tech_support/techexpertisecenter/objec...

The link on the bottom to "DDE Servers vs. ActiveX Controls", while
not specific to your question, provides a good high level view of how
DDE works and why it may not be appropriate for your situation (or why
you may need to rearrange things if you have to use it).

-ralph



Tue, 03 Sep 2013 10:15:02 GMT  
 Lift System - No foreign application responded to a DDE initiate (Error 282)


ha, Clarification.

That response was obviously meant for the OP.
I agree with Larry.

-ralph



Tue, 03 Sep 2013 10:31:04 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. VB ERROR-NO FOREIGN APPL.RESPOND TO A DDE INITIATE

2. vb screensaver dde error 282 under nt4

3. DDE Runtime error 282 on VB4

4. vb screensaver dde error 282 under nt4

5. Problem initiating DDE

6. I can't Initiate a DDE Conversation

7. foreign app wont perform DDE method or op

8. Initiate system shutdown

9. Event: all DDE requests responded

10. DDE foreign app won't respond err, but it does...

11. DDE Server Window: outlook.exe - error in application

12. DDE Application is busy Error

 

 
Powered by phpBB® Forum Software