How to print linked character in verifone vx520?

I want to draw a line in printed paper like _____ and in the picture below is a bitmap of the font font bitmaps

and i use this code to download and select font to printer and print characters

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <svc.h>
#include <printer.h>

int main() {
    int retVal;
    int handle;
    open_block_t parm;
    int h_font_file;
    char print[32] = {43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43};

    handle = open("/dev/com4", 0);

    memset(&parm, 0, sizeof (parm));
    parm.rate = Rt_19200;
    parm.format = Fmt_A8N1 | Fmt_auto | Fmt_RTS;
    parm.protocol = P_char_mode;
    parm.parameter = 0;
    set_opn_blk(handle, &parm);
    SVC_WAIT(200);
    p3700_init(handle, 6);
    SVC_WAIT(100);

    /****************SETUP FONT******************/
    h_font_file = open("8x16.pft", O_RDONLY); //load font
    retVal = p3700_dnld_font_file(handle, h_font_file, 2); //set font
    SVC_WAIT(100);
    retVal = p3700_select_font(handle, 0x03, 2);


    retVal = write(handle, print, 32);

    printf("printf: %d\n", retVal);

    retVal = write(handle, "\n\n\n\n", 4);

    SVC_WAIT(100);

    return 0;
}

      

but the result is the image below and the symbols are not related to each other. How can I fix this problem? result

0


source to share


1 answer


If all you want to do is print a horizontal line then I think creating a new font is probably not the way to go. Instead, consider making a graphic that is just a horizontal line and printing it like any other graphic file .

You can also try putting the terminal in graphical mode and drawing it by hand, although this will take more effort. From the documentation (emphasis mine):

In dot mode, the host has almost complete control over the mechanism and can print dots anywhere ... The density of horizontal and vertical printing is eight dots per mm. In bitmap mode, printable characters are classified into two groups of characters โ€” printable bit patterns and terminators. The wide variety of line terminators determines how the resulting bit patterns are printed.

Graphics are drawn one dotted line at a time in one pass. The paper feeds one exact line after printing one line. The data for the image is presented sequentially in 6-bit steps. Bit 8 is parity dependent; bit 7 is always 1; the rest of the bits are graphics bits. For graphics bits, bit 6 is the left-most bit and bit 0 is the right-most. The first code sent is the leftmost carriage position, the last character is the rightmost carriage position, and so on.

Due to the configuration of the engine, the image data format is plotted as 384 dots per dot. The host can send a maximum of 64 image codes per dot, and one terminator code.

NOTE. Image code must not be less than hex 40; the terminator must not be less than hex 20.

Thus, print characters are defined as P 1 G G G G G G

Where P = "Word format parity", 1 = constant 1, and G is a graphics bit



The char terminator is defined as P 0 1 0 EXIT X X FEED

where P = "Word format parity", 0 is a constant 0, 1 is a constant 1, "EXIT" exits graphics mode (0 = do not exit, 1 = exit), X is ignored, and "FEED "allows you to post lines.

I'm not sure if this sample code will work as it is, but it should at least get started if you want to play with it:

char line[65]; /* room for 64 image codes + 1 terminator code 
                 (if using all 64, no line feed should be used
                  as it will drop down on its own) */
memset(line, 0, sizeof(line));

// ENTER GRAPHICS MODE
line[0] = ESC; // ESC is defined as 0x1B
line[1] = 'g';
p350_print(hPrinter, line);

for(int i = 0; i<sizeof(line); i++)
    line[i] = 0x7F;

line[sizeof(line)-1] = 0x29;
p350_print(hPrinter, line);

      

Final note: I was just looking at some code that I wrote quite a while ago using graphics mode and it doesn't seem like I'm paying attention to parity, so you can get away with which is always 0.

+2


source







All Articles