⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 synth-new-host.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 HTML
📖 第 1 页 / 共 3 页
字号:
><P>Although it might seem more appropriate to use Tcl's<BCLASS="COMMAND">eval</B> procedure and have the callback functionsinvoked with the right number of arguments rather than a single list,that would cause serious problems if any of the data contained specialcharacters such as <TTCLASS="LITERAL">[</TT> or <TTCLASS="LITERAL">$</TT>. Thecurrent implementation of hooks avoids such problems, at the cost ofminor inconvenience when writing callbacks.    </P><P>A number of hooks are defined as standard. Some devices will addadditional hooks, and the device-specific documentation should beconsulted for those. User scripts can add their own hooks if desired.    </P><P></P><DIVCLASS="VARIABLELIST"><DL><DT><TTCLASS="LITERAL">exit</TT></DT><DD><P>This hook is called just before the I/O auxiliary exits. Hence itprovides much the same functionality as <TTCLASS="FUNCTION">atexit</TT> inC programs. The argument list passed to the callback function will beempty.         </P></DD><DT><TTCLASS="LITERAL">ecos_exit</TT></DT><DD><P>This hook is called when the eCos application has exited. It is usedmainly to shut down I/O operations: if the application is no longerrunning then there is no point in raising interrupts or storingincoming packets. The callback argument list will be empty.        </P></DD><DT><TTCLASS="LITERAL">ecos_initialized</TT></DT><DD><P>The synthetic target HAL will send a request to the I/O auxiliary oncethe static constructors have been run. All devices should now have beeninstantiated. A script could now check how many instances there are ofa given type of device, for example ethernet devices, and create alittle monitor window showing traffic on all the devices. The<TTCLASS="LITERAL">ecos_initialized</TT> callbacks will be run just beforethe user's <TTCLASS="FILENAME">mainrc.tcl</TT> script. The callbackargument list will be empty.        </P></DD><DT><TTCLASS="LITERAL">help</TT></DT><DD><P>This hook is also invoked once static constructors have been run, butonly if the user specified <TTCLASS="OPTION">-h</TT> or<TTCLASS="OPTION">--help</TT>. Any scripts that add their own command linearguments should add a callback to this hook which outputs details ofthe additional arguments. The callback argument list will be empty.        </P></DD><DT><TTCLASS="LITERAL">interrupt</TT></DT><DD><P>Whenever a device calls <BCLASS="COMMAND">synth::interrupt_raise</B> the<TTCLASS="LITERAL">interrupt</TT> hook will be called with a singleargument, the interrupt vector. The main use for this is to allowuser scripts to monitor interrupt traffic.        </P></DD></DL></DIV></DIV><DIVCLASS="REFSECT1"><ANAME="SYNTH-NEW-HOST-OUTPUT"></A><H2>Output and Filters</H2><P>Scripts can use conventional facilities for sending text output to theuser, for example calling <BCLASS="COMMAND">puts</B> or directlymanipulating the central text widget<TTCLASS="VARNAME">.main.centre.text</TT>. However in nearly all cases itis better to use output facilities provided by the I/O auxiliaryitself:     </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">synth::report &lt;msg&gt;synth::report_warning &lt;msg&gt;synth::report_error &lt;msg&gt;synth::internal_error &lt;msg&gt;synth::output &lt;msg&gt; &lt;filter&gt;</PRE></TD></TR></TABLE><P><BCLASS="COMMAND">synth::report</B> is intended for messages related tothe operation of the I/O auxiliary itself, especially additionaloutput resulting from <TTCLASS="OPTION">-v</TT> or<TTCLASS="OPTION">--verbose</TT>. If running in text mode the output will goto standard output. If running in graphical mode the output will go tothe central text window. In both modes, use of <TTCLASS="OPTION">-l</TT> or<TTCLASS="OPTION">--logfile</TT> will modify the behaviour.    </P><P><BCLASS="COMMAND">synth::report_warning</B>,<BCLASS="COMMAND">synth::report_error</B> and<BCLASS="COMMAND">synth::internal_error</B> have the obvious meaning,including prepending strings such as <TTCLASS="LITERAL">Warning:</TT> and<TTCLASS="LITERAL">Error:</TT>. When the eCos application informs the I/Oauxiliary that all static constructors have run, if at that pointthere have been any calls to <BCLASS="COMMAND">synth::error</B> then theI/O auxiliary will exit. This can be suppressed with command linearguments <TTCLASS="OPTION">-k</TT> or <TTCLASS="OPTION">--keep-going</TT>.<BCLASS="COMMAND">synth::internal_error</B> will output some informationabout the current state of the I/O auxiliary and then exitimmediately. Of course it should never be necessary to call thisfunction.     </P><P><BCLASS="COMMAND">synth::output</B> is the main routine for outputtingtext. The second argument identifies a filter. If running in text modethe filter is ignored, but if running in graphical mode the filter canbe used to control the appearance of this output. A typical use wouldbe:    </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    synth::output $line "console"</PRE></TD></TR></TABLE><P>This outputs a single line of text using the<TTCLASS="LITERAL">console</TT> filter. If running in graphical mode thedefault appearance of this text can be modified with the<TTCLASS="OPTION">appearance</TT> option in the<BCLASS="COMMAND">synth_device&nbsp;console</B> entry of the targetdefinition file. The <SPANCLASS="GUIMENUITEM">System filters</SPAN> menuoption can be used to change the appearance at run-time.    </P><P>Filters should be created before they are used. The proceduresavailable for this are:    </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">synth::filter_exists &lt;name&gt;synth::filter_get_listsynth::filter_add &lt;name&gt; [options]synth::filter_parse_options &lt;options&gt; &lt;parsed_options&gt; &lt;message&gt;synth::filter_add_parsed &lt;name&gt; &lt;parsed_options&gt;</PRE></TD></TR></TABLE><P><BCLASS="COMMAND">synth::filter_exists</B> can be used to check whetheror not a particular filter already exists: creating two filters withthe same name is not allowed.<BCLASS="COMMAND">synth::filter_get_list</B> returns a list of thecurrent known filters. <BCLASS="COMMAND">synth::filter_add</B> can beused to create a new filter. The first argument names the new filter,and the remaining arguments control the initial appearance. A typicaluse might be:    </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    synth::filter_add "my_device_tx" -foreground yellow -hide 1</PRE></TD></TR></TABLE><P>It is assumed that the supplied arguments are valid, which typicallymeans that they are hard-wired in the script. If instead the datacomes out of a configuration file and hence may be invalid, theI/O auxiliary provides a parsing utility. Typical usage would be:    </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    array set parsed_options [list]    set message ""    if { ![synth::filter_parse_options $console_appearance parsed_options message] } {        synth::report_error \	        "Invalid entry in target definition file $synth::target_definition\	         \n  synth_device \"console\", entry \"appearance\"\n$message"    } else {        synth::filter_add_parsed "console" parsed_options    }</PRE></TD></TR></TABLE><P>On success <TTCLASS="VARNAME">parsed_options</TT> will be updated with aninternal representation of the desired appearance, which can then beused in a call to <BCLASS="COMMAND">synth::filter_add_parsed</B>. Onfailure <TTCLASS="VARNAME">message</TT> will be updated with details of theparsing error that occurred.    </P></DIV><DIVCLASS="REFSECT1"><ANAME="SYNTH-NEW-HOST-GUI"></A><H2>The Graphical Interface</H2><P>When the I/O auxiliary is running in graphical mode, many scripts willwant to update the user interface in some way. This may be as simpleas adding another entry to the help menu for the device, or adding anew button to the toolbar. It may also involve adding new subwindows,or even creating entire new toplevel windows. These may be simplemonitor windows, displaying additional information about what is goingon in the system in a graphical format. Alternatively they may emulateactual I/O operations, for example button widgets could be used toemulate real physical buttons.    </P><P>The I/O auxiliary does not provide many procedures related to thegraphical interface. Instead it is expected that scripts will justupdate the widget hierarchy directly.    </P><DIVCLASS="INFORMALFIGURE"><ANAME="AEN18674"><P></P><DIVCLASS="MEDIAOBJECT"><P><IMGSRC="layout.png"ALIGN="CENTER"></P></DIV><P></P></DIV><P>So adding a new item to the <SPANCLASS="GUIMENU">Help</SPAN> menu involves a<BCLASS="COMMAND">.menubar.help&nbsp;add</B> operation with suitablearguments. Adding a new button to the toolbar involves creating achild window in <TTCLASS="VARNAME">.toolbar</TT> and packing itappropriately. Scripts can create their own subwindows and then packit into one of <TTCLASS="VARNAME">.main.nw</TT>,<TTCLASS="VARNAME">.main.n</TT>, <TTCLASS="VARNAME">.main.ne</TT>,<TTCLASS="VARNAME">.main.w</TT>, <TTCLASS="VARNAME">.main.e</TT>,<TTCLASS="VARNAME">.main.sw</TT>, <TTCLASS="VARNAME">.main.s</TT> or<TTCLASS="VARNAME">.main.se</TT>. Normally the user should be allowed to<AHREF="synth-gui.html#SYNTH-GUI-LAYOUT">control</A> this via the targetdefinition file. The central window <TTCLASS="VARNAME">.main.centre</TT>should normally be left alone by other scripts since it gets used fortext output.    </P><P>The following graphics-related utilities may be found useful:    </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">synth::load_image &lt;image name&gt; &lt;filename&gt;synth::register_ballon_help &lt;widget&gt; &lt;message&gt;synth::handle_help &lt;URL&gt;</PRE></TD></TR></TABLE><P><BCLASS="COMMAND">synth::load_image</B> can be used to add a new image tothe current interpreter. If the specified file has a<TTCLASS="FILENAME">.xbm</TT> extension then the image will be amonochrome bitmap, otherwise it will be a colour image of some sort.A boolean will be returned to indicate success or failure, andsuitable diagnostics will be generated if necessary.    </P><P><BCLASS="COMMAND">synth::register_balloon_help</B> provides balloon helpfor a specific widget, usually a button on the toolbar.    </P><P><BCLASS="COMMAND">synth::handle_help</B> is a utility routine that can beinstalled as the command for displaying online help, for example:    </P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    .menubar.help add command -label "my device" -command \        [list synth::handle_help "file://$path"]</PRE></TD></TR></TABLE></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="synth-new-target.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-ref.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="synth-porting.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Writing New Devices - target</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="hal-synth-arch.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Porting</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -