home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 420.lha / Example_device / Ex_Tester.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-29  |  2.2 KB  |  84 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <exec/types.h>
  5. #include <exec/exec.h>
  6. #include "exec/execbase.h"
  7. #include "devices/timer.h"
  8. #include <libraries/dos.h>
  9. #include <proto/dos.h>
  10. #include <proto/exec.h>
  11.  
  12. /************************/
  13. /* Constants and Macros */
  14. /************************/
  15. typedef struct IOStdReq   IOSTDREQUEST;
  16. typedef struct MsgPort    MSGPORT;
  17. typedef struct IORequest  IOREQUEST;
  18.  
  19. /***************************/
  20. /* Structures and Typedefs */
  21. /***************************/
  22.  
  23. /**************/
  24. /* Prototypes */
  25. /**************/
  26.  
  27. /********************/
  28. /* Global Variables */
  29. /********************/
  30.  
  31. /**********************************************************************/
  32. /*                                                                    */
  33. /**********************************************************************/
  34. int
  35. main()
  36. {
  37.     MSGPORT       *mp;
  38.     IOSTDREQUEST  *ior;
  39.     int            result;
  40.  
  41.     /*************************************/
  42.     /* Create a Private I/O Message Port */
  43.     /*************************************/
  44.     if ((mp = CreatePort(NULL, 0)) == 0) {
  45.         printf("Unable to Create a Private I/O Port.\n");
  46.         return 10;
  47.     }
  48.  
  49.     /************************************/
  50.     /* Setup the I/O Read Request Block */
  51.     /************************************/
  52.     ior = CreateStdIO(mp);
  53.     if (ior == NULL) {
  54.         DeletePort(mp);
  55.         printf("CreateStdIO Function Failed.\n");
  56.         return 10;
  57.     }
  58.  
  59.     /**********************************/
  60.     /* Open the Desired Serial Device */
  61.     /**********************************/
  62.     if (result = OpenDevice("Example.device", 0L, (IOREQUEST *)ior, 0L)) {
  63.         printf("OpenDevice Function Failed, Error %u (0x%02X).\n",
  64.             result, result);
  65.  
  66.         DeleteStdIO(ior);
  67.         DeletePort(mp);
  68.         return 10;
  69.     }
  70.  
  71.     printf("The Open Succeeded, Press Any Key to Continue!\n");
  72.     getchar();
  73.  
  74.     CloseDevice((IOREQUEST *)ior);
  75.     DeleteStdIO(ior);
  76.     DeletePort(mp);
  77.  
  78.     return 0;
  79. }
  80. /**********************************************************************/
  81. /*                                                                    */
  82. /**********************************************************************/
  83.  
  84.