home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / amiga / programm / 11472 < prev    next >
Encoding:
Text File  |  1992-07-22  |  4.5 KB  |  136 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!lambda.msfc.nasa.gov!sauron!sims
  3. From: sims@sauron.msfc.nasa.gov (Herb Sims)
  4. Subject: **HELP** Whats wrong with this program?
  5. Message-ID: <sims.711806545@sauron.msfc.nasa.gov>
  6. Summary: Program crashes - don't know why
  7. Keywords: GURU 81000009
  8. Sender: news@lambda.msfc.nasa.gov (Newsmaster)
  9. Nntp-Posting-Host: sauron.msfc.nasa.gov
  10. Organization: NASA/MSFC
  11. Date: 22 Jul 92 12:02:25 GMT
  12. Lines: 122
  13.  
  14. The following is a short serial open/read a little/close program and I 
  15. cannot figure out why the program crashes.  Can someone **PLEASE** help
  16. me on this...I am about ready to rip the wings of my pet bird!!!!!
  17.  
  18. The GURU error is 81000009. Which is Free Twice error - What the #$&^(*&@^#
  19. does that mean?
  20.  
  21. ;Serial program
  22.  
  23. ;Inlcude Serial Stuff
  24.     INCLUDE "exec/types.i"
  25.     INCLUDE "exec/nodes.i"
  26.     INCLUDE "exec/lists.i"
  27.     INCLUDE "exec/ports.i"
  28.     INCLUDE "exec/devices.i"
  29.     INCLUDE "exec/io.i"
  30.     INCLUDE "devices/serial.i"
  31.     INCLUDE "intuition/preferences.i"
  32.  
  33. ExecBase    equ 4
  34.     SECTION code,CODE
  35.  
  36.     xref _LVOOpenDevice
  37.     xref _CreatePort
  38.     xref _CreateExtIO
  39.     xref _DeletePort
  40.     xref _DeleteExtIO
  41.     xref _LVOCloseDevice
  42.     xref _LVODoIO
  43.     xref _LVOSendIO
  44.     xref _LVOGetDefPrefs
  45.     xref _LVOAbortIO
  46.     xref _LVOCheckIO
  47.     xref _SysBase
  48.     xdef SerialMPortAddr
  49.     xdef SerialCreate
  50.     xdef OpenSerial
  51.     xdef SerialSetUp
  52.  
  53.     
  54. ;Find out where the libraries really are
  55. SerialPeriod    equ $ba6            ;Set Serial BAUD rate to 1200
  56. SerPer          equ $dff032         ;Where the Serial baud rate is
  57. SerDatr         equ $dff018         ;Where the serial data is
  58. IntReq          equ $dff09c         ;Interupt Register
  59. InteruptEnable  equ $dff09a         ;Interupt Enable register
  60. InterOff        equ $0800           ;Turns off serial interupts
  61. InterOn         equ $8800           ;Turn on serial interupts
  62.  
  63. SerialCreate:
  64. ;Create the serial port
  65.     move.l  #0,-(sp)                ;What is the priority?
  66.     pea     SerialName              ;Name of port to open (serial.device)
  67.     jsr     _CreatePort             ;Go open the port
  68.     addq.l  #8,sp
  69.     tst.l   d0                      ;Did it open?
  70.     beq     EndSerial               ;No...
  71.     lea     SerialMPortAddr,a1      ;Where is the serial port?
  72.     move.l  d0,(a1)                 ;Save the serial port pointer
  73.     
  74. ;Allocate memory for and intialize IO request block
  75.     move.l  #82,-(sp)               ;How big the Message Port is
  76.     pea     SerialMPortAddr         ;Where is the serial port
  77.     jsr     _CreateExtIO            ;Allocate/intialze IO request block
  78.     addq.l  #8,sp
  79.     tst     d0                      ;Allocate/intialize ok?
  80.     beq     DeleteSerialPort        ;nope
  81.     move.l  d0,PacketIO             ;Yea, so save it
  82.     move.l  d0,a1
  83.     move.b  #0,IO_SERFLAGS(a1)      ;Set up the IO Flags
  84.     
  85. OpenSerial:                         ;Open the serial port
  86.     lea     SerialName,a0           ;Get the device name
  87.     lea     PacketIO,a1             ;What type of request
  88.     move.l  ExecBase,a6
  89.     move.l  #0,d0                   ;Which Serial device (but is ignored)
  90.     move.l  #0,d1                   ;flags
  91.     jsr     _LVOOpenDevice(a6)      ;Go open serial.device
  92.     tst.b   d0                      ;Did it open?
  93.     bne     PreCloseSerial          ;Nope, go shut it down
  94.  
  95. ;this is to be the read/write code
  96.  
  97. PreCloseSerial:
  98.     lea     PacketIO,a1             ;Serial IOrequest structure address
  99.     move.l  ExecBase,a6             ;The usual
  100.     jsr     _LVOCheckIO(a6)         ;See if any outstanding IO requests
  101.     bne     SerialClose             ;Nope, so just close it
  102.     jsr     _LVOAbortIO(a6)         ;Yeap, so stop any IO requests before
  103.                                     ;closing
  104. SerialClose:
  105.     jsr     _LVOCloseDevice(a6)     ;Go close serial.device
  106.     
  107. DeleteSerialPort:
  108.     addq.l  #4,sp
  109.     pea     SerialMPortAddr         ;Message port address
  110.     jsr     _DeletePort             ;Delete the message port to free RAM
  111.     
  112. EndSerial:
  113.     rts                             ;End of program
  114.     
  115.     SECTION data,DATA
  116. SerialName:
  117.     dc.b    'serial.device',0               ;Serial device name
  118.     dc.w    0
  119. DeviceName:
  120.     dc.b    0
  121.     dc.b    0
  122.     dc.l    SerialMPortAddr
  123. Preference_Params:
  124.     dc.b    232
  125.     
  126.     SECTION mem,BSS
  127. SerialMPortAddr
  128.     ds.l    1                               ;Place to store the Serial Port
  129. PacketIO
  130.     ds.l    1                               ;Place to store the IO Request Block
  131. SerialData
  132.     ds.b    1                               ;Place to store Serial data
  133.  
  134.     END
  135.     
  136.