<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="place"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        text-align:right;
        direction:rtl;
        unicode-bidi:embed;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
pre
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
@page Section1
        {size:595.3pt 841.9pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1 dir=RTL>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 color=black face=Verdana><span style='font-size:10.0pt;
font-family:Verdana;color:black'>Dear Sir/Madam,<o:p></o:p></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 color=black face=Verdana><span style='font-size:10.0pt;
font-family:Verdana;color:black'><o:p> </o:p></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 color=black face=Verdana><span style='font-size:10.0pt;
font-family:Verdana;color:black'>I’m developing a source code in C++ for
RTU (Remote Terminal Unit). It will gather data of IO modules of RTU and then
transmit them to SCADA center with standard communication protocol
(IEC-870-5-101). In first step, I developed it in windows in visual C++
environment. For testing its functionality, I arranged test vectors instead of
IO cards of RTU in windows. I trigger test vector via timers in windows.
Actually, it is running well without exception. I used try catch in any thread
in my program. For example I arranged it in DI thread as follows:<o:p></o:p></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 color=black face=Verdana><span style='font-size:10.0pt;
font-family:Verdana;color:black'><o:p> </o:p></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 color=black face=Verdana><span style='font-size:10.0pt;
font-family:Verdana;color:black'>
// Digital Input process thread<o:p></o:p></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'> <font color=blue><span
style='color:blue'>while</span></font><font color=red><span style='color:red'>(</span></font><st1:place
w:st="on">Loop</st1:place><font color=red><span style='color:red'>){<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
<font color=blue><span style='color:blue'>try</span></font><font color=red><span
style='color:red'>{<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
GetMsgQue<font color=red><span style='color:red'>()-></span></font>PopWait<font
color=red><span style='color:red'>(</span></font>Msg<font color=red><span
style='color:red'>);</span></font> <o:p></o:p></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
Msg<font color=red><span style='color:red'>.</span></font>OpenMsg<font
color=red><span style='color:red'>();<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
bFunctionCode <font color=red><span style='color:red'>=</span></font> <font
color=red><span style='color:red'>(</span></font>DITHREAD_EVENTS_ENUM_<font
color=red><span style='color:red'>)</span></font>Msg<font color=red><span
style='color:red'>.</span></font>GetFunCode<font color=red><span
style='color:red'>();<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
<font color=blue><span style='color:blue'>switch</span></font><font color=red><span
style='color:red'>(</span></font>bFunctionCode<font color=red><span
style='color:red'>){<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
<font color=blue><span style='color:blue'>case</span></font>
DITH_EVENT_SHOUTDOWN_<font color=red><span style='color:red'>:</span></font>
<font color=green><span style='color:green'>// ShutDown message to Kill thread<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
Loop <font color=red><span style='color:red'>=</span></font> FALSE_S<font
color=red><span style='color:red'>;<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
DestroyThread<font color=red><span style='color:red'>(</span></font>m_pthread_t<font
color=red><span style='color:red'>);<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
<font color=blue><span style='color:blue'>break</span></font><font color=red><span
style='color:red'>;<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
<font color=blue><span style='color:blue'>case</span></font>
DITH_EVENT_HWMCHKMSG_<font color=red><span style='color:red'>:</span></font>
<font color=green><span style='color:green'>// Hardware Manager Health Check
message to DI Thread<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 color=red face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New";color:red'>
...<o:p></o:p></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
<font color=blue><span style='color:blue'>break</span></font><font color=red><span
style='color:red'>;<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
<font color=blue><span style='color:blue'>case</span></font>
DITH_EVENT_PCIFREEZE_<font color=red><span style='color:red'>:</span></font>
<font color=green><span style='color:green'>// PCI Freeze message<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
...<font color=red><span style='color:red'><o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
<font color=blue><span style='color:blue'>break</span></font><font color=red><span
style='color:red'>;<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
<font color=blue><span style='color:blue'>default</span></font> <font
color=red><span style='color:red'>:<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
m_pApp<font color=red><span style='color:red'>-></span></font>GetGate<font
color=red><span style='color:red'>()-></span></font>ErrorMsg<font color=red><span
style='color:red'>(</span></font><font color=maroon><span style='color:maroon'>"DITH,
Unknown FunCode received to DI thread!"</span></font><font color=red><span
style='color:red'>);<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 color=red face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New";color:red'><o:p> </o:p></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
<font color=red><span style='color:red'>}<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
<font color=red><span style='color:red'>}<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
<font color=blue><span style='color:blue'>catch</span></font><font color=red><span
style='color:red'>(</span></font>CScadaException<font color=red><span
style='color:red'>*</span></font> e<font color=red><span style='color:red'>){<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
m_pApp<font color=red><span style='color:red'>-></span></font>GetGate<font
color=red><span style='color:red'>()-></span></font>ErrorMsg<font color=red><span
style='color:red'>(</span></font>e<font color=red><span style='color:red'>-></span></font>GetErrorMessage<font
color=red><span style='color:red'>()+</span></font><font color=maroon><span
style='color:maroon'>"!(DI_ProcessLoop)"</span></font><font
color=red><span style='color:red'>);<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
<font color=blue><span style='color:blue'>delete</span></font> e<font
color=red><span style='color:red'>;<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
<font color=red><span style='color:red'>}<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
<font color=blue><span style='color:blue'>catch</span></font><font color=red><span
style='color:red'>(...){<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
m_pApp<font color=red><span style='color:red'>-></span></font>GetGate<font
color=red><span style='color:red'>()-></span></font>ErrorMsg<font color=red><span
style='color:red'>(</span></font><font color=maroon><span style='color:maroon'>"Unknown
exception occurred in DI_ProcessLoop!"</span></font><font color=red><span
style='color:red'>);<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'>
<font color=red><span style='color:red'>}<o:p></o:p></span></font></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face="Courier New"><span style='font-size:10.0pt;
font-family:"Courier New"'> <font color=red><span
style='color:red'>}</span></font></span></font><font size=2 color=black
face=Verdana><span style='font-size:10.0pt;font-family:Verdana;color:black'><o:p></o:p></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 color=black face=Verdana><span style='font-size:10.0pt;
font-family:Verdana;color:black'><o:p> </o:p></span></font></p>
<pre dir=LTR><font size=2 color=black face=Verdana><span style='font-size:10.0pt;
font-family:Verdana;color:black'>Now, I’m porting it to Linux to run in embedded system (RTU). It is going well so far but I am hitting a segmentation-fault and each time error occurs, my application will shut off and Aborted (Segmentation Fault) is appear on the terminal. It seems, in Windows catch(...) is a fail safe that catches everything, but in Linux catch(...) doesn't seem to catch anything.<br>
<br>
<o:p></o:p></span></font></pre><pre dir=LTR><font size=2 color=black
face=Verdana><span style='font-size:10.0pt;font-family:Verdana;color:black'>My question is how to control this thing? Let’s say after error occurs, just prompt the error message and never do that action so that the app will be ok and still running.<o:p></o:p></span></font></pre><pre
dir=LTR><font size=2 color=black face=Verdana><span style='font-size:10.0pt;
font-family:Verdana;color:black'><o:p> </o:p></span></font></pre>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 color=black face=Verdana><span style='font-size:10.0pt;
font-family:Verdana;color:black'>Best Regards<o:p></o:p></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>
Ali </span></font><font face=Arial><span style='font-family:Arial'><o:p></o:p></span></font></p>
<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
</div>
</body>
</html>