File: serial.html

package info (click to toggle)
cc1111 2.9.0-4
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 38,692 kB
  • ctags: 132,262
  • sloc: ansic: 442,650; cpp: 37,006; sh: 10,334; makefile: 5,511; asm: 5,279; yacc: 2,953; lisp: 1,524; perl: 807; awk: 493; python: 468; lex: 447
file content (135 lines) | stat: -rw-r--r-- 3,750 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<html>
<head>
<title>&micro;Csim: Serial Interafces</title>
</head>

<body bgcolor="white">

<h1>Using serial interfaces</h1>

<h3>Connecting a terminal</h3>

You can easily connect a terminal to the serial interface of the
simulated microcontroller. This terminal is just a file so it can be
anything which is represented as a file. It can be a real serial line
of the computer:

<pre>
<font color="blue">$</font> s51 -s/dev/ttyS1
</pre>

Of course you must use the actual device name of your operating
system. Device name <tt>ttyS1</tt> above is used in Linux
systems. Your system can use other names.

<p>You can use a terminal of your system. It can be a virtual console
if your system provides such as Linux does for example. On X Windows
you can use <b>xterm</b> windows as terminals, one for running the
simulator and one as a terminal on CPU's serial line. Here is a sample
how to do this:

<ol><li>Prepare the terminal window which will be connected to the
serial line:

<p><ul><li>Check the device name which represents the terminal:

<pre>
<font color="blue">$</font> tty
<font color="green">/dev/ttyp1</font>
</pre>

<li>Disconnect the shell from the terminal. Usualy I use the
<b>tail</b> command and any existing text file:

<pre>
<font color="blue">$</font> tail -f $HOME/.profile
</pre>

</ul>

<li>Run the simulator in the other window:

<pre>
<font color="blue">$</font> s51 -s/dev/ttyp1 program.hex
</pre>

Use the output of the <b>tty</b> command above as the parameter of the
<tt>-s</tt> option.

</ol>

Every character sent out by the simulated program
appears in the "terminal" window and every charater you type in there
will be received by the simulated controller's serial line.


<h3>Connecting two instances of simulator</h3>

Executing two instances of the simulator, serial lines of two
simulators (micros) can be connected together so they can talk to
each other over their serial interface. It is because you can specify
separate files for serial input and output. For example you run two
simulators "1" and "2", here is the sample how to connect them:

<p><img src="serial1.gif">

<ol><li>Make two FIFOs to represent physical wires in serial cable
connecting two micros:

<pre>
<font color="blue">$</font> mkfifo 1-2 2-1 <font color="magenta"># 1-2: 1->2  and 2-1: 2->1</font>
</pre>

<li>Start two simulators and specify the FIFOs as input and output of
serial interface:

<pre>
<font color="blue">term1 $</font> <font color="magenta"># start sim "1"</font>
<font color="blue">term1 $</font> s51 -Sin=2-1,out=1-2 program_1_.hex
<font color="blue">term2 $</font> <font color="magenta"># start sim "2"</font>
<font color="blue">term2 $</font> s51 -Sout=2-1,in=1-2 program_2_.hex
</pre>

Because opening a pipe blocks the program until other direction is
opened, the order of arguments above is <b>important</b>!

<p>

<li>Debug programs as usual.

</ol>

Using the most usefull unix commands <b>cat</b> and <b>tee</b> and
just some more FIFOs you can monitor serial communication, here is a
sample:

<p><img src="serial2.gif">

<ol><li>Make some FIFOs to use between simulators and tee "monitors":

<pre>
<font color="blue">$</font> mkfifo 1_tee tee_2 2_tee tee_2
</pre>

<li>Run monitoring programs (in two xterms for example):

<pre>
<font color="blue">xterm1 $</font> cat 1_tee|tee /dev/tty >tee_2 # monitor 1->2
<font color="blue">xterm2 $</font> cat 2_tee|tee /dev/tty >tee_1 # monitor 2->1
</pre>

<li>Now you can start simulators (on two other terminals:)

<pre>
<font color="blue">xterm3 $</font> s51 -Sin=tee_1,out=1_tee program_1_.hex
<font color="blue">xterm4 $</font> s51 -Sin=tee_2,out=2_tee program_2_.hex
</pre>

<li>Start your apps and listen what they are talking about.

</ol>

<hr>

</body>
</html>