[net.micro.amiga] AEGIS DRAW / AMIGA / APPLE PLOTTER

star@fluke.UUCP (David Whitlock) (06/13/86)

Hope some of you RS-232 GURU's out their can help me with this small problem.

I am trying to get Aegis Draw to talk to an Apple 4 Color/Pen Plotter.

According to Apple, this plotter supports hardware handshaking only.

	Current configuration is as follows


		1-------------------------1
		2-------------------------3
		3-------------------------2
		5-------------------------20
	       20-------------------------5
		7-------------------------7

Pin 20 is the DTE line which according to Apple goes to the "Computer"

I am assuming that this only requires it to be hooked up to pin 5 CTS on the
Amiga.  I assumed wrong.  No hardware handshaking transpires.

Aegis Draw uses 'COPY' to copy its ASCII plot file to port 'prt:' using
the 'Custom'/'Generic' printer driver.

I guess my question is... Have I wired the RS-232 Cable correctly.  Does
the Amiga sence a toggling signal on pin 5 for the equivalent of hardware
xon/xoff.  Does the Custom/Generic printer driver cause COPY to sence hardware
handshaking.  Where am I going wrong!!

Any help will be greatly appreciated.


-- 
Dave Whitlock

        {decvax!microsof,uw-beaver,ssc-vax,allegra,lbl-csam}!fluke!star

--John Fluke Mfg. Co., 33031 Schoolcraft Road, Livonia, MI 48150

carolyn@cbmvax.cbm.UUCP (Carolyn Scheppner) (06/16/86)

In article <3311@vax4.fluke.UUCP> star@fluke.UUCP (David Whitlock) writes:
>Hope some of you RS-232 GURU's out their can help me with this small problem.
>I am trying to get Aegis Draw to talk to an Apple 4 Color/Pen Plotter.
>According to Apple, this plotter supports hardware handshaking only.
>
>	Current configuration is as follows
>
>
>		1-------------------------1
>		2-------------------------3
>		3-------------------------2
>		5-------------------------20
>	       20-------------------------5
>		7-------------------------7
>
>Pin 20 is the DTE line which according to Apple goes to the "Computer"
>
>I am assuming that this only requires it to be hooked up to pin 5 CTS on the
>Amiga.  I assumed wrong.  No hardware handshaking transpires.
>

   What follows are hardware/software instructions for hardware handshaking
for Amiga<>PC.  Hopefully, the same cabling and setup can be used with
your plotter.

   I have attached the C source for SetSerial to the end of this message.

( Thanks to Tom Pohorsky for information reposted here)

Carolyn Scheppner  --- Commodore-Amiga Technical Support


-------------------------------------------------------------------------------
  I'm "enclosing" my memo on serial downloads from IBM PC's. Note:
- this is in the latest documentation on IBM cross-development
- be sure the user has a "7-wire" RS-232 cable (i.e. supprots the DTR,
  DSR,RTS,and CTS lines) this is explained below.
- IBM, unlike the Mac, Amiga, and most others, does NOT support proper
  xon/xoff hanshaking, thus the use of "hardware" handshaking.



soooooo,


     Here's the pin connections for IBM-Amiga serial communication,
but first a couple notes:

     1. You'll want to disable xON/xOFF handshaking, or else x11's
        and x13's will be misinterpreted as flow control. To do this
        set the high order bit of io_SerFlags. To do THAT, type:
           setserial 10 x84
        That will disable xControl, and enable RTS/CTS handshaking.
        Note that setserial uses shared access, causing bit 5 of
        io_SerFlags to be "look like it's always on" for setserial.

     2. Similarly on the IBM side, one needs to run the "MODE"
        command for proper setup. Type:
           MODE com1:<baud>,N,,1,P
        where:
        com1:    is the usually the serial port (may vary per hardware)
        <baud>   set to same as Amiga, 19200 if practical.
        N        no parity
        ,,       defaults to 8 data bits, 7 prob'ly ok.
        1        1 stop bit
        P        VERY IMPORTANT. The "P" option is usually for talking
                 to printers, but MUST be used (for flow control).


                *****  Cabling Requirements  *****

                          Amiga  IBM
  
           frame ground     1  -  1   frame ground
           Transmit data    2  -  3   Receive data
           Receive data     3  -  2   Transmit data
           Request To Send  4  -  5   Clear To Send
           Clear To Send    5  -  4   Request To Send
           Data Set Ready   6  - 20   Data Terminal Ready
           Data Term Ready 20  -  6   Data Set Ready
           system ground    7  -  7   system ground



  ... or, in a nut shell, put 1 and 7 straight across, swap 2 and 3,
      swap 4 and 5, and swap 6 and 20.

  Note that this is the "standard" RS232-C cable. Note also that
