Serial Port Support

From OpenAlchemy.org

Contents

Interface

Interface here refers to applications that enable two systems to communicate and exchange data between themselves. In this chapter we concern ourselves with methods to transfer data between a remote system (i.e. an Amida) and a local system (i.e. a Linux PC). Most interfaces allow users to transfer data over the Serial port and allow users to set port and other communication parameters. Some examples on these interfaces are, ecu, C-Kermit, seyon, etc.

Minicom

At PicoPeta Simputers Pvt Ltd, our development engineers use minicom for data exchange between the Amida and the Linux PC. We recommend the same for all Amida developers.
Minicom is a communication program which somewhat resembles the shareware program TELIX but is free with source code and runs under most versions of UNIX. Features include dialing directory with auto-redial, support for UUCP-style lock files on serial devices, a separate script language interpreter, capture to file, multiple users with individual configurations, and more. To perform the data exchange between the Linux machine and the Amida, minicom must be installed on the Linux box. Following subsections will guide the developer on howto install minicom on his/her Linux machine.
Note that, minicom is shipped with the Mandrake 10.0 distribution. The simplest and recommended way is to install minicom and its dependent packages from the distribution. If the developer/reader has installed minicom on her/his Linux desktop, then the following three sections on obtaining and installing minicom would not be of relevance except for completeness.

Obtaining Minicom

The latest official version of Minicom is 2.1 and it can be downloaded from its homepage http://alioth.debian.org/projects/minicom/ . Note that, Redhat and Debian packages for minicom are avaialble.

Instructions for quick installing

  • Unzip and untar using the command tar zxvf minicom-2.1.tar.gz. This will create a directory minicom-2.1 (or the appropriate version) and place all the source files under that directory.
  • Change to the minicom-2.1 directory
  • ./configure (see ./configure -help for options)
  • make
  • make install(this should be done as root, or if you are logged in as somebody else, do "su -c 'make install")
  • As root, do 'minicom -s' to enter the configuration mode. Check all the settings, change what should be changed on your system, and choose 'Save setup as dfl' from the configuration menu to save the changed settings as system defaults. Edit /etc/minicom.users, adding the usernames which should be allowed to use minicom.

Now you should have minicom compiled, installed and ready to use.
For the latest information about minicom take a look at its homepage http://alioth.debian.org/projects/minicom/ .

Detailed installation steps

For a detailed installation steps, please go through the contents of the README and the INSTALL files. These files will be present in the minicom-2.1 directory or minicom-* directory where '*' stands for the appropriate version.

Howto use minicom

The data (binary or ASCII) is transferred between Amida and Linux PC using RS232 serial ports on the PC and Amida.

Login as root and invoke the minicom (with -o option) utility at the terminal of your PC. This is to be done whether transfer is from PC to Amida or vice versa. At this point, the connection to Amida is complete and one can view the directory structure of the Amida from the PC.

Uploading files using minicom to Amida

Receive files: Choose from various protocols (external). If you have the filename selection window and the prompt for download directory enabled, you'll get a selection window for choosing the directory for downloading. Otherwise the download directory defined in the Filenames and paths menu will be used.

  1. Press Ctrl A Z. This displays the whole list of minicom commands.
  2. Choose "s" and choose "z modem" option. (or one can directly press Ctrl A S)
  3. Next a file browser like window pops up. To browse through the list of files use arrow keys and to choose the file to be transferred press "space bar " once. Note that to change directory, space bar has to pressed twice in quick succession.
  4. Press Enter (actually the OKAY tab at the bottom is highlighted). Multiple files at once can be transferred by pressing the space bar on all the files to transferred.
  5. Another method of sending files from PC to the remote system is by issuing the command rz -z <file name> at prompt of the (bash) shell running on the remote system.

Downloading files from Amida using minicom

Send files: Choose the protocol like you do with the receive command. If you don't have the filename selection window enabled (in the File transfer protocols menu), you'll just have to write the filename(s) in a dialog window. If you have the selection window enabled, a window will pop up showing the filenames in your upload directory. You can tag and untag filenames by pressing spacebar, and move the cursor up and down with the cursor keys or j/k. The selected filenames are shown highlighted. Directory names are shown [within brackets] and you can move up or down in the directory tree by pressing the spacebar twice. Finally, send the files by pressing ENTER or quit by pressing ESC.

Once minicom is invoked it displays the remote shell(the shell running in the remote system-Amida).Using this shell on Amida, go to the directory where the file to be transferred exists and at the command prompt of the minicom terminal type "sz - y <file1> <file2>...".

