Serial Port

From OESF

Revision as of 04:03, 9 July 2007 by Pelrun (Talk | contribs)
Jump to: navigation, search

Copied from the zauruszone wiki

Contents

Zaurus serial port access

The "Sharp I/O" port at the base of the Zaurus is a serial port. It can be accessed from Linux as usual, as /dev/ttyS0.

For a complete specification of the serial interface, see Sharp's hardware document:

http://www.sharp.de/pdat/sio.zip

This link is not broken thanks to smurfix


Accessing /dev/ttyS0

The Z will take it over ttyS0 and try to run pppd on it (this does not apply to the 3.10 version of the Sharp ROM, only the 2.xx versions). In the Sharp ROMs attempts to kill it will cause it to be respawned, as this appears in /etc/inittab. It can also be avoided by rebooting the Z ("reboot" in the terminal window, or use the Shutdown app) and pressing the "/?" key as soon as you see "Wait..." during reboot, and then pressing the "E" key. Of course, you'll need to do this every time you reboot if you don't change /etc/inittab.

The offending line in /etc/inittab is:

pd:5:respawn:/etc/sync/serialctl

Using vi or something to add a pound sign (#) in front of this line disables the respawning. /etc/sync/serialctl is the script that launches pppd - you can also comment out the pppd line here and replace it with something like sleep 36000. You may have to reboot after making this change for it to be effective.

Once the serial port is available you can access the serial port using serial terminal, gps programs, pppd dialing a cell phone (I connect to the 'net with Nextel's phones, Sprint PCS with an LG 5350 and serial module also works), etc. You will need a null modem and gender bender, or a cable mod, to talk to other devices that normally connect to a PC, like modems, GPS receivers, etc.

There is alread a prepararion by Sharp for this, use runlevel 3. Further information at: http://www.sc-systems.com/info/zaurus/notes/Init3Mode.html


If you need to confirm input on the serial port (for instance, testing a serial GPS or phone hookup), issue the following from a command prompt:

 # stty 4800 -F /dev/ttyS0
 # cat /dev/ttyS0

(Note the baud rate may vary depending on the device you are connecting. Also the stty command will have to be issued any time you reboot.) This will show all incoming text on the line. Pressing "Function C" will terminate the output. This data may also be sent to a capture file:

 # cat /dev/ttyS0 > mydata.txt

Buying a serial-to-Sharp cable

The Sharp CE-170TS cable works on the Zaurus. It has electronics in it, not just a pin mapping. The Zaurus end is a large box with a power connection that blocks the keyboard so that it cannot be opened with the cable attached. The box is glued together. Removing the outside of the box is still not enough clearance. If the power connector were desoldered from the internal circuit board then there should be enough clearance (see below.)

This cable comes with a DB-9 female so that it can be plugged into a PC, upon which the Zaurus acts like a DCE (see cable diagram above.) If you want to hook it up to another DCE (such as a modem or GPS receiver) you will need to insert a gender bender (DB9 male-to-male adapter) and a null modem (DB-9 male-to-female adapter that swaps pins to turn a DCE into a DTE or vice versa.) Both of these are available at Radio Shack.

One funny thing about the commercially available Sharp serial cable (part number CE-170TS) when running on the SL-5000D is that even when the Z is off, there is signal on the Z's serial data output line (this would be RxD, or pin 2 on the DB-9 end of Sharp's data cable). Although I have not tested this, it suggests that if you leave the Z plugged into a device, you will eventually drain its battery. It appears that only the serial data output line does this; the other handshake output lines do not do this! SL-5500 owners, is this the same for you?

Note: The Sharp Zaurus and the connector only provides TTL or CMOS voltage and current levels out the serial port. Some equipment requires bipolar (<-3v or >3v) signal levels to be valid, typically for power or a wake up function. (Example: the $99 GPS receiver available at Radio Shack, see below.) Some also require a certain amount of current sourcing or sinking. The Sharp serial connector will NOT work with such devices, since its current output is lower than typical RS-232 and signal low is zero volts rather than a negative voltage.

However, it should work with most devices, since modern RS-232 receiver chips are designed to have a signal low threshold of about 1 volt and a signal high threshold of about 2 volts. This makes the Z's "RS-232" output signal, which swings from 0 to 3.3v (or 0 to 3.3v) work just as well as if it swung from -12V to +12V.


Building a serial-to-Sharp cable

(The Sharp development team says this will be available in early 2002, but in the meantime...)

To go to a standard 9 pin serial such as you would find on a PC you would use the following pin config.