this may vary for different manufacturer's serial cards. If there
is a problem, one can find the Amiga serial pin-out in Appendix E
of the hardware manual. Consult the proper info for the IBM side.
It's not uncommon that pin 8 (Carrier Detect) needs to be tied low
on the IBM side.

***********************************************************************



Setserial is actually sort of self-documenting. typing "setserial"
will produce a little message on the use of the arguments. typing
"setserial 0" will list the all the parameters: their name and current
value. some of the parameters will require reference to the header file
serial.h, which is in the rom manual. this will explain the bit assignments
for io_SerFlags, for example, such as which bit to set to disable
xon/off handshaking.

-----------------SetSerial.c   CUT HERE------------------------------------


/* SetSerial allows the CLI user to dynamically change any particular
 * serial port parameter.
 *
 * July 6, 1985  Version 1.0  Keith Stobie  Initial version 
 * July 7, 1985  Version 2.0  Keith Stobie  Converted to Lattice
 * July 8, 1985  Version 3.0  Keith Stobie  Both term words settable.
 * Sep 25, 1985  Version 3.1  Tom Pohorsky  Remove WBufLen
 * Nov  9, 1985  Version 3.2  Tom Pohorsky  Cleanup
 */
char *prog_name;            /* Name of program being run */
char *prog_version = "3.2"; /* Version of the program */

#include        <exec/types.h>
#include        <exec/nodes.h>
#include        <exec/lists.h>
#include        <exec/memory.h>
#include        <exec/ports.h>
#include        <exec/libraries.h>
#include        <exec/devices.h>
#include        <exec/tasks.h>
#include        <exec/io.h>
#include        <devices/serial.h>
#undef NULL
#include        <lattice/stdio.h>


extern struct MsgPort *CreatePort();

int set_serial( index, value )
   int   index;         /* which parameter to set */
   ULONG value;      /* The new value for paramter */
{
    struct IOExtSer IORser;      /* Serial port IO request block */
    int     error;

    if ((index < 0) || (index > 11)) {
       printf( "Index value %ld is not in range 0-10!\n", index );    
       return 20;
    }

    IORser.io_SerFlags |= SERF_SHARED;
    if ((error = OpenDevice (SERIALNAME, 0, &IORser, 0)) != 0) {
        printf( "Unable to open Serial Device, error=%ld\n", error );
        return 20;
    }

    IORser.IOSer.io_Command = SDCMD_QUERY;
    if ((error = DoIO( &IORser ) != 0)) {
        printf ( "Query status error %ld\n", error);
        return 20;
    }

    /* SET UP the read message port in the I/O request */
    if ((IORser.IOSer.io_Message.mn_ReplyPort = CreatePort( "SetSerial", 0 ))
         == NULL) {
        printf( "Unable to create port for IO message\n" );
        CloseDevice( &IORser );
        return 20;
      }

    switch( index ) {
      case 0:    print_request( &IORser );         break;
      case 1:    IORser.io_CtlChar       = value;  break;
      case 2:    IORser.io_RBufLen       = value;  break;
      case 3:    IORser.io_Baud          = value;  break;
      case 4:    IORser.io_BrkTime       = value;  break;
      case 5:    IORser.io_TermArray.TermArray0 = value; break;
      case 6:    IORser.io_TermArray.TermArray1 = value; break;
      case 7:    IORser.io_ReadLen       = value;  break;
      case 8:    IORser.io_WriteLen      = value;  break;
      case 9:    IORser.io_StopBits      = value;  break;
      case 10:   IORser.io_SerFlags      = value;  break;
      default:   printf( "Internal Logic error! case value %ld\n", index );
    } /* switch */

    IORser.IOSer.io_Command = SDCMD_SETPARAMS;

    error = DoIO( &IORser );

    DeletePort( IORser.IOSer.io_Message.mn_ReplyPort );

    CloseDevice( &IORser );

    if (error) {
       printf( "Error %ld doing IO to set params!\n", error );
       return 10;
    }
      
    if (IORser.IOSer.io_Error) {
       printf( "Error %ld from serial device doing set params!\n"
             , IORser.IOSer.io_Error );
       return 10;
    }

    return 0;
}  /* set_serial() */




