0

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
    `LPBYTE buffer[6]` is a 6 pointers to byte array, not an array of 6 bytes. You only need to change that array definition to `BYTE buffer[6]`, set the three bytes, and set the ulSize to 3. That command is vendor dependent, so your SPI and your printer must support it to work. – SuperG280 Aug 09 '21 at 10:57

1 Answers1

0

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);