|
@@ -6,7 +6,7 @@
|
|
|
|
|
|
|
|
using boost::asio::ip::tcp;
|
|
using boost::asio::ip::tcp;
|
|
|
|
|
|
|
|
-CPosPrinter::CPosPrinter(): m_socket(m_io)
|
|
|
|
|
|
|
+CPosPrinter::CPosPrinter() : m_socket(m_io)
|
|
|
{
|
|
{
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -15,29 +15,13 @@ CPosPrinter::~CPosPrinter()
|
|
|
{
|
|
{
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/*
|
|
|
|
|
- *找到所有可用的小票打印机,包括USB、并口、串口3个类型
|
|
|
|
|
- **/
|
|
|
|
|
-bool CPosPrinter::InitShouyin()
|
|
|
|
|
|
|
+void CPosPrinter::InitUsb()
|
|
|
{
|
|
{
|
|
|
- //先找USB的
|
|
|
|
|
-
|
|
|
|
|
- //设备路径
|
|
|
|
|
- TCHAR* szDevicePath[MAX_DEVICE];
|
|
|
|
|
-
|
|
|
|
|
//设置中文字符
|
|
//设置中文字符
|
|
|
setlocale(LC_CTYPE, "chs");
|
|
setlocale(LC_CTYPE, "chs");
|
|
|
|
|
|
|
|
- TCHAR* Port = NULL;
|
|
|
|
|
-
|
|
|
|
|
- //分配需要的空间
|
|
|
|
|
- for(int i = 0; i < MAX_DEVICE; i++)
|
|
|
|
|
- {
|
|
|
|
|
- szDevicePath[i] = new TCHAR[MAX_PATH];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
//取设备路径
|
|
//取设备路径
|
|
|
- int nDevice = GetDevicePath((LPGUID)&USB_GUID, szDevicePath);
|
|
|
|
|
|
|
+ int nDevice = GetDevicePath((LPGUID)&USB_GUID);
|
|
|
LOG_INFO("可用的USB打印机数量:" << nDevice);
|
|
LOG_INFO("可用的USB打印机数量:" << nDevice);
|
|
|
|
|
|
|
|
//添加usb端口
|
|
//添加usb端口
|
|
@@ -45,10 +29,9 @@ bool CPosPrinter::InitShouyin()
|
|
|
|
|
|
|
|
while(i < nDevice)
|
|
while(i < nDevice)
|
|
|
{
|
|
{
|
|
|
- Port = szDevicePath[i++];
|
|
|
|
|
- LOG_INFO("准备打开端口 Port = " << Port);
|
|
|
|
|
|
|
+ LOG_INFO("准备打开端口 Port = " << m_usb_devices[i].c_str());
|
|
|
|
|
|
|
|
- HANDLE hPort = CreateFile(Port, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
|
|
|
|
|
|
|
+ HANDLE hPort = CreateFile(m_usb_devices[i].c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
|
|
|
|
|
|
|
|
if(hPort == INVALID_HANDLE_VALUE)
|
|
if(hPort == INVALID_HANDLE_VALUE)
|
|
|
{
|
|
{
|
|
@@ -84,12 +67,54 @@ bool CPosPrinter::InitShouyin()
|
|
|
//端口打印机没有连接,那么就直接关闭掉并口,避免占用
|
|
//端口打印机没有连接,那么就直接关闭掉并口,避免占用
|
|
|
CloseHandle(hPort);
|
|
CloseHandle(hPort);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ i++;
|
|
|
}
|
|
}
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- //开始添加并口的端口
|
|
|
|
|
|
|
+void CPosPrinter::InitOneUsb(wstring usb_path)
|
|
|
|
|
+{
|
|
|
|
|
+ HANDLE hPort = CreateFile(usb_path.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
|
|
|
|
|
+
|
|
|
|
|
+ if(hPort == INVALID_HANDLE_VALUE)
|
|
|
|
|
+ {
|
|
|
|
|
+ // 打开端口失败
|
|
|
|
|
+ DWORD error = GetLastError();
|
|
|
|
|
+
|
|
|
|
|
+ if(error == 2)
|
|
|
|
|
+ {
|
|
|
|
|
+ //没有指定的文件
|
|
|
|
|
+ LOG_INFO("没有找对对应的usb端口");
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(error == 5)
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_INFO("usb端口被占用!");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ LOG_INFO("打开usb端口,准备进行打印机检测! hPort:" << hPort);
|
|
|
|
|
+
|
|
|
|
|
+ if(PortTest(hPort) == true)
|
|
|
|
|
+ {
|
|
|
|
|
+ //端口测试连通,保存起来
|
|
|
|
|
+ PrinterHandle newHandle;
|
|
|
|
|
+ newHandle.hPort = hPort;
|
|
|
|
|
+ newHandle.type = 1;
|
|
|
|
|
+
|
|
|
|
|
+ m_hPorts.push_back(newHandle);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ //端口打印机没有连接,那么就直接关闭掉并口,避免占用
|
|
|
|
|
+ CloseHandle(hPort);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void CPosPrinter::InitBingkou()
|
|
|
|
|
+{
|
|
|
std::wstring LptStr = L"lpt1";
|
|
std::wstring LptStr = L"lpt1";
|
|
|
|
|
|
|
|
- HANDLE hPort = CreateFile(LptStr.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
|
|
|
|
|
|
|
+ HANDLE hPort = CreateFile(LptStr.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
|
|
|
|
|
|
|
|
if(hPort == INVALID_HANDLE_VALUE)
|
|
if(hPort == INVALID_HANDLE_VALUE)
|
|
|
{
|
|
{
|
|
@@ -125,15 +150,17 @@ bool CPosPrinter::InitShouyin()
|
|
|
CloseHandle(hPort);
|
|
CloseHandle(hPort);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- //开始添加串口
|
|
|
|
|
|
|
+void CPosPrinter::InitCom()
|
|
|
|
|
+{
|
|
|
int comNum = 10;
|
|
int comNum = 10;
|
|
|
|
|
|
|
|
for(int i = 1; i <= 10; i++)
|
|
for(int i = 1; i <= 10; i++)
|
|
|
{
|
|
{
|
|
|
std::wstring com2Str = L"com" + CLewaimaiString::ANSIToUnicode(to_string(i));
|
|
std::wstring com2Str = L"com" + CLewaimaiString::ANSIToUnicode(to_string(i));
|
|
|
|
|
|
|
|
- hPort = CreateFile(com2Str.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
|
|
|
+ HANDLE hPort = CreateFile(com2Str.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
|
|
|
|
if(hPort == INVALID_HANDLE_VALUE)
|
|
if(hPort == INVALID_HANDLE_VALUE)
|
|
|
{
|
|
{
|
|
@@ -192,14 +219,27 @@ bool CPosPrinter::InitShouyin()
|
|
|
m_hPorts.push_back(newHandle);
|
|
m_hPorts.push_back(newHandle);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/*
|
|
|
|
|
+ *找到所有可用的小票打印机,包括USB、并口、串口3个类型,注意这里不包含网口
|
|
|
|
|
+ **/
|
|
|
|
|
+void CPosPrinter::InitShouyin()
|
|
|
|
|
+{
|
|
|
|
|
+ //开始添加usb
|
|
|
|
|
+ InitUsb();
|
|
|
|
|
+
|
|
|
|
|
+ //开始添加并口的端口
|
|
|
|
|
+ InitBingkou();
|
|
|
|
|
|
|
|
- return true;
|
|
|
|
|
|
|
+ //开始添加串口
|
|
|
|
|
+ InitCom();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
*获取CreateFile的USB端口号
|
|
*获取CreateFile的USB端口号
|
|
|
**/
|
|
**/
|
|
|
-int CPosPrinter::GetDevicePath(LPGUID lpGuid, LPTSTR* pszDevicePath)
|
|
|
|
|
|
|
+int CPosPrinter::GetDevicePath(LPGUID lpGuid)
|
|
|
{
|
|
{
|
|
|
HDEVINFO hDevInfoSet;
|
|
HDEVINFO hDevInfoSet;
|
|
|
SP_DEVINFO_DATA spDevInfoData;
|
|
SP_DEVINFO_DATA spDevInfoData;
|
|
@@ -300,27 +340,27 @@ int CPosPrinter::GetDevicePath(LPGUID lpGuid, LPTSTR* pszDevicePath)
|
|
|
|
|
|
|
|
if(bResult)
|
|
if(bResult)
|
|
|
{
|
|
{
|
|
|
- wstring DevicePath = pDetail->DevicePath;
|
|
|
|
|
|
|
+ wstring DevicePath = pDetail->DevicePath;
|
|
|
|
|
|
|
|
- wstring vid = DevicePath.substr(DevicePath.find(_T("vid_"), 0) + 4, 4);
|
|
|
|
|
- wstring pid = DevicePath.substr(DevicePath.find(_T("pid_"), 0) + 4, 4);
|
|
|
|
|
|
|
+ wstring vid = DevicePath.substr(DevicePath.find(_T("vid_"), 0) + 4, 4);
|
|
|
|
|
+ wstring pid = DevicePath.substr(DevicePath.find(_T("pid_"), 0) + 4, 4);
|
|
|
|
|
|
|
|
- LOG_INFO("Vid:" << vid.c_str() << ", Pid:" << pid.c_str());
|
|
|
|
|
|
|
+ LOG_INFO("Vid:" << vid.c_str() << ", Pid:" << pid.c_str());
|
|
|
|
|
|
|
|
- if (GetPrinterType(vid, pid) == 2)
|
|
|
|
|
- {
|
|
|
|
|
- //标签打印机,暂时不处理打印
|
|
|
|
|
- LOG_INFO("标签打印机,暂时不打印!");
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if(GetPrinterType(vid, pid) == 2)
|
|
|
|
|
+ {
|
|
|
|
|
+ //标签打印机,暂时不处理打印
|
|
|
|
|
+ LOG_INFO("标签打印机,暂时不打印!");
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 复制设备路径到输出缓冲区
|
|
|
|
|
- ::_tcscpy_s(pszDevicePath[nCount], 256, pDetail->DevicePath);
|
|
|
|
|
|
|
+ // 复制设备路径到输出缓冲区
|
|
|
|
|
+ m_usb_devices.push_back(DevicePath);
|
|
|
|
|
|
|
|
- // 调整计数值
|
|
|
|
|
- nCount++;
|
|
|
|
|
|
|
+ // 调整计数值
|
|
|
|
|
+ nCount++;
|
|
|
|
|
|
|
|
- LOG_INFO("Cnt = " << nCount << ",pDetail->DevicePath =" << pDetail->DevicePath);
|
|
|
|
|
|
|
+ LOG_INFO("Cnt = " << nCount << ",pDetail->DevicePath =" << pDetail->DevicePath);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -343,31 +383,60 @@ int CPosPrinter::GetDevicePath(LPGUID lpGuid, LPTSTR* pszDevicePath)
|
|
|
**/
|
|
**/
|
|
|
int CPosPrinter::GetPrinterType(wstring vid, wstring pid)
|
|
int CPosPrinter::GetPrinterType(wstring vid, wstring pid)
|
|
|
{
|
|
{
|
|
|
- if (vid == L"6868" && pid == L"0500")
|
|
|
|
|
- {
|
|
|
|
|
- //佳博标签打印机
|
|
|
|
|
- return 2;
|
|
|
|
|
- }
|
|
|
|
|
- else if (vid == L"0fe6" && pid == L"811e")
|
|
|
|
|
- {
|
|
|
|
|
- return 2;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return 1;
|
|
|
|
|
|
|
+ if(vid == L"6868" && pid == L"0500")
|
|
|
|
|
+ {
|
|
|
|
|
+ //佳博标签打印机
|
|
|
|
|
+ return 2;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/*
|
|
|
|
|
+ *打印收银小票
|
|
|
|
|
+ **/
|
|
|
void CPosPrinter::PrintWaimaiOrderShouyin(CWaimaiOrder& order)
|
|
void CPosPrinter::PrintWaimaiOrderShouyin(CWaimaiOrder& order)
|
|
|
{
|
|
{
|
|
|
//设置模式,后面输出数据不会错
|
|
//设置模式,后面输出数据不会错
|
|
|
m_type = 1;
|
|
m_type = 1;
|
|
|
|
|
|
|
|
- //初始化收银打印机的链接
|
|
|
|
|
- bool ret = InitShouyin();
|
|
|
|
|
|
|
+ std::string printer_leixing = CSetting::GetParam("setting_printer_leixing");
|
|
|
|
|
+ if(printer_leixing == "auto")
|
|
|
|
|
+ {
|
|
|
|
|
+ InitShouyin();
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(printer_leixing == "usb")
|
|
|
|
|
+ {
|
|
|
|
|
+ std::string printer_usb = CSetting::GetParam("setting_printer_usb");
|
|
|
|
|
+ std::wstring ws_printer_usb = CLewaimaiString::UTF8ToUnicode(printer_usb);
|
|
|
|
|
|
|
|
- if(ret == false)
|
|
|
|
|
|
|
+ InitOneUsb(ws_printer_usb);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(printer_leixing == "bingkou")
|
|
|
{
|
|
{
|
|
|
- LOG_INFO("打开收银打印机端口失败!");
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ InitBingkou();
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(printer_leixing == "chuankou")
|
|
|
|
|
+ {
|
|
|
|
|
+ InitCom();
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(printer_leixing == "wangkou")
|
|
|
|
|
+ {
|
|
|
|
|
+ m_type = 2;
|
|
|
|
|
+
|
|
|
|
|
+ std::string wangkou_ip = CSetting::GetParam("setting_printer_wangkou_ip");
|
|
|
|
|
+
|
|
|
|
|
+ //初始化连接
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ boost::asio::ip::tcp::endpoint ep(boost::asio::ip::address::from_string(wangkou_ip.c_str()), 9100);
|
|
|
|
|
+ m_socket.connect(ep);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(std::exception& e)
|
|
|
|
|
+ {
|
|
|
|
|
+ std::string err = e.what();
|
|
|
|
|
+ LOG_INFO("连接厨房打印机失败,IP地址:" << wangkou_ip.c_str() << ",错误信息:" << err.c_str());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//读取当前收银打印机的设置
|
|
//读取当前收银打印机的设置
|
|
@@ -521,6 +590,7 @@ void CPosPrinter::PrintWaimaiOrderShouyin(CWaimaiOrder& order)
|
|
|
|
|
|
|
|
POS_TextOut(lines);
|
|
POS_TextOut(lines);
|
|
|
POS_FeedLine();
|
|
POS_FeedLine();
|
|
|
|
|
+
|
|
|
//商品标题
|
|
//商品标题
|
|
|
bool setting_printer_shangpin_big = false;
|
|
bool setting_printer_shangpin_big = false;
|
|
|
|
|
|
|
@@ -775,7 +845,6 @@ void CPosPrinter::PrintWaimaiOrderChufang(CWaimaiOrder& order)
|
|
|
std::string fenlei_ids = printer.fenlei_ids;
|
|
std::string fenlei_ids = printer.fenlei_ids;
|
|
|
|
|
|
|
|
std::vector<CWaimaiOrderItem> cur_printer_use;
|
|
std::vector<CWaimaiOrderItem> cur_printer_use;
|
|
|
-
|
|
|
|
|
if(fenlei == "0")
|
|
if(fenlei == "0")
|
|
|
{
|
|
{
|
|
|
cur_printer_use = order.m_order_items;
|
|
cur_printer_use = order.m_order_items;
|
|
@@ -1064,6 +1133,11 @@ void CPosPrinter::PrintWaimaiOrderChufang(CWaimaiOrder& order)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+std::vector<std::wstring> CPosPrinter::getUsbDevices()
|
|
|
|
|
+{
|
|
|
|
|
+ return m_usb_devices;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
int CPosPrinter::WriteData(string msg)
|
|
int CPosPrinter::WriteData(string msg)
|
|
|
{
|
|
{
|
|
|
return WriteBuf(msg.c_str(), msg.length());
|
|
return WriteBuf(msg.c_str(), msg.length());
|
|
@@ -1082,28 +1156,30 @@ int CPosPrinter::WriteBuf(const char* buf, int len)
|
|
|
if((*it).type == 3)
|
|
if((*it).type == 3)
|
|
|
{
|
|
{
|
|
|
//串口,同步写数据
|
|
//串口,同步写数据
|
|
|
- LOG_INFO("before com writefile handle:" << hPort);
|
|
|
|
|
|
|
+ //LOG_INFO("before com writefile handle:" << hPort);
|
|
|
WriteFile(hPort, buf, len, &dwWrite, NULL);
|
|
WriteFile(hPort, buf, len, &dwWrite, NULL);
|
|
|
- LOG_INFO("after com writefile handle:" << hPort);
|
|
|
|
|
|
|
+ //LOG_INFO("after com writefile handle:" << hPort);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
//usb和并口,异步写数据
|
|
//usb和并口,异步写数据
|
|
|
OVERLAPPED overlap;
|
|
OVERLAPPED overlap;
|
|
|
memset(&overlap, 0, sizeof(overlap));
|
|
memset(&overlap, 0, sizeof(overlap));
|
|
|
- BOOL rc = WriteFile(hPort, buf, len, &dwWrite, &overlap);
|
|
|
|
|
|
|
|
|
|
|
|
+ BOOL rc = WriteFile(hPort, buf, len, &dwWrite, &overlap);
|
|
|
if(rc)
|
|
if(rc)
|
|
|
{
|
|
{
|
|
|
- LOG_INFO("writefile success immediately, handle:" << hPort);
|
|
|
|
|
|
|
+ //LOG_INFO("writefile success immediately, handle:" << hPort);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
if(GetLastError() == ERROR_IO_PENDING)
|
|
if(GetLastError() == ERROR_IO_PENDING)
|
|
|
{
|
|
{
|
|
|
- LOG_INFO("Request queued, waiting... handle:" << hPort);
|
|
|
|
|
- WaitForSingleObject(hPort, 5000);
|
|
|
|
|
- LOG_INFO("Request completed, handle:" << hPort);
|
|
|
|
|
|
|
+ //LOG_INFO("Request queued, waiting... handle:" << hPort);
|
|
|
|
|
+ WaitForSingleObject(hPort, 1000);
|
|
|
|
|
+ //LOG_INFO("Request completed, handle:" << hPort);
|
|
|
|
|
+
|
|
|
|
|
+ //计算写入了多少字节的数据
|
|
|
DWORD numread;
|
|
DWORD numread;
|
|
|
rc = GetOverlappedResult(
|
|
rc = GetOverlappedResult(
|
|
|
hPort,
|
|
hPort,
|
|
@@ -1134,19 +1210,19 @@ int CPosPrinter::WriteBuf(const char* buf, int len)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
- *测试这个并口是否连通的
|
|
|
|
|
|
|
+ *测试打印机是否连接
|
|
|
**/
|
|
**/
|
|
|
bool CPosPrinter::PortTest(HANDLE hPort)
|
|
bool CPosPrinter::PortTest(HANDLE hPort)
|
|
|
{
|
|
{
|
|
|
- char chInitCode[] = "\x1B\x40";
|
|
|
|
|
|
|
+ //标签打印机的查询状态指令
|
|
|
|
|
+ char chInitCode[2] = { 0x1b, 0x40 };
|
|
|
|
|
|
|
|
DWORD dwWrite;
|
|
DWORD dwWrite;
|
|
|
|
|
|
|
|
OVERLAPPED overlap;
|
|
OVERLAPPED overlap;
|
|
|
memset(&overlap, 0, sizeof(overlap));
|
|
memset(&overlap, 0, sizeof(overlap));
|
|
|
|
|
|
|
|
- BOOL rc = WriteFile(hPort, chInitCode, (DWORD)2L, &dwWrite, &overlap);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ BOOL rc = WriteFile(hPort, chInitCode, 2, &dwWrite, &overlap);
|
|
|
if(rc)
|
|
if(rc)
|
|
|
{
|
|
{
|
|
|
LOG_INFO("writefile success immediately, handle:" << hPort);
|
|
LOG_INFO("writefile success immediately, handle:" << hPort);
|
|
@@ -1157,11 +1233,11 @@ bool CPosPrinter::PortTest(HANDLE hPort)
|
|
|
{
|
|
{
|
|
|
if(GetLastError() == ERROR_IO_PENDING)
|
|
if(GetLastError() == ERROR_IO_PENDING)
|
|
|
{
|
|
{
|
|
|
- DWORD ret = WaitForSingleObject(hPort, 500);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ DWORD ret = WaitForSingleObject(hPort, 1000);
|
|
|
if(ret == 0)
|
|
if(ret == 0)
|
|
|
{
|
|
{
|
|
|
LOG_INFO("printer is connect, handle:" << hPort);
|
|
LOG_INFO("printer is connect, handle:" << hPort);
|
|
|
|
|
+
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
@@ -1176,14 +1252,14 @@ bool CPosPrinter::PortTest(HANDLE hPort)
|
|
|
|
|
|
|
|
int CPosPrinter::POS_Reset(void)
|
|
int CPosPrinter::POS_Reset(void)
|
|
|
{
|
|
{
|
|
|
- char s[2] = {0x1B, 0x40};
|
|
|
|
|
|
|
+ char s[2] = { 0x1B, 0x40 };
|
|
|
WriteBuf(s, 2);
|
|
WriteBuf(s, 2);
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
int CPosPrinter::POS_FeedLine(void)
|
|
int CPosPrinter::POS_FeedLine(void)
|
|
|
{
|
|
{
|
|
|
- char s[1] = {0x0A};
|
|
|
|
|
|
|
+ char s[1] = { 0x0A };
|
|
|
WriteBuf(s, 1);
|
|
WriteBuf(s, 1);
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
@@ -1207,7 +1283,7 @@ int CPosPrinter::POS_SetMotionUnit(int x, int y)
|
|
|
|
|
|
|
|
int CPosPrinter::POS_SET_MOVE_X()
|
|
int CPosPrinter::POS_SET_MOVE_X()
|
|
|
{
|
|
{
|
|
|
- char s2[6] = { 0x1B, 0x44, 0x0C, 0x0E, 0x17, 0x00};
|
|
|
|
|
|
|
+ char s2[6] = { 0x1B, 0x44, 0x0C, 0x0E, 0x17, 0x00 };
|
|
|
WriteBuf(s2, 6);
|
|
WriteBuf(s2, 6);
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
@@ -1299,7 +1375,7 @@ int CPosPrinter::POS_TextOut(string abc, bool is_double_width, bool is_double_he
|
|
|
**/
|
|
**/
|
|
|
int CPosPrinter::POS_CutPaper()
|
|
int CPosPrinter::POS_CutPaper()
|
|
|
{
|
|
{
|
|
|
- char s[4] = { 0x1D, 0x56, 0x01};
|
|
|
|
|
|
|
+ char s[4] = { 0x1D, 0x56, 0x01 };
|
|
|
WriteBuf(s, 3);
|
|
WriteBuf(s, 3);
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|