?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. <html>
  2.   <head>
  3.     <meta content="text/html; charset=ISO-8859-2" http-equiv="content-type">
  4.     <title>&mu;Csim: Serial Interafces</title>
  5.   </head>
  6.   <body bgcolor="white">
  7.     <h1>Using serial interfaces</h1>
  8.     <h3>Connecting a terminal</h3>
  9.     You can easily connect a terminal to the serial interface of the
  10.     simulated microcontroller. This terminal is just a file so it can be
  11.     anything which is represented as a file. It can be a real serial line
  12.     of the computer:
  13.     <pre><font color="blue">$</font> s51 -s/dev/ttyS1
  14. </pre>
  15.     Of course you must use the actual device name of your operating
  16.     system. Device name <tt>ttyS1</tt> above is used in Linux
  17.     systems. Your system can use other names.
  18.     <p>You can use a terminal of your system. It can be a virtual console
  19.       if your system provides such as Linux does for example. On X Windows
  20.       you can use <b>xterm</b> windows as terminals, one for running the
  21.       simulator and one as a terminal on CPU's serial line. Here is a sample
  22.      how to do this:
  23.    </p>
  24.    <ol>
  25.      <li>Prepare the terminal window which will be connected to the
  26.        serial line:
  27.        <p></p>
  28.        <ul>
  29.          <li>Check the device name which represents the terminal:
  30.            <pre><font color="blue">$</font> tty
  31. <font color="green">/dev/ttyp1</font>
  32. </pre>
  33.          </li>
  34.          <li>Disconnect the shell from the terminal. Usually I use the
  35.            <b>tail</b> command and any existing text file:
  36.            <pre><font color="blue">$</font> tail -f $HOME/.profile
  37. </pre>
  38.          </li>
  39.        </ul>
  40.      </li>
  41.      <li>Run the simulator in the other window:
  42.        <pre><font color="blue">$</font> s51 -s/dev/ttyp1 program.hex
  43. </pre>
  44.        Use the output of the <b>tty</b> command above as the parameter of the
  45.        <tt>-s</tt> option.
  46.      </li>
  47.    </ol>
  48.    Every character sent out by the simulated program
  49.    appears in the "terminal" window and every charater you type in there
  50.    will be received by the simulated controller's serial line.
  51.     <h3>Connecting two instances of simulator</h3>
  52.     Executing two instances of the simulator, serial lines of two
  53.     simulators (micros) can be connected together so they can talk to
  54.     each other over their serial interface. It is because you can specify
  55.     separate files for serial input and output. For example you run two
  56.     simulators "1" and "2", here is the sample how to connect them:
  57.     <p><img src="serial1.svg">
  58.     </p>
  59.     <ol>
  60.       <li>Make two FIFOs to represent physical wires in serial cable
  61.         connecting two micros:
  62.         <pre><font color="blue">$</font> mkfifo 1-2 2-1 <font color="magenta"># 1-2: 1-&gt;2  and 2-1: 2-&gt;1</font>
  63. </pre>
  64.       </li>
  65.       <li>Start two simulators and specify the FIFOs as input and output of
  66.         serial interface:
  67.         <pre><font color="blue">term1 $</font> <font color="magenta"># start sim "1"</font>
  68. <font color="blue">term1 $</font> s51 -Sin=2-1,out=1-2 program_1_.hex
  69. <font color="blue">term2 $</font> <font color="magenta"># start sim "2"</font>
  70. <font color="blue">term2 $</font> s51 -Sout=2-1,in=1-2 program_2_.hex
  71. </pre>
  72.         Because opening a pipe blocks the program until other direction is
  73.         opened, the order of arguments above is <b>important</b>!
  74.         <p>
  75.         </p>
  76.       </li>
  77.       <li>Debug programs as usual.
  78.       </li>
  79.     </ol>
  80.     Using the most usefull unix commands <b>cat</b> and <b>tee</b> and
  81.     just some more FIFOs you can monitor serial communication, here is a
  82.     sample:
  83.     <p><img src="serial2.svg">
  84.     </p>
  85.     <ol>
  86.       <li>Make some FIFOs to use between simulators and tee "monitors":
  87.         <pre><font color="blue">$</font> mkfifo 1_tee tee_2 2_tee tee_2
  88. </pre>
  89.       </li>
  90.       <li>Run monitoring programs (in two xterms for example):
  91.         <pre><font color="blue">xterm1 $</font> cat 1_tee|tee /dev/tty &gt;tee_2 # monitor 1-&gt;2
  92. <font color="blue">xterm2 $</font> cat 2_tee|tee /dev/tty &gt;tee_1 # monitor 2-&gt;1
  93. </pre>
  94.       </li>
  95.       <li>Now you can start simulators (on two other terminals:)
  96.         <pre><font color="blue">xterm3 $</font> s51 -Sin=tee_1,out=1_tee program_1_.hex
  97. <font color="blue">xterm4 $</font> s51 -Sin=tee_2,out=2_tee program_2_.hex
  98. </pre>
  99.       </li>
  100.       <li>Start your apps and listen what they are talking about.
  101.       </li>
  102.     </ol>
  103.     <hr>
  104.   </body>
  105. </html>
  106.