Tja also so einfach kann es manchmal sein...
Code:' ************************************************************* ' ' Proxileser ' Protect Proxileser an Portb ' (b.0=Data, b.2=Clock, b.3=Chipdetect) ' ' ************************************************************* ' ' $crystal = 16000000 $baud = 19200 $regfile = "m32def.dat" Dim Mc_ar(100) As Byte Dim Mc_b As Byte Dim Mc_a As Byte Dim Rc_x As Byte Dim Rc_str As String * 8 Dim Rc_binstr As String * 100 Dim Rc_lng As Long Dim L As Long Dim X As Byte Declare Function Recode() As Long _mport Alias Pinb 'all pins are connected to PINB _mdata Alias 0 'data line (blue) PORTB.0 _mcs Alias 1 'CS line (yellow) PORTB.1 _mclock Alias 2 'clock line (green) PORTB.2 Config Portb = Input 'we only need bit 0,1 and 2 for input Portb = 255 'make them high Do Cls Locate 1 , 1 Lcd "BEREIT fuer CHIP" Readmagcard Mc_ar(1) , Mc_b , 5 'read the data L = Recode() ' Umwandeln der Daten Print L ' Ausgabe des Ergebnisses Wait 3 ' Kurz warten Loop End ' ******************************************************************************************* Function Recode() As Long Rc_binstr = "" ' Den String leeren For Rc_x = 1 To Mc_b Rc_str = Bin(mc_ar(rc_x)) ' Die im Array abgelegte Zahlen umwandeln Rc_str = Right(rc_str , 2) ' Nur die lezten 2 Bit werden benötigt Rc_binstr = Rc_binstr + Rc_str ' Diese Bits in den String ablegen Next Rc_x Rc_binstr = Right(rc_binstr , 32) ' Abschneiden da ein Long 32 Bit hat Rc_lng = Binval(rc_binstr) ' das ganze in eine Zahl umwandeln Recode = Rc_lng ' Ermittelter Wert zürückgeben ' wenn die Zahl vom Readmagcard-Befehl in binär umgewandelt wird ' und jedes 2er päärchen einzeln wieder als Zahl dargestellt wird, ' kommst man auf den Bascom Wert. ' Beispiel: 302978763 ' binär = (0)1 00 10 00 00 11 11 00 01 01 10 11 00 10 11 ' ============================================================ ' umcodiert = 1 0 2 0 0 3 3 0 1 1 2 3 0 2 3 End Function
Danke chr-mt für Deinen Tipp







Zitieren

Lesezeichen