print_request( IORser )
    struct IOExtSer *IORser;     /* Serial port IO request block */
{
#define PRINT( field )           printf( "      %s = %8lx %8ld\n" \
                                 , "field", (ULONG) IORser->field \
                                 , (ULONG) IORser->field )
#define IPRINT( index, field ) printf( " %2ld   %s = %8lx %8ld\n" \
                                    , index, "field", (ULONG) IORser->field \
                                                    , (ULONG) IORser->field )

      printf( "index field name       hexadec  decimal\n" ); 
      IPRINT( 1, io_CtlChar   );
      IPRINT( 2, io_RBufLen   );
      IPRINT( 3, io_Baud      );
      IPRINT( 4, io_BrkTime   ); 
      IPRINT( 5, io_TermArray.TermArray0   );
      IPRINT( 6, io_TermArray.TermArray1   );
      IPRINT( 7, io_ReadLen   );
      IPRINT( 8, io_WriteLen  );
      IPRINT( 9, io_StopBits  );
      IPRINT(10, io_SerFlags  );
      printf( "\n" );   /* Not associated with an index */
          PRINT( io_Status    );
}  /* print_request() */


print_usage() {
   printf("%s: version %s\n", prog_name, prog_version );
   printf("usage: %s <index> <value>\n", prog_name );
   printf("  <index> is a decimal number indicating which parameter.\n" );
   printf("          0 indicates print current values (and indexes) \n");
   printf("            without changing them.\n" );
   printf("  <value> number to set the indexed parameter to.\n");
   printf("          value should be in decimal unless it starts with X\n" );
   printf("          or x in which case the number should be hexadecimal\n");
   exit( 5 );
}





main( argc, argv ) 
   int argc;
   char *argv[];
{
   int   index;
   ULONG value;

   if (argc <=0 ) { prog_name = "SetSerial"; }
   else { prog_name = argv[0];}

   if (argc == 1) { print_usage(); }

   if (argc < 2 ) { printf( "Too few parameters\n" ); print_usage();}
   if (argc > 3 ) { printf( "Too many parameters\n" ); print_usage();}

   sscanf( *++argv, "%d", &index );

   if ((index != 0) && (argc < 3)) {
      printf( "Too few parameters\n" ); print_usage();
   }

   if (argc == 3) { 
      ++argv;
      if ((*argv[0] == 'x') || (*argv[0] == 'X')) {
         sscanf( *argv+1, "%x", &value ); /* Skip x or X */
      } else {
         sscanf( *argv, "%d", &value );
      }
   }

   exit( set_serial( index, value ) ); 
   
}  /* main() */
-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Carolyn Scheppner -- CBM   >>Amiga Technical Support<<
                     UUCP  ...{allegra,caip,ihnp4,seismo}!cbmvax!carolyn 
                     PHONE 215-431-9180
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

hull@haouucp.UUCP (Howard Hull) (06/18/86)

Outlined below is the RS232 handshaking sequence, followed by a diagram of a
full null modem cable for connecting a terminal and a printer.  It is normally
assumed that the computer is DTE (Data Terminal Equipment) and that the device
at the other end of the cable is DCE (Data Communications Equipment), i.e., a
modem.  Usually with a computer and a printer such is not the case, and that
is why one needs a null modem cable.  However, be warned: one frequently finds
that the printer output RS232 connectors on CRT terminals, for instance, are
wired as DCE devices so that a null modem cable is not desired.  The problem
becomes one of discovering how the computer manufacturer wired his RS232 port.
Was it wired as one would wire a terminal, or was it wired as one would wire a
modem?  The same problem exists for the printer.  It has been done in every
possible combination by someone at some time.  Recently the standard seems to
be to wire everything except modems as DTE.  If that is done, then a printer
cable needs to be a null modem cable.  Next, there is the matter of the group
of handshaking sequence.

