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 even can be a real serial line of the computer:
$ ucsim_51 -s/dev/ttyS1
Of course you must use the actual device name of your operating system. Device name ttyS1 above is used in Linux systems. Your system can use other names.
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 xterm 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:
$ tty /dev/ttyp1
$ tail -f $HOME/.profile
$ ucsim_51 -s/dev/ttyp1 program.hexUse the output of the tty command above as the parameter of the -s option.
Every character sent out by the simulated program appears in the "terminal" window and every character you type in there will be received by the simulated controller's serial line.
Notes
-s option is deprecated, it is recommended to use -S instead. Option -S provides more features and flexibility but it requires to use different syntax:
-S subopt1,subopt2,...
Known suboptions are:
Input and output file can be a regular file or a special one, for example pipe (fifo) or a TCP socket. If a file is a tty, the simulator will assume that a terminal is connected and will start an interactive session. TCP socket is treated as a tty, and telnet protocol is used to control the terminal settings. This can be turned off by raw suboption. If raw is used, simulator will not perform any terminal control and will not use/interpret telnet protocol commands.
µCsim contains an internal terminal emulator which can be turned on by converting a command console to the emulator, see UART display chapter in Peripheral displays document.
If you use -U id option to µCsim (where id is the number of the UART), the default command console will be converted to internal terminal emulator by default and can be used as interface to the simulated application.
It is possible to configure the character sequence which will be sent to UART when you press the ENTER key on the connected terminal emulator. This feature converts line endings that arrives from the terminal emulator to any sequence that needed by the simulated application. The configuration is stored in a variable, called:
uartX_nl
where X is ID number of the UART. Sequence is stored in bytes of this 32 bit variable, where lowest byte is the first character of the sequence. Last byte must be zero, so the max length of the sequence is 3 characters.
Examples of different settings:
expr uart0_nl='\r' ; CR only
expr uart0_nl=10 ; LF only
expr uart0_nl=0xa0d ; CRLF
To turn off the line ending conversion, the uartX_nl variable must be set to 0.
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:
$ mkfifo 1-2 2-1 # 1-2: 1->2 and 2-1: 2->1
term1 $ # start sim "1" term1 $ ucsim_51 -Sin=2-1,out=1-2,raw program_1_.hex term2 $ # start sim "2" term2 $ ucsim_51 -Sout=2-1,in=1-2,raw program_2_.hexBecause opening a pipe blocks the program until other direction is opened, the order of arguments above is important!
$ mkfifo 1_tee tee_2 2_tee tee_2
xterm1 $ cat 1_tee|tee /dev/tty >tee_2 # monitor 1->2
xterm2 $ cat 2_tee|tee /dev/tty >tee_1 # monitor 2->1
xterm3 $ ucsim_51 -Sin=tee_1,out=1_tee,raw program_1_.hex
xterm4 $ ucsim_51 -Sin=tee_2,out=2_tee,raw program_2_.hex