cen/xfs how to initialize a ptr_raw_data to send code page to the printer

257 Views Asked by At

I'm trying to sent to the printer the follow command to setup the printer with code page 500, but this doesnt works for me, I need to sent this 1B 74 02 in the initialization of the raw_data. By doing this, I lose all encodings.

enter image description here

std::string fmtData = text;
LPBYTE buffer[6];

memset(buffer, 0x00, sizeof(buffer));
buffer[0] = (LPBYTE)0x1B;
buffer[1] = (LPBYTE)0x74;
buffer[2] = (LPBYTE)0x02;

WFSPTRRAWDATA print_data = {
        WFS_PTR_INPUTDATA,
        fmtData.size(),
        (LPBYTE)buffer
    };

wfs_execute(WFS_CMD_PTR_RAW_DATA, &print_data, TIMEOUT_WFS_CMD_PTR_RAW_DATA, wfsResult);

1

There are 1 best solutions below

0
Marcos Dalte On

I discover my trouble, I was trying to do every in the same time, e.g to send text e codepage. But I can to do it separatelly and this way worked for me.

Step 1: to send codepage to the printer

const char *command = "\x1B\x74\x02";

WFSPTRRAWDATA print_data = {
    WFS_PTR_NOINPUTDATA,
    sizeof(command),
    (LPBYTE)command
};

sep::xfs::unique_wfsresult_ptr wfsResult;
if (result = wfs_execute(WFS_CMD_PTR_RAW_DATA, &print_data, TIMEOUT_WFS_CMD_PTR_RAW_DATA, wfsResult)){
    return result;
}

Step 2: to send text

std::string fmtData = text;
replace_special_chars(fmtData);

WFSPTRRAWDATA print_data = {
    WFS_PTR_NOINPUTDATA,
    fmtData.size(),
    (LPBYTE)fmtData.c_str()
};

unique_wfsresult_ptr wfsResult;
return wfs_execute(WFS_CMD_PTR_RAW_DATA, &print_data, TIMEOUT_WFS_CMD_PTR_RAW_DATA, wfsResult);