Peoples...
I'm trying to write a simple read/write application for a Magnetic Card Reader/writer (Tyner) I'm able to get everything off the card just fine, and it appears to to be working to write. However, when I scan the card it reads like this:
I wrote to the card (first track only):
abcdefghijklmnopqrstuvwxyz
got back:
!"#$%&'()*+,-./0123456789:
Appears to be transposing.
wx button code
-
def Write(self, event):
-
chk = False
-
Connection = SerialConnection()
-
Connection.flush()
-
dialog = wx.TextEntryDialog(None, "*****:", caption="Paste here...", defaultValue="", style=wx.OK|wx.CANCEL)
-
if dialog.ShowModal() == wx.ID_OK:
-
if Connection.chkConnection(chk) == True :
-
print dialog.Value
-
str = dialog.Value
-
Connection.write(str)
-
#wx.Exit()
-
-
else:
-
print 'Connection Error!'
-
else:
-
print 'User canceled'
-
Serial class I made, write method:
-
-
def write(self,str):
-
#Byte Codes:
-
escape = 0x1b
-
track1 = 0x01
-
EndMark = 0x3f
-
FileSeparator = 0x1c
-
#input string
-
input = chr(escape) + chr(track1) + str
-
-
-
self.ser.write(chr(escape) + '\x77')
-
output = self.ser.read(size=100)
-
time.sleep(.1)
-
self.ser.write(chr(escape) + '\x73' + input)
-
self.ser.write(chr(EndMark) + chr(FileSeparator))
-
-
output = self.ser.read(size=100)
-
print output + ' ' + ' --Error'
-
print "wrote: " + ' ' + input
-
-
I should mention I'm pretty new to Python :) sorry for the messy code.