Linux to Windows CE Connection

It took me a little while to figure out how to setup Linux and my H/PC to talk to each other, so I thought I'd put up some info about what I had to do from the perspective of a fairly new Linux user (installed my first distribution in August of 1998 and have loved every minute of it).

At the time of writing this, I was running Red Hat 5.2 (kernel 2.0.36). The H/PC I was using was a Phenom Express and occasionally a HP 320LX which were connected to COM2 (Linux equivalent is /dev/ttyS1). I used getty to initiate my login and then I manually started the PPP connection (using pppd) using a shell script so I didn't have to type so much. Once I was connected I would either start the ftp server on my Phenom and use ncftp to transfer files, or use ScottyFTP on my H/PC to transfer files. You could also use Netscape to transfer file from the H/PC to the desktop. The following screen shots show Netscape connected to my H/PC (62k) and the nxterm window (22k) showing the results of pinging the H/PC.

I would recommend reading the documentation and man pages for pppd, getty, (or mgetty) init, the Linux PPP Howto, and the Serial Howto. You might also want to check out another program called mgetty (it has the ability to start pppd automatically, but seems to be a bit more complicated than getty). I'd also recommend checking out the Connect WinCE to Linux Mini-Howto that was posted to comp.sys.palmtops and comp.os.linux.misc (do a Dejanews search). Also be sure to make backup copies of any files that you are going to modify just in case something goes wrong.

The WinCE Side of the Work

Disable 'Allow connection with desktop...' in the Communications Properties in the Control Panel. Make a new connection in Remote Networking (dial-up connection, not direct connection). Select 'Hayes Compatible on COM1,' and then 'Configure...' with the following properites: manual dial, 115200 baud, 8-N-1, hardware flow control. Make sure that there is nothing checked on the 'Call Options' page. The default TCP/IP setting should work (server assigned IP and DNS addresses). For the phone number to dial, I selected 'Force Local' and just entered '1' for the phone number.

The Linux Side of the Work

This is a little more complicated. In my /etc/inittab file I added the lines:

# Added for Windows CE ppp connection on COM2
s1:2345:respawn:/sbin/getty ttyS1 115200

Save the file and then restart init by typing in a shell window:

init 2; sleep 5; init 3

Create a shell script to start pppd. You don't have to do this if you really enjoy typing. In the below script the '192.168.55.1:192.168.55.2' section is the [Linux IP address]:[Windows CE IP address]. Read the PPP Howto to find out what numbers you can use for different situations. My script looks like this (for the bash shell):

#!/bin/sh
# pppd script for Windows CE ppp connection on COM2

pppd -detach crtscts lock 192.168.55.1:192.168.55.2 /dev/ttyS1 115200 &

Save your script, make sure it's in a location defined by your PATH, and make sure you have execution rights on the script. I then added the H/PC to the Hosts section of Network Configurator (as root in Red Hat type netcfg & or edit the file /etc/hosts). Add the IP address for the H/PC (192.168.55.2 in my case), the name (phenom.localhost in my case), and a nickname (phenom in my case). This will let you connect to the H/PC by using the nickname rather than typing in the IP address all the time.

Software

As far as software to transfer files back and forth between the H/PC and the desktop, there are two different ways you can approach this. The first is using an ftp server on the H/PC and an ftp client on the desktop. There is an ftp server for Windows CE available at places like www.cemonster.com or www.wincecity.com, in the Internet software section. I've used ftp and ncftp on the desktop to send files to the H/PC. The second way, and the way I'm doing it, is to run an ftp server on the desktop and use an ftp client on the H/PC. I'm using ScottyFTP on my Phenom and wu-ftpd on the desktop and it works very well. wu-ftpd was included on my Red Hat disk and is available from their ftp site, and probably many others as well. No matter which way you do it, make sure that the file transfer is set to BINARY mode. Some files can be transferred using ASCII, but others cannot (like database backup files and compressed files).

Other software that will come in handy is vxUtil (free from www.cam.com for ping, etc.), fftp (ftp), and ftnet (telnet) from www.cemonster.com or www.wincecity.com. Both fftp and ftnet need the program 'console' available at the same sites. If you want to backup the system databases, get one of the many programs that will backup the databases as a single file and then send that file to the desktop.

Talkie Talkie

Now for the fun part. Connect your H/PC to COM2 on the Linux PC. Double click the connection you made in Remote Networking. You don't need to add any info for user name or password yet. Click 'Connect' and a term window will show up with a login prompt from Linux. Enter the needed info. You should see a command line now. Start pppd on the PC by executing the above script. On the H/PC click FILE -> CONTINUE. You should now be connected. To test the connection ping the H/PC from the PC using the H/PC's address (192.168.55.2 in this case) or by name. Now that you're connected, start the ftp server on the H/PC and point Netscape to the H/PC (by name or address). Pretty cool, huh?

Issues

If you don't know about shell scripts, paths, or how to change permissions (chmod), you really should read up on it by going to The Linux Documentation Project and reading The Linux Users' Guide, The Linux Installation and Getting Started Guide, and The System Administrators' Guide.

One problem you may run into is that you can't run pppd unless you have root access. To solve this the pppd program needs to be setuid root. You should be aware that setting a program to setuid root has the potential to open up your system to security risks that won't be discussed here. As root, type:

chmod u+s /usr/sbin/pppd

You also need to check to see if you have the various configuration files needed. Read the getty (or mgetty) man page to find out what you need and where is should be. In my case, I didn't have to do anything as it was already setup. Yours probably is already setup also.

In the case of connecting your H/PC to COM1, in the inittab line change 's1' to 's0' and change any references to 'ttyS1' to 'ttyS0'.

You may have to change the connection speed to get a good connection on a slower unit. When connecting my HP 320LX to Linux using the settings above, I would connect, but wouldn't be able telnet or ftp in. I changed the connect speed on the unit to 57600 and did the same with the the line in my /etc/inittab file and the ppp script. Works great.