Pin #	Signal Name			Description

 1	Protective ground		(mutual)
 2	Transmit Data (TD)		(from T to M)
 3	Receive Data (RD)		(from M to T)
 4	Request to Send	(RTS)		(from T to M)
 5	Clear to Send (CTS)		(from M to T)
 6	Data Set Ready (DSR)		(from M to T)
 7	Signal Ground			(mutual)
 8	Carrier Detect (CD)		(from M to T)
20	Data Terminal Ready (DTR)	(from T to M)
22	Ring Indicator		(from M to T)

Notes:	The "from" device asserts the signal.
	The "to" device reads the signal.
	Data Terminal "T" is the computer or a crt terminal (DTE).
	Data Set "M" is a modem, or a null-modem to a terminal (DCE).

	The RS232 standard lists a half-dozen or so handshaking methods.
The most complex protocol is used from DTE to DCE to switched telephone
network to DCE to DTE.  In this case, the switched network must be induced
to connect before the DTE/DCE path can be initialized.  In such a case,
the first signals exchanged are those associated with the readyness of the
DTE/DCE combination of each end of the switched network.  For the pure
example, at power-up, Each assumes it is an answering station unless set
otherwise; the DTE asserts DTR.  (The DTE may at its discretion assert
RTS and the DCE may initiate an ASCII task request protocol.)  After a
time, one of the DTE's is programed to make a call.


The call is initiated by the calling DTE holding or setting DTR as is
appropriate, followed by holding or assertion of RTS and delivery of the
ASCII calling instructions, if appropriate, or waiting for the operator
to dial the call and put the DCE on the line.  The call placing sequence
involves taking the line off-hook, determining that there is a dial tone,
dialing the number, connecting the DCE to the line, and then issuing DSR.
Nothing then happens until the phone rings at the called site, where the
DCE then asserts RI to let the called DTE know that the phone is ringing.
The called DTE then responds by holding or asserting DTR, as appropriate. 
The called DCE responds by asserting off-hook to the switched network,
effectively answering the call and then placing the answer tone on the line.
The calling DCE then asserts the originate tone.  Some timing pulses are
exchanged by the DCE's, and then they together assert CD (carrier detect,
or what is in the standard named the "Received Line Signal Detector").
This completes what is known as the Group 1 transaction.

For the Group 2 transaction, each end conditions itself to handle data.
At the calling end, the DTE response is to hold or set RTS, and the DCE
responds with CTS.  At the called end, the DCE sets CTS, and the DTE sets
RTS if write permissions exists for the port.


DEC		TERMINAL / COMPUTER RS-232 NULL-MODEM CABLE

Cable Type:	Belden 9504	4 pair overall shielded
Outside Dia.:	0.265 inches	(6.75 millimeters)
Connectors:	DB-25

Terminal								Computer
Pin #	Signal Name		Wire Color	Signal Name		Pin #

 1	Protective ground-------Shield Drain----Protective ground	 1
 2	Transmit Data---------> red ----------> Receive Data		 3
 3	Receive Data <--------- white <-------- Transmit Data		 2
 4	Request to Send--:----> violet -------> Carrier Detect		 8
 5	Clear to Send <--: 5 jumpered to 4
 6	Data Set Ready <-:-----	green <-------- Data Terminal Ready	20
22	Ring Indicator <-: 22 jumpered to 6
 7	Signal Ground--white's blk & red's blk--Signal Ground		 7
 8	Carrier Detect <--- violet's blk <--:---Request to Send		 4
			    5 jumpered to 4 :-> Clear to Send		 5
20	Data Terminal Ready -> green's blk -:-> Data Set Ready		 6
			   22 jumpered to 6 :-> Ring Indicator		22

Notes:	This cable is wired like a DEC H312 Null Modem Card.

The pins that must be connected for a printer depend on whether the printer
uses a group 1 or a group 2 handshake.  For group 1, the important cross
connects are Pin 8 --> Pins 4 & 5.  For group 2, use Pin 20 --> Pins 6 & 22.
It is even possible to encounter a situation that requires group 1 passing
from device A to device B, but group 2 passing from device B to device A.
The full implementation uses all four: group 1, A to B; group 2, A to B;
group 1, B to A; group 2, B to A.

								!hao!hull