Shop OBEX P1 Docs P2 Docs Learn Events
Printing Issue RFID card — Parallax Forums

Printing Issue RFID card

Luis_PLuis_P Posts: 246
edited 2012-09-05 19:01 in BASIC Stamp
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"

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-09-04 08:46
    Change
    [STR buf\4,10]
    in Read_Tag1 to
    [STR buf\4]
  • Luis_PLuis_P Posts: 246
    edited 2012-09-04 10:25
    I think I tried that, what it does is print only the last name, the memory address 4 only, the one with the 10 command.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-09-04 10:31
    10 is the ASCII code for a Line Feed.

    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
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-09-04 16:50
    Hello? Hello? Operator? I think I've been disconnected.

    [Thunk, Thunk, Thunk... Testing, Testing 1, 2, 3... Is this thing working?]
  • Luis_PLuis_P Posts: 246
    edited 2012-09-04 21:12
    PJ Allen wrote: »
    10 is the ASCII code for a Line Feed.

    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



    So you saying this will print the name, make an space and no feed the paper?
    SEROUT printerPin, 32, [STR buf\4," "]
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-09-05 04:50
    Seems to me.

    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?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-09-05 19:01
    Systems based on ASCII or a compatible character set use either LF (Line feed, '\n', 0x0A, 10 in decimal) or CR (Carriage return, '\r', 0x0D, 13 in decimal) individually, or CR followed by LF (CR+LF, '\r\n', 0x0D0A). These characters are based on printer commands:
    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)
Sign In or Register to comment.