10. Serial Connections and PPP

Both hardwire and infrared serial ports work fine on the 5MX in linux. This section describes how to use them, and how to set up PPP connections with them.

Some distributions come with gsmlib, that allows you to send SMS and manipulate your cell phone phone book. For more information about gsmlib see: http://www.pxh.de/fs/gsmlib/.

The 5MX serial ports are /dev/ttyAM0 (IRDA) and /dev/ttyAM1 (hard wire). If these special files do not exist on your system then:

   mknod /dev/ttyAM0 c 204 16    [ IRDA serial port ]
   mknod /dev/ttyAM1 c 204 17    [ regular serial port ]
will make them.

10.1. Serial Connection: Wire

Connections to both a modem using PPP, or to the desktop computer using minicom, seem to work fine (115200 baud). The serial port is /dev/ttyAM1; it works just like any other serial port. Use minicom to debug serial connections.

In order to make it easy to connect the 5MX to the desktop, the Psion serial cable is a null-modem cable. This means that to connect other serial devices (GPS, modems), a null-modem adapter is required. See the netBook HOWTO for a discussion.

Although the 5MX is specified to support speeds to 115200 baud, in reality speeds of 230400 baud can be obtained. However, the serial ports on most computer motherboards only support 115200 baud. Generally, an external serial port such as USB or PCMCIA must be used to obtain a 230400 baud connection to the 5MX. Fast Connection to Windows describes how to do it with windoze.

10.2. Serial Connection: Infrared/IRDA

The IR serial port also works; one can communicate back and forth via minicom, and set up a PPP connection over this port to e.g., a notebook computer. You can then rcp files back and forth out of thin air! Woohoo!

With a Debian distribution, you can just install the irda-utils package to get all you need for irda. Edit the /etc/default/irda-utils configuration file (enable irattach, enable discovery, use device /dev/ttyAM0), and then execute /etc/init.d/irda-utils start and /etc/init.d/irda-utils stop to start and stop irda.

More primitively, to enable the infrared connection, one executes irattach /dev/ttyAM0 -s 1 on the psion, and irattach /dev/ttyS1 -s 1 on the other machine (if ttyS1 was recognized at boot up of the notebook computer as the IR device). There is also likely to be a /etc/init.d/irda startup script on the notebook computer that you could use. The -s 1 flag enables system logging.

Even though ttyAM0 or ttyS1 are used to make the IR attachment, /dev/ircomm0 is still the serial port to use on either notebook computer or psion. The command irdadump, which is a standard tool, can help in debugging the connection - it will show, at the lowest level, when or if the remote IR signal is picked up or not.

NOTE: the use of IRDA is meant to consume a considerable amount of power; turn it off by killing the irattach process when it is not in use.

For real amusement, it may be possible that the IR and normal serial connections can be bound together as one in order to double the bandwidth of the serial connection. See the IR HOWTO (and let us know if you got this to work!).

10.3. Running Getty's

The serial connections, PPP, and rsh involve running a getty on the serial ports, either on the notebook or on the psion. getty 115200 /dev/ttyAM1 or getty 115200 /dev/ircomm0 on the psion, or agetty 115200 /dev/ttyS0 or agetty 115200 /dev/ircomm0 on the remote computer. These getty's are probably best started up in the /etc/inittab file, because they need to be "respawned". You can restart init so that it rereads this file without rebooting by init q.

10.4. Setting up PPP

This subsection contains two sub-subsections on

1. Connecting the Psion to the Desktop.

2. Connecting the Psion to the Internet Using an External Modem.

Refer to the Linux PPP howto: http://www.linux.org/docs/ldp/howto/PPP-HOWTO/index.html.

10.4.1. Connecting the Psion to the Desktop