Although the Zaurus is a computer, the Sharp cable, and this diagram, treats it as a DCE rather than DTE (which a PC normally is.)

       Wiring for hookup to a DTE (ie, a PC)
       (Zaurus as DCE) (same as Sharp's CE-170TS)
           Female
           DB-9     Signal name    Signal
           9 pin    (relative      Direction
  zaurus   serial   to PC)    Z (DCE)----- PC (DTE)
  -------------------------------------------------
  3           3      TxD              <-
  4           2      RxD              ->
  5           7      RTS              <-
  6           8      CTS              ->
  7           6      DSR              ->
  8           5      GND              --
  14          4      DTR              <-
 Wiring for hookup to a DCE (ie, a modem or GPS receiver)
 (Zaurus as DTE)
           Male
           DB-9     Signal name    Signal
           9 pin    (relative      Direction
  zaurus   serial   to Z)   Z (DTE)----- modem (DCE)
  -------------------------------------------------
  3           2      RxD              <-
  4           3      TxD              ->
  5           8      CTS              <-
  6           7      RTS              ->
  7           4      DTR              ->
  8           5      GND              --
  14          6      DSR              <-
  • NOTE: The second table was derived from the first, and may contain mistakes. Would the first person making a cable to the second table verify that this table is indeed correct, and if so, delete this note.

The tough part will probably be getting the proprietary connector. You will need part # TCX3106 made by Hosiden Corp http://www.hosiden.co.jp

Their Californian Sales office is +1-408-252-0541 Or if you are feeling particularly resourceful you could 'borrow' the connector from the docking station :-)

(posted by Martin Dorschler) (edited by someone else)


(This appears to be an order page for Japanese products for Zaurus connectivity. Translation via Babelfish.)

http://babelfish.altavista.com/urltrurl?lp=ja_en&url=http%3A%2F%2Fzaurus.spacetown.ne.jp%2Fmi-e21%2Fperipheral%2Fpp-mie21-06.asp%23p4


More on the wiring of Sharp's connector

If you open the Sharp serial connector you will see some circuitry and 8 pins at the bottom. They are from left to right (they are soldered on the top surface so there is no ambiguity). For transmit/receive, it is based on if the Sharp is transmitting or receiving. This is my connector, I can't guarantee the colors or circuit board won't change.

                   Function                  Female DB-9 RS232         Signal
  Color            (relative to Z)           connector pin        Direction
  ------           ------                    ------               ------
  Shield/Black     Shield Ground             Case
  Red              Transmitted Data          2                  from Z
  Yellow           Data Set Ready            4                    to Z
  Blue             Signal Ground             5
   gap for cable
  Brown            Clear To Send             7                    to Z
  Gray             Request To Send           8                  from Z
  Green            Data Terminal Ready       6                  from Z
  White            Received Data             3                    to Z
  • Note: The signal names given in the "Function" column are named relative to the Z, as if it were a PC (aka DTE). However, this cable is designed for connecting the Z to a PC, so it is wired like a modem (aka DCE). You might want to reference the wiring tables in the preceding section.

Ring Indicator and Carrier Detect are the other two pins on the connector and aren't used or provided by the Sharp.

To create a cable that looks like a PC, use a male connector and swap the following pairs of pins:

  2,3  4,6  7,8

You can buy one of the above connectors and cut the female end up and solder the appropriate wires, but then you won't need a null modem connector for a GPS.


Keyboard and Serial at the same time:

