Um nur ein Bit in der SPS zu setzen würde ich die Funktion daveWriteBits nehmen, weil du damit einfch nur das eine Bit setzten/rücksetzen kannst und nicht das ganze Byte überschreibst.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
dc.daveWriteBits(libnodave.daveDB, 51, 3, 2, puffer)
End Sub
Dim puffer(8) As Byte
Dim puffer As Boolean = True
Das mag die SPS nicht. Bits können nur einzeln geschrieben werden. Oder löst das libnodave auf?Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click daveWriteBits(dc,libnodave.daveDB, 51, 3, 2, puffer) End Sub
So dürfte das eigentlich gehen, dann schreibst du ab DB51.DBX 0.3 2 Bit!
Ich hatte gedacht, dass man mit der 3 das Byte und mit der 2 das Bit angibt.So dürfte das eigentlich gehen, dann schreibst du ab DB51.DBX 0.3 2 Bit!Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click daveWriteBits(dc,libnodave.daveDB, 51, 3, 2, puffer) End Sub
daveWriteBits(dc,libnodave.daveDB, 51, 3, [U][B]1[/B][/U], puffer)
Dim puffer(8) As Byte
puffer = 1
daveWriteBits(dc,libnodave.daveDB, 51, 3, 1, puffer)
Dim puffer() As Byte = {"1"}
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
dc.writeBits(libnodave.daveDB, 51, 3, 1, puffer)
End Sub
Das mag die SPS nicht. Bits können nur einzeln geschrieben werden. Oder löst das libnodave auf?
Ich hab das ehrlich gesagt noch nie ausprobiert, aber ich denke mal nicht, dass die Länge da umsonst mit drinnen ist.
[COLOR=#0000ff][COLOR=#0000ff]Public[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Shared[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Function[/COLOR][/COLOR] SetBit([COLOR=#0000ff][COLOR=#0000ff]ByRef[/COLOR][/COLOR] Byt [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Byte[/COLOR][/COLOR], [COLOR=#0000ff][COLOR=#0000ff]ByVal[/COLOR][/COLOR] Bit [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Integer[/COLOR][/COLOR], [COLOR=#0000ff][COLOR=#0000ff]ByVal[/COLOR][/COLOR] State [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Boolean[/COLOR][/COLOR]) [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Boolean[/COLOR]
[/COLOR][COLOR=#0000ff][COLOR=#0000ff]Try[/COLOR]
[/COLOR][COLOR=#0000ff][COLOR=#0000ff]If[/COLOR][/COLOR] Bit > 7 [COLOR=#0000ff][COLOR=#0000ff]Then[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Return[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]False[/COLOR]
[/COLOR][COLOR=#0000ff][COLOR=#0000ff]Dim[/COLOR][/COLOR] OrMask [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Byte[/COLOR][/COLOR] = [COLOR=#0000ff][COLOR=#0000ff]CType[/COLOR][/COLOR](&H1 << Bit, [COLOR=#0000ff][COLOR=#0000ff]Byte[/COLOR][/COLOR])
[COLOR=#0000ff][COLOR=#0000ff]Dim[/COLOR][/COLOR] AndMask [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Byte[/COLOR][/COLOR] = [COLOR=#0000ff][COLOR=#0000ff]CType[/COLOR][/COLOR](&HFF [COLOR=#0000ff][COLOR=#0000ff]Xor[/COLOR][/COLOR] OrMask, [COLOR=#0000ff][COLOR=#0000ff]Byte[/COLOR][/COLOR])
[COLOR=#0000ff][COLOR=#0000ff]If[/COLOR][/COLOR] State = [COLOR=#0000ff][COLOR=#0000ff]True[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Then[/COLOR]
[/COLOR]Byt = Byt [COLOR=#0000ff][COLOR=#0000ff]Or[/COLOR][/COLOR] OrMask
[COLOR=#0000ff][COLOR=#0000ff]Return[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]True[/COLOR]
[/COLOR][COLOR=#0000ff][COLOR=#0000ff]Else[/COLOR]
[/COLOR]Byt = Byt [COLOR=#0000ff][COLOR=#0000ff]And[/COLOR][/COLOR] AndMask
[COLOR=#0000ff][COLOR=#0000ff]Return[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]True[/COLOR]
[/COLOR][COLOR=#0000ff][COLOR=#0000ff]End[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]If[/COLOR]
[/COLOR][COLOR=#0000ff][COLOR=#0000ff]Catch[/COLOR][/COLOR] ex [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] Exception
[COLOR=#0000ff][COLOR=#0000ff]Return[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]False[/COLOR]
[/COLOR][COLOR=#0000ff][COLOR=#0000ff]End[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Try[/COLOR]
[/COLOR][COLOR=#0000ff][COLOR=#0000ff]End[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Function[/COLOR][/COLOR]
[COLOR=#0000ff]
[/COLOR][COLOR=#0000ff][COLOR=#0000ff]Public[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Shared[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Function[/COLOR][/COLOR] GetBit([COLOR=#0000ff][COLOR=#0000ff]ByRef[/COLOR][/COLOR] Byt [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Byte[/COLOR][/COLOR], [COLOR=#0000ff][COLOR=#0000ff]ByVal[/COLOR][/COLOR] Bit [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Integer[/COLOR][/COLOR]) [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Boolean[/COLOR]
[/COLOR][COLOR=#0000ff][COLOR=#0000ff]Try[/COLOR]
[/COLOR][COLOR=#0000ff][COLOR=#0000ff]If[/COLOR][/COLOR] Bit > 7 [COLOR=#0000ff][COLOR=#0000ff]Then[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Return[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]False[/COLOR]
[/COLOR][COLOR=#0000ff][COLOR=#0000ff]Dim[/COLOR][/COLOR] AndMask [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Byte[/COLOR][/COLOR] = [COLOR=#0000ff][COLOR=#0000ff]CType[/COLOR][/COLOR](&H1 << Bit, [COLOR=#0000ff][COLOR=#0000ff]Byte[/COLOR][/COLOR])
[COLOR=#0000ff][COLOR=#0000ff]Return[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]CType[/COLOR][/COLOR](((Byt [COLOR=#0000ff][COLOR=#0000ff]And[/COLOR][/COLOR] AndMask) >> Bit) [COLOR=#0000ff][COLOR=#0000ff]And[/COLOR][/COLOR] &H1, [COLOR=#0000ff][COLOR=#0000ff]Boolean[/COLOR][/COLOR])
[COLOR=#0000ff][COLOR=#0000ff]Catch[/COLOR][/COLOR] ex [COLOR=#0000ff][COLOR=#0000ff]As[/COLOR][/COLOR] Exception
[COLOR=#0000ff][COLOR=#0000ff]Return[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]False[/COLOR]
[/COLOR][COLOR=#0000ff][COLOR=#0000ff]End[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Try[/COLOR]
[/COLOR][COLOR=#0000ff][COLOR=#0000ff]End[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Function[/COLOR]
[/COLOR][COLOR=#0000ff][COLOR=#0000ff]End[/COLOR][/COLOR] [COLOR=#0000ff][COLOR=#0000ff]Class[/COLOR]
[/COLOR]
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?