如何在Verifone vx520中打印连接的字符? [英] How to print connected character in verifone vx520?

查看:237
本文介绍了如何在Verifone vx520中打印连接的字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在_____之类的打印纸上画一条线,下面的图片是我的字体位图

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

并且我使用此代码下载并选择我的字体以打印和打印字符

and I use this code to download and select my 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 characters don't connected together. How can I fix this problem?

推荐答案

如果您只想打印一条水平线,那么我认为创建新字体可能不是走的路.相反,可以考虑制作仅是一条水平线的图形,并像其他任何图形一样打印它.

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.

您也可以尝试将终端置于图形模式并手动绘制,尽管这会花费更多的精力.从文档(已添加重点):

You can also try putting the terminal into graphics mode and drawing it manually, although this will take more effort. From the documentation (emphasis added):

在点图形模式下,主机几乎可以完全控制该机制,并且可以在任何点位置上打印点...水平和垂直打印密度为每毫米8个点.在点图形模式下,可打印字符分为两类字符:可打印位模式和终止符.各种各样的行终止符决定了接收位模式的打印方式.

In dot graphics mode, the host has almost complete control over the mechanism and can print dots in any dot positions... The horizontal and vertical print density is eight dots per mm. In dot graphics mode, printable characters are subdivided into two groups of characters—printable bit patterns and terminators. The wide variety of line terminators determine the way that received bit patterns print.

图形图像一次通过一个点线.在打印一行图像后,纸张进入一条虚线. 图像数据以6位为增量顺序显示.位8取决于奇偶性;位7始终为1;其余位是图形图像位.对于图形图像位,位6是最左边的位,位0是最右边的位.发送的第一个代码代表最左边的支架位置,最后一个字符代表最右边的支架位置,依此类推.

Graphic images are constructed one dot line-at-a-time in one pass. Paper feeds one dot-line after one line of image prints. The data for the image is presented sequentially in 6-bit increments. Bit 8 depends on parity; bit 7 is always 1; the remaining bits are the graphic-image bits. For graphic image bits, bit 6 is the leftmost bit and bit 0 is rightmost. The first code sent represents the leftmost carriage position, the last character the rightmost carriage position, and so on.

由于机制配置,图像数据格式构造为384 每条点线的点数.主机每条虚线最多可以发送64个图像代码, 和一个终止符代码.

Due to mechanism configuration, the image data format is constructed as 384 dots per dot line. The host can send a maximum of 64 image code per dot-line, and one terminator code.

注意:图像代码不得小于十六进制数字40;终止符不得小于20的十六进制数字.

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

因此,将打印字符定义为 P 1 G G G G G G 其中P =由字格式定义的奇偶校验",1 =常数1,G是图形位

So the print characters are defined to be P 1 G G G G G G Where P = "Parity as defined by word format", 1=constant 1, and G is a graphics bit

终止符char被定义为 P 0 1 0 EXIT X X FEED其中P =字格式定义的奇偶校验",0是常数0,1是常数1,"EXIT"允许您退出图形模式(0 =不退出,1 =退出),X会被忽略,而"FEED"则允许您发送换行符.

The terminator char is defined to be P 0 1 0 EXIT X X FEED where P = "Parity as defined by word format", 0 is a constant 0, 1 is a constant 1, "EXIT" allows you to exit graphics mode (0=don't exit, 1=exit), X is ignored, and "FEED" allows you to send a line feed.

我不确定此示例代码是否可以按原样工作,但是如果您想使用它,至少可以起步:

I'm not sure if this sample code will work as-is, but it should at least get you 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);

最后的提示:我只是看了很久以前编写的一些使用图形模式的代码,看起来我不太注意奇偶校验,因此您也许可以摆脱困境始终为0.

Final note: I was just looking at some code I had written quite a long time ago that uses graphics mode and it doesn't look like I'm paying any attention to parity, so you may be able to get away with that always being 0.

这篇关于如何在Verifone vx520中打印连接的字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