Note: These files from Amida are transferred to the current working directory of the PC from where the Minicom command was invoked.

Configuration Options and Parameter Settings

The following issues regarding configuration will be dealt:

Communication Parameters
On pressing Ctrl A P will result in the above window to be displayed.

The current communication parameters are shown after the label "Current". The various parameters that can be configured are Speed(Baud rate), Parity Bit Setting, Start/Stop bit setting and number of bits/byte.

To change the settings simple press the key corresponding to that parameter value and accordingly the value displayed next to Current label will change. For instance, if the current settings are 9600 8N1, then on pressing "I" the baud rate gets changed to 115200 8N1.

Terminal Settings

On pressing Ctrl A T the above screen is displayed. Choose Terminal emulation: Ansi (color) or vt100. You can also change the backspace key here, turn the status line on or off, and define delay (in milliseconds) after each new line if you need that.

Configuration of minicom

By pressing C-A O the above setup menu will be displayed. Most settings there can be changed by everyone, but some are restricted to root only. Those privileged settings are marked with a star (*) here.

Filenames and paths: This menu defines your default directories.

  • A - Download directory where the downloaded files go to.
  • B - Upload directory where the uploaded files are read from.
  • C - Script directory Where you keep your login scripts
  • D - Script program Which program to use as the script interpreter? Defaults to the program "runscript", but if you want to use something else (eg, /bin/sh or "expect") it is possible. Stdin and stdout are connected to the modem, stderr to the screen.
  • E - Kermit programming
  • F - Logging options:Options to configure the logfile writing.

For more on file transfer protocols see the man pages of minicom.

Serial Port Setup
  • A - Serial device
    /dev/tty1 or /dev/ttyS1 for most people. /dev/cua<n> is still possible under Linux, but not recommended any more because these devices are obsolete and many newly installed systems with kernel 2.2.x don't have them. Use /dev/ttyS<n> instead. You may also have /dev/modem as a symlink to the real device.
  • B - Lock file location On most systems this should be /usr/spool/uucp. Linux systems use /var/lock. If this directory does not exist, minicom will not attempt to use lockfiles.
  • C - Callin program If you have a uugetty or something on your serial port, it could be that you want a program to be run to switch the modem cq. port into dialin/dialout mode. This is the program to get into dialin mode.
  • D - Callout program To get into dialout mode.
  • E - Bps/Par/Bits Default parameters at startup.

If one of the entries is left blank, it will not be used. So if you don¿t care about locking, and don't have a getty running on your modemline, entries B - D should be left blank. Be warned! The callin and callout programs are run with the effective user id of "root", i.e., 0!

Modem and Dialing

Here, the parameters for your modem are defined. The only things worth noticing are that control characters can be sent by prefixing them with a ", in which 'g means " itself, and the ' character must also be doubled as +\\\\+because backslash is used specially in the macro definitions. Some options however, don't have much to do with the modem but more with the behavior of minicom itself:

  • M - Dial time The number of seconds before minicom times out if no connection is established.
  • N - Delay before redial Minicom will redial if no connection was made, but it first waits some time.
  • O - Number of tries Maximum number of times that minicom attempts to dial.
  • P - Drop DTR time If you set this to 0, minicom hangs up by sending a Hayes-type hangup sequence. If you specify a non-zero value, the hangup will be done by dropping the DTR line. The value tells in seconds how long DTR will be kept down.
  • Q - Auto bps detect If this is on, minicom tries to match the dialed party¿s speed. With most modern modems this is NOT desirable, since the modem buffers the data and converts the speed.
  • R - Modem has DCD line If your modem, and your O/S both support the DCD line (that goes 'high' when a connection is made) minicom will use it. When you have this option on, minicom will also NOT start dialing while you are already online.
  • S - Status line shows DTE speed/line speed You can toggle the status line to show either the DTE speed (the speed which minicom uses to communicate with your modem) or the line speed (the speed that your modem uses on the line to communicate with the other modem). Notice that the line speed may change during the connection, but you will still only see the initial speed that the modems started the connection with. This is because the modem doesn't tell the program if the speed is changed. Also, to see the line speed, you need to have the modem set to show it in the connect string. Otherwise you will only see 0 as the line speed.

Useful Links

Given below is a list of some useful link to information:

Users

OpenAlchemy is a Free and Open Source Software project
proudly supported by
Geodesic Information Systems Limited

Comments? Feedback? Contact Us.

MediaWiki