As an example, PPP can be configured with telnetd. However, rsh (ssh) may be preferable to telnet, because then you can efficiently copy things between the psion and desktop using rcp (ssh). Install the rsh (ssh) client and servers if you want rsh (ssh); rsh is somewhat preferable to ssh for psion-computer connections because it does not have the overhead of ssh encryption. [NOTE: installing packages with shells, daemons and so on with dpkg, will sometimes make a directory /etc/pam.d. If you have disabled passwords on your system, you must delete this directory; if it exists you will not be able to login!! If you forget and find yourself unable to login, boot to single user mode and delete the pam.d directory.]

To connect your Psion to your computer:

Have something like this for the /etc/ppp/options file on the Psion:

-detach
defaultroute
noauth
nocrtscts
lock
lcp-echo-interval 5
lcp-echo-failure 3
/dev/ttyAM1
115200
(or use /dev/ircomm0 for IRDA)

Then add the ppp user to your Psion's /etc/passwd file:

echo "ppp:*:101:101:PPP User:/etc/ppp:/usr/sbin/pppd" >> /etc/passwd
And make sure pppd is executable for user ppp:
chmod a+x /etc/sbin/pppd

To get telnetd running, add the required entry to the /etc/passwd file:

echo "telnetd:*:101:101::/usr/lib/telnetd:/bin/false" >> /etc/passwd 
Then add the telnetd entry to the /etc/inetd.conf file:
echo "telnet stream tcp nowait telnetd.telnetd  /usr/sbin/tcpd  \
               /usr/sbin/in.telnetd" >> /etc/inetd.conf

You will need to run a getty on e.g., /dev/ttyAM1 to enable logins to the Psion by telnet or ppp. The getty gives you the login prompt when you connect over the serial port. The command getty 115200 /dev/ttyAM1 - or /dev/ircomm0 - will start a getty on the serial port. It may be preferrable to start the getty on the serial port in the /etc/inittab file.

Finally add your computer's PPP IP address to /etc/hosts on the Psion to make telnet login happen faster:

echo "# This makes the telnet login to psion faster
 192.168.1.100   gateway" >> /etc/hosts

On your desktop computer have something like this for a /etc/ppp/peers/psion file:

-detach
noauth
nocrtscts
lock
local
connect '/usr/sbin/chat -v -t3 ogin--ogin: ppp'
/dev/ttyS0
115200
192.168.1.100:192.168.1.101

Then just type pppd call psion on your computer to connect to Psion. [You may prefer to start up the ppp connection from the psion, rather than from the desktop computer - but that might not be a security risk you want to take.]

To access the internet from your Psion through the desktop computer, you need to add routing, masquerading, and NAT [I don't know what these are either...but it works, so who am I to complain?] to your desktop:

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE
then you can browse the internet from your psion using dillo or lynx. Be aware that your desktop kernel must be compiled to support these things; default RedHat kernels support this. You may also have to disable, or otherwise configure, your firewall for this to work properly.

10.4.2. Connecting the Psion to the Internet Using an External Modem

Either a standard external modem (with null-modem adapter) or an external infrared modem (e.g., Psion's nifty external travel modem - the Diamond Mako travel modems are apparently identical to the Psion travel modems) will work for using your psion to connect to the internet over the telephone lines. You might be able to pick up an infrared Psion (or Diamond Mako) travel modem from ebay.com for cheap; it works just fine in OpenPsion with very little fuss once IRDA is working - relink /dev/modem to /dev/ircomm0 and use baud rate 115200.

With its installation via dpkg (or ipkg?), PPP is pretty much all set up and ready to go with an external telephone modem. Edit the files /etc/chatscripts/provider, /etc/ppp/peers/provider, and /etc/ppp/pap-secrets to include your own ppp information, or just run the script pppconfig, which should come with PPP. PPP is started and stopped using pon and poff. (I made a script "ppp-on" that starts pon, dumps its messages to /dev/null, and puts it in the background.) You may also need to modify the /etc/resolv.conf file, to give your nameserver IP numbers (but this is unlikely).