Printing Issue RFID card
Luis_P
Posts: 246
Hi; I have a problen getting the RFID badges to print the stored names in a little printer I got from spurkfun.com. I had the code before working before the way I need but my laptop got stolen and the code is gone! I need to figure what I did before but I can't remember. Everything works fine except I need to print the last name next to the first name just like this:
John Pott
But instead prints the name, feeds 1 line and then print the last name on the paper, just like this:
John
Pott
How can I have everything in one line? I saved John in memory address 3 and Pott and memory address 4. The printer manual is attached
Printer link: https://www.sparkfun.com/products/10438
A2-user manual-1.pdf
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[ Constants ]
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
T9600 CON 84
#CASE BS2SX, BS2P
T9600 CON 240
#ENDSELECT
Baud CON T9600
' RFID R/W Module Commands
' Number of bytes returned in ()
RFID_Read CON $01 ' Read data from specified address, valid locations 1 to 33 (5)
RFID_Write CON $02 ' Write data to specified address, valid locations 3 to 31 (1)
' Status/error return codes
ERR_OK CON $01 ' No errors
'
[ Variables ]
buf VAR Byte(4) ' data buffer
PAUSE 500
printerPin PIN 3 ' Conect RX output of printer to pin 3 of Bs2
heatTime CON 80
heatInterval CON 255
printDensity CON 15
printBreakTime CON 15
'TO initialize the printer:
SEROUT printerPin, 32, [27, 55, 7, heatTime, heatInterval, 18, 35, (printDensity<<4) | printBreakTime ]
Read_Tag1:
SEROUT 0, Baud, ["!RW", RFID_Read, 3] ' Read data from address
SERIN 1, Baud, [STR buf\4] ' Get status byte and data bytes
IF buf(0) <> ERR_OK THEN Read_Tag1 ' If we get an error, keep trying until the read is successful
SEROUT printerPin, 32, [STR buf\4,10] 'Print "John"
Read_Tag2:
SEROUT 0, Baud, ["!RW", RFID_Read, 4]
SERIN 1, Baud, [STR buf\4]
IF buf(0) <> ERR_OK THEN Read_Tag2
SEROUT printerPin, 32, [STR buf\4,10] 'Print "Pott"
John Pott
But instead prints the name, feeds 1 line and then print the last name on the paper, just like this:
John
Pott
How can I have everything in one line? I saved John in memory address 3 and Pott and memory address 4. The printer manual is attached
Printer link: https://www.sparkfun.com/products/10438
A2-user manual-1.pdf
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[ Constants ]
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
T9600 CON 84
#CASE BS2SX, BS2P
T9600 CON 240
#ENDSELECT
Baud CON T9600
' RFID R/W Module Commands
' Number of bytes returned in ()
RFID_Read CON $01 ' Read data from specified address, valid locations 1 to 33 (5)
RFID_Write CON $02 ' Write data to specified address, valid locations 3 to 31 (1)
' Status/error return codes
ERR_OK CON $01 ' No errors
'
[ Variables ]
buf VAR Byte(4) ' data buffer
PAUSE 500
printerPin PIN 3 ' Conect RX output of printer to pin 3 of Bs2
heatTime CON 80
heatInterval CON 255
printDensity CON 15
printBreakTime CON 15
'TO initialize the printer:
SEROUT printerPin, 32, [27, 55, 7, heatTime, heatInterval, 18, 35, (printDensity<<4) | printBreakTime ]
Read_Tag1:
SEROUT 0, Baud, ["!RW", RFID_Read, 3] ' Read data from address
SERIN 1, Baud, [STR buf\4] ' Get status byte and data bytes
IF buf(0) <> ERR_OK THEN Read_Tag1 ' If we get an error, keep trying until the read is successful
SEROUT printerPin, 32, [STR buf\4,10] 'Print "John"
Read_Tag2:
SEROUT 0, Baud, ["!RW", RFID_Read, 4]
SERIN 1, Baud, [STR buf\4]
IF buf(0) <> ERR_OK THEN Read_Tag2
SEROUT printerPin, 32, [STR buf\4,10] 'Print "Pott"
pdf
402K
Comments
[STR buf\4,10]
in Read_Tag1 to
[STR buf\4]
SEROUT printerPin, 32, [STR buf\4,10] ' Print "John" followed by a Line Feed
SEROUT printerPin, 32, [STR buf\4," "] ' Print "John" followed by a space
[Thunk, Thunk, Thunk... Testing, Testing 1, 2, 3... Is this thing working?]
So you saying this will print the name, make an space and no feed the paper?
SEROUT printerPin, 32, [STR buf\4," "]
SEROUT printerPin, 32, ["John"," ","Pott",[COLOR="#006400"]10[/COLOR]]
ought to print
John Pott
followed by a line feed
Are you running out of paper?
The line feed indicated that one line of paper should feed out of the printer thus instructed the printer to advance the paper one line, and a carriage return indicated that the printer carriage should return to the beginning of the current line. Some rare systems, such as QNX before version 4, used the ASCII RS (record separator, 0x1E, 30 in decimal) character as the newline character.
(de wikipedia)