If you crack the CE-170TS (above) connector box open (you can do so by carefully inserting a blade to the left of the cable entry, with the cable facing you and the SHARP logo facing up), and desolder the power connector and put electrical tape over the circuit board (and do something so the wires won't break), you will be able to open your keyboard again with this modified connector attached ...and even plug in the power connector, but it will push up on the modified board as it just overlaps the power connector.

However, a little more time spent with a dremel tool and a glue gun, can make this into a really nice connector. After desoldering the power connector you can remove excess material from the top and bottom halves of the box with the dremel so that they can be reused as a cover and still clear the keyboard. You will also need to expand the cable hole and trim the strain relief to make it fit when the halves are clamped together. Squirt some hot glue in there and clamp the parts together for a few minutes and you'll have a nice connector that looks like it came from the factory.

You will lose the ability to power the Z, unless you reuse the power connector. For my cable, before I glued it together, I drilled an extra hole in the bottom half of the serial cable box. I threaded a two-conductor jacketed audio cable through this hole, and soldered one side to the old power adapter power solder pads. On the other end I slipped a sleeve for an audio jack (Radio Shack, toss the jack) over the wire, then soldered on power connector. I trimmed the power connector's tabs a tad so it would fit in the sleeve, then put a shot of glue into the sleeve and shoved the connector in afterwards.

The result is a serial cable that I can attach to my cell phone to get email, enter the commands to start the PPP session on the keyboard, and charge the unit at the same time, that doesn't look like a hack job.

If you can't solder tiny wires, don't attempt this, as the wires inside break easily from their connection points.

Another way of keeping power available is to carefully desolder the socket for the power and run some wires between the now desoldered connector and the circuit board. You should probably enclose the power socket with electrical tape or heat shrink and do whatever else necessary to prevent short circuits. The only two wires that matter are the lower left two - the two nearest the cable, i.e.

Z     X
+-------+
|       |  <- socket opening
+-------+
A B   X

Run wires to reconnect A and B. X seems to only be used to hold the socket down, and Z is like a switch - no plug, and A connects to Z, which I think would be used if power was not connected, but doesn't appear to affect anything.

Note any of this will void the serial connector warranty and maybe the sharp warranty (especially if you blow it up while trying to find a new place for the power connector so you can still charge the unit while cabled up!)


Keyboard and Serial at the same time (another option):

You can open the USB cradle and pull out the electronics these can then function as an extension for the docking connector. This extension does not block the keyboard!


serialio.com are soon (Oct 2002) to start selling a null modem cable with a male socket (for connecting peripherals to the Zaurus), and a profile flat enough to allow the keyboard to open.

http://www.sc-systems.com/products/adaptors/sioCableZaurus.htm


Getting off the topic - uses of the serial port

Using the Radio Shack $99 !DigiTraveler (PC edition)

Note: much of the weirdness discovered during this adventure has been documented above.

Walking into the Rat Shack one day I discovered the Radio Shack's !DigiTraveler, a $99 GPS receiver with no display that hooks up to your laptop. It came with !DeLorme software, which made it a better deal than when !DeLorme offered a similar packet with their !EarthMate or !TripMate receivers. Better yet, the Rat Shack model outputs NMEA using a serial cable, instead of Rockwell Binary, so it will work with more apps! I had been looking for a battery box to bolt onto a ETAK Rockwell Binary receiver I had for a number of years, and not relishing having to build a Rockwell Binary decoder (kind of dead-end) I jumped on the Rat Shack model.

The DigiTraveler runs on 3 AAA batteries for, it claims, 12 hours. When hooked to a PC it uses the PC's TxD line (from PC) to detect whether or not it is connected to the PC, and turns itself on.

So I grabbed my combo null-modem-gender-bender connector, downloaded and installed zgps, rebooted and did the / - 3 dance (see above for all this) AND...

The Rat Shack receiver turned ON when the Z was OFF, and turned OFF when zgps was started.

Further investigation revealed that the Z was outputting 3.3 volts on its transmit data line when it was powered off or when the serial port was not in use, and 0 volts when the serial port was active. This is kind of whacked. (See 'Buying a serial-to-Sharp cable', above.)

Unfortnately, the DigiTraveler turns off when it sees zero voltage on this line. So it worked opposite to what it should have, thanks to the Z's serial weirdness. (I have seen this on two SL-5000Ds.)

To fix this, I took an old serial mouse from my junk box and whacked the cord off it. (This is not an ideal solution since I still needed the null-modem-gender-bender when I was done. However, I was experimenting, and ultimately I will whack one of the Sharp cables and stick an RJ-11 jack on the DB9 end and dedicate it to this receiver. Anyhow, back to the story.) This particular cable had four wires running to DB9 pins 2, 3, 5 and 7.

Since the handshake signals output by the Z actually work properly (opposite of the transmit data output signal from the Z) I cut the wire leading from pin 2 and used the wire from pin 7 instead, and crimped an RJ-11 jack onto the end. (The DigiTraveler has an RJ-11 jack on it for the serial connection.) This worked!

The final wiring (requiring the null-modem-gender-bender connector) looks like this:

     +---------+   <- RJ-11, as viewed from the front (non-cable) end
     |         |
     |      ---
  +--|      ---  pin 5 ---- female DB-9 pin 5
  |  |      ---
  |  |      ---  pin 3 ---- female DB-9 pin 7
  +--|      ---  pin 2 ---- female DB-9 pin 2
     |      ---
     |         |
     +---------+

(If you want to use a male DB-9 instead, and avoid using a null-modem-gender-bender, then running RJ-11 pin 2 to male DB-9 pin 3, RJ-11 pin 3 to DB-9 pin 8, and RJ-11 pin 5 to DB-9 pin 5 should do the trick.)

On the positive side, leaving the GPS receiver attached to the Z will probably not drain the Z's battery since the Z's transmit data signal output line is no longer connected to anything. (Again, see 'Buying a serial-to-Sharp cable' for why this matters.)

Why use a serial GPS receiver like this instead of a CF-card GPS receiver? Because it was there. (Also, my project calls for the use of an 802.11 card in the CF slot.)

As far as this receiver is concerned, I cannot say how good it is. I just gotten it working. It attempted its first fix with the assumption that it was located somewhere in Asia, which probably slowed down this first fix. However, after leaving it "off" for about half an hour, and plugging it back in, it seemed to remember where it was, and also seems to store an almanac. I would bet this is forgotten when the batteries are pulled. I'll either post more later, or let someone else add to this.

--- Added 10/16/03 Five Star Associates offers this cable on it's website http://www.fivestarassoc.com/Z/index.html

--- Added 12/07/2003 If you are building your own cable to go directly from the Zaurus 5500 serial port to the DigiTraveler, the following pinout was tested successfully with zGPS and zRoadmap.

GPS <==> Zaurus

2         4
3         9
5         8

A signal is present on pin 9 whenever the Zaurus is powered on.

Pin 1 on the Zaurus is on the left when the screen is face-up and the serial connector is towards you.

Pin 1 on the DigiTraveler is opposite the power connector.


Using a Nextel i88s cell phone as a GPS receiver with a Zaurus

Compared to the DigiTraveler, this one is a no-brainer. Follow the directions near the top of this page for accessing ttyS0. Download something like zgps to talk to the receiver. Get yourself a serial data cable for the i88s, and a null-modem and gender-bender (male-male DB9.) Hook it all together. Start zgps. (You might want to extend the Z's power-off timeout, or plug it in, so it does not shut down while in use, see below.) Then go into the GPS menu of the i88s, select Interface, and turn it on. If you have a Nextel Online, two-way data, or Powerapps or Packetstream data plan, and hold the unit upside down in an open area, you should get a fairly quick first fix, and pretty reliable fixes afterwards.

This handset is currently on sale at www.nextel.com for $99 so it costs the same as the DigiTraveler, and seems to be a better receiver. It does not come with map software, but it is a cell phone! (You will need service to be able to access the GPS menu.)

The phone is pretty aggressive about turning off the NMEA interface when the Z is detached or powers off, apparently to save power. You may have to turn the phone's GPS interface back on (it may still show up as being ON in the user interface, but if nothing is happening, it could very well have been turned off.)

This is a J2ME phone, and MIDlets can read/write to the serial port, so you can write apps that run in the phone and talk to the Z. I also use it as a modem for my Z. A dial string of ATDTS=2 makes the phone start spitting out PPP, so after chat issues ATDTS=2 and I get a CONNECT, pppd takes over, gets the IP address and DNS addresses from the phone, and with that I'm able to use Opera and Qtmail (and other stuff.)


Hooking a Stowaway or Palm Portable Keyboard to your Zaurus

Since it uses the serial port, here is a link to a small work in progress making a Palm Vx Portable Keyboard (aka Stowaway) work on a Zaurus. If you are interested in making this happen, please help. This link will be moved to somewhere more appropriate when the project is closer to completion: Palm Portable Keyboard for Zaurus


You're right. On all the laptops, PC's, and PDA's that we tested against, the PC's TXD would be either positive or negative, but not 0 volts. That's why we put the "port detect" circuit in. Sorry you had to cut up a cable to get it to work. As to the first fix time (cold start), it does assume that it's in Tokyo at first, since it's a Sony baseband. It doesn't affect cold start times, however, because the unit always starts up in "skysearch" mode, which means it will look for any satellite it can find. After the unit aquires a fix, it will save the ephemeris data, and start downloading the almanac. The almanac download takes about 10 minutes. The batteries keep this data intact. If you have valid ephemeris data, the fix time should be under 20 seconds (hot start). Ephemeris data is only good for about 4 hours. If the ephemeris data is obsolete, then the almanac is used, which is good for about 6 months. Then your fix time will be around 45 seconds.


I tried to connect a SLC700 to my sprint phone yesterday, using the CE-170TS, and it looks like the same problem as the radioshack GPS story above. The zaurus connected to the serial port on the computer works fine, as does connecting the phone to the computer. However, when trying to connect the zaurus to the phone with a null modem/gender changer, a whole lot of nothing happens. Stay tuned for more details.


On the C700, a GPS can go into the sound input (left, or the "tip" of a stereo phone plug). Since it can do 48kHz sampling, the standard 4800 baud will have one bit be 10 samples (9600 would be 5), and it isn't difficult to write a software receive UART for /dev/dsp. This leaves the real serial port free.

Personal tools