CompuServe Thread

Serial Port Ownership

2 messages in this thread
#163451From: Steve McDonnellMar 11, 1994 2:25 PM
#163406-Serial Port Ownership — declared parent_msg_num=163406, resolved parent_id points to #(none)
Here ya go, Andre. Per Craig Prouse's suggestion, I'll be adding a check for the driver name (.AIn, .AOut, .BIn, .BOut), which is somewhere towards the end of the DCE (don't have my MacsBug reference handy), to further ensure comaptibilty. That check is not in the code below. Not sure if we have an AV Mac. I did the development on a PowerBook 270C DuoDoc, which is a pretty new machine, System 7.1 too. I bet it will work on the AV. If you try it on the AV, and it doesn't work, please let me know. Exerpt from the unit's interface section. kUTableBaseAddr = $11C; {System global – points to DCE unit table} kAInDCEOffSet = $14; {Offset from kUTableBase to .AIn DCE handle} kAOutDCEOffSet = $18; {Offset from kUTableBase to .AOut DCE handle} kBInDCEOffSet = $1C; {Offset from kUTableBase to .BIn DCE handle} kBOutDCEOffSet = $20; {Offset from kUTableBase to .BOut DCE handle} kDCtlFlagsOffSet = $4; {Offset from start of DCE to dCtlFlags handle} kDCFDriverOpen = $0020; {Bit 5 of dCtlFlags indicates driver open status} The function itself, taken from implementain section: FUNCTION GetDCtlFlags (offSet: longint): integer; {} { Return the dCtlFlags word from the DCE handle stored at 'offset' to the} { start of DCE unit table (i.e. UTableBase). The dCtlFlags field can be} { used to obtain the current status of the driver (open/closed, RAM/ROM} { based, currently running, etc.). See Device Manager chapter in Macsbug} { Reference for a good description of how this works.} { SPM 3/7/94} {} VAR rc: integer; {return code} tp: Ptr; {Pointer to the unit table} dh: Handle; {Handle to DCE} hState: SignedByte; {For saving handle attributes} BEGIN BlockMove(Ptr(kUTableBaseAddr), @tp, 4); {pointer to unit table} BlockMove(Ptr(Ord4(tp) + offset), @dh, 4); {offset to DCE handle} hState := HGetState(dh); {get handle attributes} HLock(dh); {lock down the handle} BlockMove(Ptr(Ord4(dh^) + longint(kDCtlFlagsOffSet)), @rc, 2); {dCtlFlags} HSetState(dh, hState); {restore handle attributes} GetDCtlFlags := rc; {return result} END; {GetDCtlFlags} Example of calling the function: rc := GetDCtlFlags(kAInDCEOffSet); IF (BAND(rc, kDCFDriverOpen) > 0) THEN BEGIN {Port already open?} ParamText(rName, 'Another application is using the modem port!', '', ''); rc := Alert(kPortInUseAlert, NIL);; IF (rc = Cancel) THEN ExitToShell; {exit app immediately} END; {BAND(rc, kDCFDriverOpen)}
#164177From: Andre CoulombeMar 16, 1994 6:17 AM
#163451-Serial Port Ownership — declared parent_msg_num=163451, resolved parent_id points to #163451
Thank Steve, I dont have an an AV either, that why I ws asking. Andre