Hello, Ive been trying for about a week to get the parallel port plugin working with hs2. My coding skills are very limited (web stuff, php ,ect.)
The prob. is with GetDevice needing to be switched to GetDeviceEnumerator. Im at a complete loss at how this is done.
Could someone please look at this code and give me a hand.
The hs1 working code.
Ive tried this which will create the 12 devices but it sets all 12 output pins on, and on/off from hs2 has no effect .
Any help would be great.
Also heres the full vb source. the vb project is in the pportIO folder. the port95nt folder has the need DLPORTIO.BAS
The prob. is with GetDevice needing to be switched to GetDeviceEnumerator. Im at a complete loss at how this is done.
Could someone please look at this code and give me a hand.
The hs1 working code.
Code:
Sub CreateDevices() Dim i As Integer Dim j As Integer Dim h As Integer Dim d As Integer Dim index As Integer Dim dv Dim unit As Integer Dim house_code As String Dim dev_code As Integer On Error Resume Next Screen.MousePointer = vbHourglass ' first, check to see if our devices are created already h = "[" For j = 1 To MAX_IO_CODES For i = 1 To hs.DeviceCount Set dv = hs.GetDevice(i) If dv.interface = IFACE_NAME And dv.iotype = IOTYPE_VARIABLE Then MsgBox "Your variables appear to be created already. Please delete them before attempting to rebuild them", vbExclamation + vbOKOnly Screen.MousePointer = vbDefault Exit Sub End If Next h = Chr(Asc(h) + 1) Next ' create 6 variables ' call back to HS to get a free housecode house_code = callback.GetNextFreeIOCode ' exit if all codes are used If house_code = -1 Then MsgBox "HSPI_PPortIO ERROR. Sorry, all device codes used", vbCritical + vbOKOnly Screen.MousePointer = vbDefault Exit Sub End If ' save this for restore later SaveSetting "hspi_PPortIO", "Settings", "gbasecode", house_code SaveSetting "hspi_PPortIO", "Settings", "LPTport", Port gbasecode = Chr(house_code) ' create the devices ' note the special "iotype" property that must be set dev_code = 1 For i = 0 To 11 index = hs.NewDevice("Variable " + Trim(Str(i))) Set dv = hs.GetDevice(index) dv.location = "PPortIO Device" dv.hc = Chr(house_code) dv.dc = Trim(Str(dev_code)) dv.interface = IFACE_NAME dv.iotype = IOTYPE_VARIABLE dv.Status = NO_X10 dv.misc = 0 ' On/Off only, no dim dv.dev_type_string = "PPortIO Variable" dev_code = dev_code + 1 Next Screen.MousePointer = vbDefault MsgBox "Created 12 devices" End Sub
Code:
Sub CreateDevices() Dim i As Integer Dim j As Integer Dim h As Integer Dim d As Integer Dim index As Integer Dim dv As Object Dim lIndex As Integer ' Dim dv Dim unit As Integer Dim house_code As String Dim dev_code As Integer Dim DE As Object On Error Resume Next Screen.MousePointer = vbHourglass ' first, check to see if our devices are created already DE = hs.GetDeviceEnumerator If Not DE Is Nothing Then Do While Not DE.Finished dv = DE.GetNext If Not dv Is Nothing Then If dv.interface = IFACE_NAME Then ' already exist, just exit Exit Sub End If End If Loop End If ' create 6 variables ' call back to HS to get a free housecode house_code = callback.GetNextFreeIOCode ' exit if all codes are used If house_code = -1 Then MsgBox "HSPI_PPortIO ERROR. Sorry, all device codes used", vbCritical + vbOKOnly Screen.MousePointer = vbDefault Exit Sub End If ' save this for restore later SaveSetting "hspi_PPortIO", "Settings", "gbasecode", house_code SaveSetting "hspi_PPortIO", "Settings", "LPTport", Port gbasecode = Chr(house_code) ' create the devices ' note the special "iotype" property that must be set dev_code = 1 ' this is a good place to actually assign the real zone names For i = 0 To 11 lIndex = hs.NewDeviceRef("Zone " & Trim(Str(i))) dv = hs.GetDeviceByRef(lIndex) dv.location = "PPortIO Device" dv.hc = Chr(house_code) dv.dc = Trim(Str(dev_code)) dv.interface = IFACE_NAME dv.iotype = IOTYPE_VARIABLE dv.Status = NO_X10 dv.misc = 0 ' On/Off only, no dim dv.dev_type_string = "PPortIO Variable" dev_code = dev_code + 1 Next Screen.MousePointer = vbDefault MsgBox "Created 12 devices" End Sub
Also heres the full vb source. the vb project is in the pportIO folder. the port95nt folder has the need DLPORTIO.BAS
Comment