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