

The 32 bit version of Microsoft Visual Basic 4.0 can now be used to interact
with the Windows NT versions of the Oregon Micro Systems device drivers.
Device driver access is provided via the NTDRV.DLL.

Installation and use:

Copy NTDRV.DLL from the distribution disk to the \windows\system directory.

Place the following DLL function call definitions in a global module with in
your Visual Basic Project:

Declare Function GetOmsHandle Lib "ntdrv" (ByVal DeviceName As String) As Long

Declare Sub CloseOmsHandle Lib "ntdrv" (ByVal Handle As Long)

Declare Function GetDriverVersion Lib "ntdrv" (ByVal Handle As Long, _
                                                ByVal Version As String _
                                               ) As Boolean
                                               
Declare Function SendAndGetString Lib "ntdrv" (ByVal Handle As Long, _
                                                ByVal Command As String, _
                                                ByVal Response As String _
                                               ) As Boolean
                                               
Declare Function SendString Lib "ntdrv" (ByVal Handle As Long, _
                                          ByVal Command As String _
                                         ) As Boolean
                                         
Declare Function GetDoneFlags Lib "ntdrv" (ByVal Handle As Long, _
                                            ByRef Flags As Byte _
                                           ) As Boolean
                                           
Declare Function GetStatusFlags Lib "ntdrv" (ByVal Handle As Long, _
                                              ByRef Flags As Byte _
                                             ) As Boolean
                                             
Declare Function ClrDoneFlags Lib "ntdrv" (ByVal Handle As Long, _
                                            ByRef Mask As Byte _
                                           ) As Boolean
                                           
Declare Function ClrStatusFlags Lib "ntdrv" (ByVal Handle As Long, _
                                              ByRef Mask As Byte _
                                             ) As Boolean
                                             
Declare Function ResetOmsController Lib "ntdrv" (ByVal Handle As Long _
                                                 ) As Boolean


The following Visual Basic code was used to test Visual Basic access
to the OMS device driver functions.  It provides examples of how to
call the DLL's functions.

Private Sub Command1_Click()
  'Test Visual Basic 4.0 access to NTDRV DLL functions
  
  'Receives OMS device driver handle
  Dim Handle As Long
  
  'Reserve fixed length string to receive driver version
  Dim Version As String * 128
  
  'Reserve fixed length string to receive query responses
  Dim Response As String * 128
  
  'Reserve bytes to receive Done & controller status
  Dim DoneStatus As Byte
  Dim FlagStatus As Byte
  
  Dim DeviceName As String
  Dim Status As Boolean
  
  Dim AxisSelection As Byte
  Dim FlagSelection As Byte
  
  'Get a controller board device handle
  Handle = GetOmsHandle("OMS1")
  
  'Get the driver's version text string and display it
  Status = GetDriverVersion(Handle, Version)
  MsgBox "Version = " & Version
  
  'Reset the controller to its power on state
  Status = ResetOmsController(Handle)
  
  'Select the X & Y axes and clear their done flags
  AxisSelection = &H3
  Status = ClrDoneFlags(Handle, AxisSelection)
  'Command an X & Y axis move
  Status = SendString(Handle, "AAMR10000,200;GDID")
  'Wait for the moves to complete
  Do
     Status = GetDoneFlags(Handle, DoneStatus)
  Loop Until ((DoneStatus And AxisSelection) = AxisSelection)
  'Get the new axis positions and report them
  Status = SendAndGetString(Handle, "AARP", Response)
  MsgBox "New Positions =" & Response
  'Report the done flag status after the move
  MsgBox "Done Flags =" & CStr(DoneStatus)
  'Clear the X & Y axis done flags
  AxisSelection = &H3
  Status = ClrDoneFlags(Handle, AxisSelection)
  'Report the done flag status after the clear
  Status = GetDoneFlags(Handle, DoneStatus)
  MsgBox "Done Flags after clear" & CStr(DoneStatus)
  
  'Make sure all of the controller status flags are clear
  FlagSelection = &HF
  Status = ClrStatusFlags(Handle, FlagSelection)
  'Force a command  error
  Status = SendString(Handle, "ZZ;")
  'Wait for the controller to set the error flag
  FlagSelection = &H1
  Do
     Status = GetStatusFlags(Handle, FlagStatus)
  Loop Until ((FlagStatus And FlagSelection) = FlagSelection)
  'Report the controller status
  MsgBox "Command error status =" & CStr(FlagStatus)
  'Clear the command error flag
  FlagSelection = &H1
  Status = ClrStatusFlags(Handle, FlagSelection)
  'Report the flag status after the clear
  Status = GetStatusFlags(Handle, FlagStatus)
  MsgBox "Controller Flags after clear" & CStr(FlagStatus)
  
  'Release the OMS board's driver handle
  CloseOmsHandle (Handle)
  
End Sub


