serialmgr.pp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. {$MACRO ON}
  2. (******************************************************************************
  3. *
  4. * Copyright (c) 1995-2000 Palm, Inc. or its subsidiaries.
  5. * All rights reserved.
  6. *
  7. * File: SerialMgr.h
  8. *
  9. * Release: Palm OS SDK 4.0 (63220)
  10. *
  11. * Description:
  12. * Include file for Serial manager
  13. *
  14. * History:
  15. * 1/14/98 SerialMgr.h created by Ben Manuto
  16. *
  17. *****************************************************************************)
  18. unit serialmgr;
  19. interface
  20. uses palmos, coretraps, errorbase, systemresources, systemmgr, netmgr;
  21. // New Serial manager feature numbers
  22. const
  23. sysFtrNewSerialPresent = 1;
  24. sysFtrNewSerialVersion = 2;
  25. serMgrVersion = 2;
  26. (********************************************************************
  27. * Serial Manager Errors
  28. * the constant serErrorClass is defined in SystemMgr.h
  29. ********************************************************************)
  30. serErrBadParam = serErrorClass or 1;
  31. serErrBadPort = serErrorClass or 2;
  32. serErrNoMem = serErrorClass or 3;
  33. serErrBadConnID = serErrorClass or 4;
  34. serErrTimeOut = serErrorClass or 5;
  35. serErrLineErr = serErrorClass or 6;
  36. serErrAlreadyOpen = serErrorClass or 7;
  37. serErrStillOpen = serErrorClass or 8;
  38. serErrNotOpen = serErrorClass or 9;
  39. serErrNotSupported = serErrorClass or 10; // functionality not supported
  40. serErrNoDevicesAvail = serErrorClass or 11; // No serial devices were loaded or are available.
  41. // New error codes for USB support
  42. serErrConfigurationFailed = serErrorClass or 12;
  43. //
  44. // mask values for the lineErrors from SerGetStatus
  45. //
  46. serLineErrorParity = $0001; // parity error
  47. serLineErrorHWOverrun = $0002; // HW overrun
  48. serLineErrorFraming = $0004; // framing error
  49. serLineErrorBreak = $0008; // break signal asserted
  50. serLineErrorHShake = $0010; // line hand-shake error
  51. serLineErrorSWOverrun = $0020; // HW overrun
  52. serLineErrorCarrierLost = $0040; // CD dropped
  53. (********************************************************************
  54. * Serial Port Definitions
  55. ********************************************************************)
  56. const
  57. serPortLocalHotSync = $8000; // Use physical HotSync port
  58. serPortCradlePort = $8000; // Cradle port. (Auto detect cradle type)
  59. serPortIrPort = $8001; // Use available IR port.
  60. serPortConsolePort = $8002; // Console port
  61. serPortCradleRS232Port = $8003; // Cradle RS232 Port
  62. serPortCradleUSBPort = $8004; // Cradle USB Port
  63. // This constant is used by the Serial Link Mgr only
  64. serPortIDMask = $C000;
  65. (********************************************************************
  66. * Serial Settings Descriptor
  67. ********************************************************************)
  68. srmSettingsFlagStopBitsM = $00000001; // mask for stop bits field
  69. srmSettingsFlagStopBits1 = $00000000; // 1 stop bits
  70. srmSettingsFlagStopBits2 = $00000001; // 2 stop bits
  71. srmSettingsFlagParityOnM = $00000002; // mask for parity on
  72. srmSettingsFlagParityEvenM = $00000004; // mask for parity even
  73. srmSettingsFlagXonXoffM = $00000008; // (NOT IMPLEMENTED) mask for Xon/Xoff flow control
  74. srmSettingsFlagRTSAutoM = $00000010; // mask to prevent UART input overflow using RTS (NOTE: this flag
  75. // alone does not prevent software overruns from the serial input buffer)
  76. srmSettingsFlagCTSAutoM = $00000020; // mask for CTS xmit flow control (see srmSettingsFlagFlowControlIn below)
  77. srmSettingsFlagBitsPerCharM = $000000C0; // mask for bits/char
  78. srmSettingsFlagBitsPerChar5 = $00000000; // 5 bits/char
  79. srmSettingsFlagBitsPerChar6 = $00000040; // 6 bits/char
  80. srmSettingsFlagBitsPerChar7 = $00000080; // 7 bits/char
  81. srmSettingsFlagBitsPerChar8 = $000000C0; // 8 bits/char
  82. srmSettingsFlagFlowControlIn = $00000100; // mask to prevent the serial input buffer overflow, using RTS. Use in
  83. // conjunction with srmSettingsFlagRTSAutoM for a fully flow controlled input.
  84. srmSettingsFlagRTSInactive = $00000200; // if set and srmSettingsFlagRTSAutoM==0, RTS is held in the inactive (flow off) state forever.
  85. // Default settings
  86. srmDefaultSettings = srmSettingsFlagBitsPerChar8 or srmSettingsFlagStopBits1 or srmSettingsFlagRTSAutoM or srmSettingsFlagRTSInactive;
  87. srmDefaultCTSTimeout = 5 * sysTicksPerSecond_;
  88. // Status bitfield constants
  89. srmStatusCtsOn = $00000001;
  90. srmStatusRtsOn = $00000002;
  91. srmStatusDsrOn = $00000004;
  92. srmStatusBreakSigOn = $00000008;
  93. //
  94. // Info fields describing serial HW capabilities.
  95. //
  96. serDevCradlePort = $00000001; // Serial HW controls RS-232 serial from cradle connector of handheld.
  97. serDevRS232Serial = $00000002; // Serial HW has RS-232 line drivers
  98. serDevIRDACapable = $00000004; // Serial Device has IR line drivers and generates IRDA mode serial.
  99. serDevModemPort = $00000008; // Serial deivce drives modem connection.
  100. serDevCncMgrVisible = $00000010; // Serial device port name string to be displayed in Connection Mgr panel.
  101. serDevConsolePort = $00000020; // Serial device is the default console port.
  102. serDevUSBCapable = $00000040; // USB driver for USB hardware connected to the cradle connector of the handheld.
  103. type
  104. DeviceInfoType = record
  105. serDevCreator: UInt32; // Four Character creator type for serial driver ('sdrv')
  106. serDevFtrInfo: UInt32; // Flags defining features of this serial hardware.
  107. serDevMaxBaudRate: UInt32; // Maximum baud rate for this device.
  108. serDevHandshakeBaud: UInt32; // HW Handshaking is reccomended for baud rates over this
  109. serDevPortInfoStr: PChar; // Description of serial HW device or virtual device.
  110. reserved: array [0..8-1] of UInt8; // Reserved.
  111. end;
  112. DeviceInfoPtr = ^DeviceInfoType;
  113. // Function IDs
  114. //
  115. // Standard set of function ids for the SrmOpen. Out of convenience, function ids
  116. // use the same namespace as creator ids. Custom functions can be defined by
  117. // using your app's creator id. The driver must have knowledge of that creator
  118. // id for it to be of any use. A driver should handle an unknown function id
  119. // gracefully, either use default functionality or return a serErrBadParam error.
  120. const
  121. serFncUndefined = 0; // Undefined function
  122. serFncPPPSession = netIFCreatorPPP; // NetLib PPP Interface
  123. serFncSLIPSession = netIFCreatorSLIP; // NetLib SLIP Interface
  124. serFncDebugger = sysFileCSystem; // PalmOS Debugger
  125. serFncHotSync = sysFileCSync; // HotSync function
  126. serFncConsole = sysFileCSystem; // PalmOS Console
  127. serFncTelephony = sysFileCTelMgrLib; // Telephony Library
  128. //
  129. // Open Configuration Structure
  130. //
  131. type
  132. SrmOpenConfigType = record
  133. baud: UInt32; // Baud rate that the connection is to be opened at.
  134. // Applications that use drivers that do not require
  135. // baud rates can set this to zero or any other value.
  136. // Drivers that do not require a baud rate should
  137. // ignore this field
  138. function_: UInt32; // Designates the function of the connection. A value
  139. // of zero indictates default behavior for the protocol.
  140. // Drivers that do not support multiple functions should
  141. // ignore this field.
  142. drvrDataP: MemPtr; // Pointer to driver specific data.
  143. drvrDataSize: UInt16; // Size of the driver specific data block.
  144. sysReserved1: UInt32; // System Reserved
  145. sysReserved2: UInt32; // System Reserved
  146. end;
  147. SrmOpenConfigPtr = ^SrmOpenConfigType;
  148. (********************************************************************
  149. * Transfer modes for USB
  150. ********************************************************************)
  151. type
  152. SrmTransferModeType = Enum;
  153. const
  154. srmTransferFirstReserved = 0; // RESERVE 0
  155. srmUSBInterruptMode = Succ(srmTransferFirstReserved);
  156. srmUSBBulkMode = Succ(srmUSBInterruptMode);
  157. srmUSBIsochronous = Succ(srmUSBBulkMode);
  158. (********************************************************************
  159. * Type of a wakeup handler procedure which can be installed through the
  160. * SerSetWakeupHandler() call.
  161. ********************************************************************)
  162. type
  163. WakeupHandlerProcPtr = procedure(refCon: UInt32);
  164. (********************************************************************
  165. * Type of an emulator-mode only blocking hook routine installed via
  166. * SerControl function serCtlEmuSetBlockingHook. This is supported only
  167. * under emulation mode. The argument to the function is the value
  168. * specified in the SerCallbackEntryType structure. The intention of the
  169. * return value is to return false if serial manager should abort the
  170. * current blocking action, such as when an app quit event has been received;
  171. * otherwise, it should return true. However, in the current implementation,
  172. * this return value is ignored. The callback can additionally process
  173. * events to enable user interaction with the UI, such as interacting with the
  174. * debugger.
  175. ********************************************************************)
  176. BlockingHookProcPtr = function(userRef: UInt32): Boolean;
  177. (********************************************************************
  178. * Serial Library Control Enumerations (Pilot 2.0)
  179. ********************************************************************)
  180. (********************************************************************
  181. * Structure for specifying callback routines.
  182. ********************************************************************)
  183. SrmCallbackEntryType = record
  184. funcP: BlockingHookProcPtr; // function pointer
  185. userRef: UInt32; // ref value to pass to callback
  186. end;
  187. SrmCallbackEntryPtr = ^SrmCallbackEntryType;
  188. type
  189. SrmCtlEnum = Enum;
  190. const
  191. srmCtlFirstReserved = 0; // RESERVE 0
  192. srmCtlSetBaudRate = Succ(srmCtlFirstReserved); // Sets the current baud rate for the HW.
  193. // valueP = Pointer to Int32, valueLenP = Pointer to sizeof(Int32)
  194. srmCtlGetBaudRate = Succ(srmCtlSetBaudRate); // Gets the current baud rate for the HW.
  195. srmCtlSetFlags = Succ(srmCtlGetBaudRate); // Sets the current flag settings for the serial HW.
  196. srmCtlGetFlags = Succ(srmCtlSetFlags); // Gets the current flag settings the serial HW.
  197. srmCtlSetCtsTimeout = Succ(srmCtlGetFlags); // Sets the current Cts timeout value.
  198. srmCtlGetCtsTimeout = Succ(srmCtlSetCtsTimeout); // Gets the current Cts timeout value.
  199. srmCtlStartBreak = Succ(srmCtlGetCtsTimeout); // turn RS232 break signal on:
  200. // users are responsible for ensuring that the break is set
  201. // long enough to genearate a valid BREAK!
  202. // valueP = 0, valueLenP = 0
  203. srmCtlStopBreak = Succ(srmCtlStartBreak); // turn RS232 break signal off:
  204. // valueP = 0, valueLenP = 0
  205. srmCtlStartLocalLoopback = Succ(srmCtlStopBreak); // Start local loopback test
  206. // valueP = 0, valueLenP = 0
  207. srmCtlStopLocalLoopback = Succ(srmCtlStartLocalLoopback); // Stop local loopback test
  208. // valueP = 0, valueLenP = 0
  209. srmCtlIrDAEnable = Succ(srmCtlStopLocalLoopback); // Enable IrDA connection on this serial port
  210. // valueP = 0, valueLenP = 0
  211. srmCtlIrDADisable = Succ(srmCtlIrDAEnable); // Disable IrDA connection on this serial port
  212. // valueP = 0, valueLenP = 0
  213. srmCtlRxEnable = Succ(srmCtlIrDADisable); // enable receiver ( for IrDA )
  214. srmCtlRxDisable = Succ(srmCtlRxEnable); // disable receiver ( for IrDA )
  215. srmCtlEmuSetBlockingHook = Succ(srmCtlRxDisable); // Set a blocking hook routine FOR EMULATION
  216. // MODE ONLY - NOT SUPPORTED ON THE PILOT
  217. //PASS:
  218. // valueP = Pointer to SerCallbackEntryType
  219. // *valueLenP = sizeof(SerCallbackEntryType)
  220. //RETURNS:
  221. // the old settings in the first argument
  222. srmCtlUserDef = Succ(srmCtlEmuSetBlockingHook); // Specifying this opCode passes through a user-defined
  223. // function to the DrvControl function. This is for use
  224. // specifically by serial driver developers who need info
  225. // from the serial driver that may not be available through the
  226. // standard SrmMgr interface.
  227. srmCtlGetOptimalTransmitSize = Succ(srmCtlUserDef); // This function will ask the port for the most efficient buffer size
  228. // for transmitting data packets. This opCode returns serErrNotSupported
  229. // if the physical or virtual device does not support this feature.
  230. // The device can return a transmit size of 0, if send buffering is
  231. // requested, but the actual size is up to the caller to choose.
  232. // valueP = Pointer to UInt32 --> return optimal buf size
  233. // ValueLenP = sizeof(UInt32)
  234. srmCtlSetDTRAsserted = Succ(srmCtlGetOptimalTransmitSize); // Enable or disable DTR.
  235. srmCtlGetDTRAsserted = Succ(srmCtlSetDTRAsserted); // Determine if DTR is enabled or disabled.
  236. srmCtlSetYieldPortCallback = Succ(srmCtlGetDTRAsserted); // Set the yield port callback
  237. srmCtlSetYieldPortRefCon = Succ(srmCtlSetYieldPortCallback); // Set the yield port refNum
  238. // ***** ADD NEW ENTRIES BEFORE THIS ONE
  239. srmCtlSystemReserved = $7000; // Reserve control op code space for system use.
  240. srmCtlCustom = $8000; // Reserve control op code space for licensee use.
  241. srmCtlLAST = Succ(srmCtlCustom);
  242. const
  243. srmCtlSystemStart = $7000; // Start poitn for system op codes.
  244. srmCtlCustomStart = $8000; // Start point for custom op codes.
  245. (********************************************************************
  246. * Serial Hardware Library Routines
  247. ********************************************************************)
  248. // *****************************************************************
  249. // * New Serial Manager trap selectors
  250. // *****************************************************************
  251. type
  252. sysSerialSelector = Enum; // The order of this enum *MUST* match the sysSerialSelector in SerialMgr.c
  253. const
  254. sysSerialInstall = 0;
  255. sysSerialOpen = Succ(sysSerialInstall);
  256. sysSerialOpenBkgnd = Succ(sysSerialOpen);
  257. sysSerialClose = Succ(sysSerialOpenBkgnd);
  258. sysSerialSleep = Succ(sysSerialClose);
  259. sysSerialWake = Succ(sysSerialSleep);
  260. sysSerialGetDeviceCount = Succ(sysSerialWake);
  261. sysSerialGetDeviceInfo = Succ(sysSerialGetDeviceCount);
  262. sysSerialGetStatus = Succ(sysSerialGetDeviceInfo);
  263. sysSerialClearErr = Succ(sysSerialGetStatus);
  264. sysSerialControl = Succ(sysSerialClearErr);
  265. sysSerialSend = Succ(sysSerialControl);
  266. sysSerialSendWait = Succ(sysSerialSend);
  267. sysSerialSendCheck = Succ(sysSerialSendWait);
  268. sysSerialSendFlush = Succ(sysSerialSendCheck);
  269. sysSerialReceive = Succ(sysSerialSendFlush);
  270. sysSerialReceiveWait = Succ(sysSerialReceive);
  271. sysSerialReceiveCheck = Succ(sysSerialReceiveWait);
  272. sysSerialReceiveFlush = Succ(sysSerialReceiveCheck);
  273. sysSerialSetRcvBuffer = Succ(sysSerialReceiveFlush);
  274. sysSerialRcvWindowOpen = Succ(sysSerialSetRcvBuffer);
  275. sysSerialRcvWindowClose = Succ(sysSerialRcvWindowOpen);
  276. sysSerialSetWakeupHandler = Succ(sysSerialRcvWindowClose);
  277. sysSerialPrimeWakeupHandler = Succ(sysSerialSetWakeupHandler);
  278. sysSerialOpenV4 = Succ(sysSerialPrimeWakeupHandler);
  279. sysSerialOpenBkgndV4 = Succ(sysSerialOpenV4);
  280. sysSerialCustomControl = Succ(sysSerialOpenBkgndV4);
  281. // Used by SerialMgrDispatch.c
  282. maxSerialSelector = sysSerialCustomControl;
  283. function SerialMgrInstall: Err;
  284. function SrmOpen(port, baud: UInt32; var newPortIdP: UInt16): Err;
  285. function SrmExtOpen(port: UInt32; var configP: SrmOpenConfigType; configSize: UInt16; var newPortIdP: UInt16): Err;
  286. function SrmExtOpenBackground(port: UInt32; var configP: SrmOpenConfigType; configSize: UInt16; var newPortIdP: UInt16): Err;
  287. function SrmOpenBackground(port, baud: UInt32; var newPortIdP: UInt16): Err;
  288. function SrmClose(portId: UInt16): Err;
  289. function SrmSleep: Err;
  290. function SrmWake: Err;
  291. function SrmGetDeviceCount(var numOfDevicesP: UInt16): Err;
  292. function SrmGetDeviceInfo(deviceID: UInt32; var deviceInfoP: DeviceInfoType): Err;
  293. function SrmGetStatus(portId: UInt16; var statusFieldP: UInt32; var lineErrsP: UInt16): Err;
  294. function SrmClearErr(portId: UInt16): Err;
  295. function SrmControl(portId, op: UInt16; valueP: Pointer; var valueLenP: UInt16): Err;
  296. function SrmCustomControl(portId, opCode: UInt16; creator: UInt32; valueP: Pointer; var valueLenP: UInt16): Err;
  297. function SrmSend(portId: UInt16; const bufP: Pointer; count: UInt32; var errP: Err): UInt32;
  298. function SrmSendWait(portId: UInt16): Err;
  299. function SrmSendCheck(portId: UInt16; var numBytesP: UInt32): Err;
  300. function SrmSendFlush(portId: UInt16): Err;
  301. function SrmReceive(portId: UInt16; rcvBufP: Pointer; count: UInt32; timeout: Int32; var errP: Err): UInt32;
  302. function SrmReceiveWait(portId: UInt16; bytes: UInt32; timeout: Int32): Err;
  303. function SrmReceiveCheck(portId: UInt16; var numBytesP: UInt32): Err;
  304. function SrmReceiveFlush(portId: UInt16; timeout: Int32): Err;
  305. function SrmSetReceiveBuffer(portId: UInt16; bufP: Pointer; bufSize: UInt16): Err;
  306. function SrmReceiveWindowOpen(portId: UInt16; var bufPP: UInt8Ptr; var sizeP: UInt32): Err;
  307. function SrmReceiveWindowClose(portId: UInt16; bytesPulled: UInt32): Err;
  308. function SrmSetWakeupHandler(portId: UInt16; procP: WakeupHandlerProcPtr; refCon: UInt32): Err;
  309. function SrmPrimeWakeupHandler(portId: UInt16; minBytes: UInt16): Err;
  310. //procedure SrmSelectorErrPrv(UInt16 serialSelector); // used only by SerialMgrDispatch.c
  311. implementation
  312. function __SerialMgrInstall: Err; syscall sysTrapSerialDispatch;
  313. function __SrmOpen(port, baud: UInt32; var newPortIdP: UInt16): Err; syscall sysTrapSerialDispatch;
  314. function __SrmExtOpen(port: UInt32; var configP: SrmOpenConfigType; configSize: UInt16; var newPortIdP: UInt16): Err; syscall sysTrapSerialDispatch;
  315. function __SrmExtOpenBackground(port: UInt32; var configP: SrmOpenConfigType; configSize: UInt16; var newPortIdP: UInt16): Err; syscall sysTrapSerialDispatch;
  316. function __SrmOpenBackground(port, baud: UInt32; var newPortIdP: UInt16): Err; syscall sysTrapSerialDispatch;
  317. function __SrmClose(portId: UInt16): Err; syscall sysTrapSerialDispatch;
  318. function __SrmSleep: Err; syscall sysTrapSerialDispatch;
  319. function __SrmWake: Err; syscall sysTrapSerialDispatch;
  320. function __SrmGetDeviceCount(var numOfDevicesP: UInt16): Err; syscall sysTrapSerialDispatch;
  321. function __SrmGetDeviceInfo(deviceID: UInt32; var deviceInfoP: DeviceInfoType): Err; syscall sysTrapSerialDispatch;
  322. function __SrmGetStatus(portId: UInt16; var statusFieldP: UInt32; var lineErrsP: UInt16): Err; syscall sysTrapSerialDispatch;
  323. function __SrmClearErr(portId: UInt16): Err; syscall sysTrapSerialDispatch;
  324. function __SrmControl(portId, op: UInt16; valueP: Pointer; var valueLenP: UInt16): Err; syscall sysTrapSerialDispatch;
  325. function __SrmCustomControl(portId, opCode: UInt16; creator: UInt32; valueP: Pointer; var valueLenP: UInt16): Err; syscall sysTrapSerialDispatch;
  326. function __SrmSend(portId: UInt16; const bufP: Pointer; count: UInt32; var errP: Err): UInt32; syscall sysTrapSerialDispatch;
  327. function __SrmSendWait(portId: UInt16): Err; syscall sysTrapSerialDispatch;
  328. function __SrmSendCheck(portId: UInt16; var numBytesP: UInt32): Err; syscall sysTrapSerialDispatch;
  329. function __SrmSendFlush(portId: UInt16): Err; syscall sysTrapSerialDispatch;
  330. function __SrmReceive(portId: UInt16; rcvBufP: Pointer; count: UInt32; timeout: Int32; var errP: Err): UInt32; syscall sysTrapSerialDispatch;
  331. function __SrmReceiveWait(portId: UInt16; bytes: UInt32; timeout: Int32): Err; syscall sysTrapSerialDispatch;
  332. function __SrmReceiveCheck(portId: UInt16; var numBytesP: UInt32): Err; syscall sysTrapSerialDispatch;
  333. function __SrmReceiveFlush(portId: UInt16; timeout: Int32): Err; syscall sysTrapSerialDispatch;
  334. function __SrmSetReceiveBuffer(portId: UInt16; bufP: Pointer; bufSize: UInt16): Err; syscall sysTrapSerialDispatch;
  335. function __SrmReceiveWindowOpen(portId: UInt16; var bufPP: UInt8Ptr; var sizeP: UInt32): Err; syscall sysTrapSerialDispatch;
  336. function __SrmReceiveWindowClose(portId: UInt16; bytesPulled: UInt32): Err; syscall sysTrapSerialDispatch;
  337. function __SrmSetWakeupHandler(portId: UInt16; procP: WakeupHandlerProcPtr; refCon: UInt32): Err; syscall sysTrapSerialDispatch;
  338. function __SrmPrimeWakeupHandler(portId: UInt16; minBytes: UInt16): Err; syscall sysTrapSerialDispatch;
  339. function SerialMgrInstall: Err;
  340. begin
  341. asm
  342. move.l #$sysSerialInstall,D2;
  343. end;
  344. SerialMgrInstall := __SerialMgrInstall;
  345. end;
  346. function SrmOpen(port, baud: UInt32; var newPortIdP: UInt16): Err;
  347. begin
  348. asm
  349. move.l #$sysSerialOpen,D2;
  350. end;
  351. SrmOpen := __SrmOpen(port, baud, newPortIdP);
  352. end;
  353. function SrmExtOpen(port: UInt32; var configP: SrmOpenConfigType; configSize: UInt16; var newPortIdP: UInt16): Err;
  354. begin
  355. asm
  356. move.l #$sysSerialOpenV4,D2;
  357. end;
  358. SrmExtOpen := __SrmExtOpen(port, configP, configSize, newPortIdP);
  359. end;
  360. function SrmExtOpenBackground(port: UInt32; var configP: SrmOpenConfigType; configSize: UInt16; var newPortIdP: UInt16): Err;
  361. begin
  362. asm
  363. move.l #$sysSerialOpenBkgndV4,D2;
  364. end;
  365. SrmExtOpenBackground := __SrmExtOpenBackground(port, configP, configSize, newPortIdP);
  366. end;
  367. function SrmOpenBackground(port, baud: UInt32; var newPortIdP: UInt16): Err;
  368. begin
  369. asm
  370. move.l #$sysSerialOpenBkgnd,D2;
  371. end;
  372. SrmOpenBackground := __SrmOpenBackground(port, baud, newPortIdP);
  373. end;
  374. function SrmClose(portId: UInt16): Err;
  375. begin
  376. asm
  377. move.l #$sysSerialClose,D2;
  378. end;
  379. SrmClose := __SrmClose(portId);
  380. end;
  381. function SrmSleep: Err;
  382. begin
  383. asm
  384. move.l #$sysSerialSleep,D2;
  385. end;
  386. SrmSleep := __SrmSleep;
  387. end;
  388. function SrmWake: Err;
  389. begin
  390. asm
  391. move.l #$sysSerialWake,D2;
  392. end;
  393. SrmWake := __SrmWake;
  394. end;
  395. function SrmGetDeviceCount(var numOfDevicesP: UInt16): Err;
  396. begin
  397. asm
  398. move.l #$sysSerialGetDeviceCount,D2;
  399. end;
  400. SrmGetDeviceCount := __SrmGetDeviceCount(numOfDevicesP);
  401. end;
  402. function SrmGetDeviceInfo(deviceID: UInt32; var deviceInfoP: DeviceInfoType): Err;
  403. begin
  404. asm
  405. move.l #$sysSerialGetDeviceInfo,D2;
  406. end;
  407. SrmGetDeviceInfo := __SrmGetDeviceInfo(deviceID, deviceInfoP);
  408. end;
  409. function SrmGetStatus(portId: UInt16; var statusFieldP: UInt32; var lineErrsP: UInt16): Err;
  410. begin
  411. asm
  412. move.l #$sysSerialGetStatus,D2;
  413. end;
  414. SrmGetStatus := __SrmGetStatus(portId, statusFieldP, lineErrsP);
  415. end;
  416. function SrmClearErr(portId: UInt16): Err;
  417. begin
  418. asm
  419. move.l #$sysSerialClearErr,D2;
  420. end;
  421. SrmClearErr := __SrmClearErr(portId);
  422. end;
  423. function SrmControl(portId, op: UInt16; valueP: Pointer; var valueLenP: UInt16): Err;
  424. begin
  425. asm
  426. move.l #$sysSerialControl,D2;
  427. end;
  428. SrmControl := __SrmControl(portId, op, valueP, valueLenP);
  429. end;
  430. function SrmCustomControl(portId, opCode: UInt16; creator: UInt32; valueP: Pointer; var valueLenP: UInt16): Err;
  431. begin
  432. asm
  433. move.l #$sysSerialCustomControl,D2;
  434. end;
  435. SrmCustomControl := __SrmCustomControl(portId, opCode, creator, valueP, valueLenP);
  436. end;
  437. function SrmSend(portId: UInt16; const bufP: Pointer; count: UInt32; var errP: Err): UInt32;
  438. begin
  439. asm
  440. move.l #$sysSerialSend,D2;
  441. end;
  442. SrmSend := __SrmSend(portId, bufP, count, errP);
  443. end;
  444. function SrmSendWait(portId: UInt16): Err;
  445. begin
  446. asm
  447. move.l #$sysSerialSendWait,D2;
  448. end;
  449. SrmSendwait := __SrmSendwait(portId);
  450. end;
  451. function SrmSendCheck(portId: UInt16; var numBytesP: UInt32): Err;
  452. begin
  453. asm
  454. move.l #$sysSerialSendCheck,D2;
  455. end;
  456. SrmSendCheck := __SrmSendCheck(portId, numBytesP);
  457. end;
  458. function SrmSendFlush(portId: UInt16): Err;
  459. begin
  460. asm
  461. move.l #$sysSerialSendFlush,D2;
  462. end;
  463. SrmSendFlush := __SrmSendFlush(portId);
  464. end;
  465. function SrmReceive(portId: UInt16; rcvBufP: Pointer; count: UInt32; timeout: Int32; var errP: Err): UInt32;
  466. begin
  467. asm
  468. move.l #$sysSerialReceive,D2;
  469. end;
  470. SrmReceive := __SrmReceive(portId, rcvBufP, count, timeout, errP);
  471. end;
  472. function SrmReceiveWait(portId: UInt16; bytes: UInt32; timeout: Int32): Err;
  473. begin
  474. asm
  475. move.l #$sysSerialReceiveWait,D2;
  476. end;
  477. SrmReceiveWait := __SrmReceiveWait(portId, bytes, timeout);
  478. end;
  479. function SrmReceiveCheck(portId: UInt16; var numBytesP: UInt32): Err;
  480. begin
  481. asm
  482. move.l #$sysSerialReceiveCheck,D2;
  483. end;
  484. SrmReceiveCheck := __SrmReceiveCheck(portId, numBytesP);
  485. end;
  486. function SrmReceiveFlush(portId: UInt16; timeout: Int32): Err;
  487. begin
  488. asm
  489. move.l #$sysSerialReceiveFlush,D2;
  490. end;
  491. SrmReceiveFlush := __SrmReceiveFlush(portId, timeout);
  492. end;
  493. function SrmSetReceiveBuffer(portId: UInt16; bufP: Pointer; bufSize: UInt16): Err;
  494. begin
  495. asm
  496. move.l #$sysSerialSetRcvBuffer,D2;
  497. end;
  498. SrmSetReceiveBuffer := __SrmSetReceiveBuffer(portId, bufP, bufSize);
  499. end;
  500. function SrmReceiveWindowOpen(portId: UInt16; var bufPP: UInt8Ptr; var sizeP: UInt32): Err;
  501. begin
  502. asm
  503. move.l #$sysSerialRcvWindowOpen,D2;
  504. end;
  505. SrmReceiveWindowOpen := __SrmReceiveWindowOpen(portId, bufPP, sizeP);
  506. end;
  507. function SrmReceiveWindowClose(portId: UInt16; bytesPulled: UInt32): Err;
  508. begin
  509. asm
  510. move.l #$sysSerialRcvWindowClose,D2;
  511. end;
  512. SrmReceiveWindowClose := __SrmReceiveWindowClose(portId, bytesPulled);
  513. end;
  514. function SrmSetWakeupHandler(portId: UInt16; procP: WakeupHandlerProcPtr; refCon: UInt32): Err;
  515. begin
  516. asm
  517. move.l #$sysSerialSetWakeupHandler,D2;
  518. end;
  519. SrmSetWakeupHandler := __SrmSetWakeupHandler(portId, procP, refcon);
  520. end;
  521. function SrmPrimeWakeupHandler(portId: UInt16; minBytes: UInt16): Err;
  522. begin
  523. asm
  524. move.l #$sysSerialPrimeWakeupHandler,D2;
  525. end;
  526. SrmPrimeWakeupHandler := __SrmPrimeWakeupHandler(portId, minBytes);
  527. end;
  528. end.