home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 377b.lha / devices / serial / serial.c next >
Encoding:
C/C++ Source or Header  |  1980-02-03  |  2.3 KB  |  66 lines

  1. /*  serial.c - Simple no tricks example of serial.device usage
  2.  *
  3.  * Copyright (c) 1990 Commodore-Amiga, Inc.
  4.  *
  5.  * This example is provided in electronic form by Commodore-Amiga, Inc. for
  6.  * use with the 1.3 revisions of the Addison-Wesley Amiga reference manuals. 
  7.  * The 1.3 Addison-Wesley Amiga Reference Manual series contains additional
  8.  * information on the correct usage of the techniques and operating system
  9.  * functions presented in this example.  The source and executable code of
  10.  * this example may only be distributed in free electronic form, via bulletin
  11.  * board or as part of a fully non-commercial and freely redistributable
  12.  * diskette.  Both the source and executable code (including comments) must
  13.  * be included, without modification, in any copy.  This example may not be
  14.  * published in printed form or distributed with any commercial product.
  15.  * However, the programming techniques and support routines set forth in
  16.  * this example may be used in the development of original executable
  17.  * software products for Commodore Amiga computers.
  18.  * All other rights reserved.
  19.  * This example is provided "as-is" and is subject to change; no warranties
  20.  * are made.  All use is at your own risk.  No liability or responsibility
  21.  * is assumed.
  22.  *
  23.  *  Compile with Lattice 5.04: LC -Lt -catsfq.    Use from CLI only.
  24.  */
  25. #include <exec/types.h>
  26. #include <devices/serial.h>
  27. #ifdef LATTICE
  28. #include <proto/exec.h>
  29. #include <stdio.h>
  30. int CXBRK(void) { return(0); }  /* Disable Lattice CTRL-C handling */
  31. void main(void);
  32. #endif
  33.  
  34. #define DEVICE_NAME "serial.device"
  35. #define UNIT_NUMBER 0
  36.  
  37. void main()
  38. {
  39. struct MsgPort    *SerialMP;        /* Define storage for one pointer */
  40. struct IOExtSer *SerialIO;       /* Define storage for one pointer */
  41.  
  42.     if( SerialMP=CreatePort(0,0) )
  43.     {
  44.     if( SerialIO=(struct IOExtSer *)
  45.         CreateExtIO(SerialMP,sizeof(struct IOExtSer)) )
  46.         {
  47.         SerialIO->io_SerFlags=SERF_SHARED;    /* Turn on SHARED mode */
  48.  
  49.         if ( OpenDevice(DEVICE_NAME,UNIT_NUMBER,SerialIO,0) )
  50.         printf("Serial.device did not open\n");
  51.         else
  52.         {
  53.         SerialIO->IOSer.io_Command  = CMD_WRITE;
  54.         SerialIO->IOSer.io_Length   = 6;
  55.         SerialIO->IOSer.io_Data     = (APTR)"Amiga ";
  56.         DoIO(SerialIO);             /* execute write */
  57.  
  58.         /* Add more commands here */
  59.         CloseDevice(SerialIO);
  60.         }
  61.         DeleteExtIO(SerialIO);
  62.         }
  63.     DeletePort(SerialMP);
  64.     }
  65. }
  66.