|
|
@@ -35,7 +35,7 @@ void CPosPrinter::InitUsb(int usbType)
|
|
|
{
|
|
|
LOG_INFO("准备打开端口 Port = " << m_usb_devices[i].c_str());
|
|
|
|
|
|
- HANDLE hPort = CreateFile(m_usb_devices[i].c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 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)
|
|
|
{
|
|
|
@@ -78,7 +78,7 @@ void CPosPrinter::InitUsb(int usbType)
|
|
|
|
|
|
void CPosPrinter::InitOneUsb(wstring usb_path)
|
|
|
{
|
|
|
- HANDLE hPort = CreateFile(usb_path.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
+ 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)
|
|
|
{
|
|
|
@@ -796,14 +796,16 @@ void CPosPrinter::PrintWaimaiOrderShouyin(CWaimaiOrder& order)
|
|
|
|
|
|
POS_FeedLine();
|
|
|
|
|
|
- POS_FeedLine();
|
|
|
+ POS_FeedLine();;
|
|
|
POS_FeedLine();
|
|
|
|
|
|
//准备开始打印二维码
|
|
|
std::string order_no = order.m_order_no;
|
|
|
order_no = CLewaimaiString::UTF8ToANSI(order_no);
|
|
|
|
|
|
- POS_OutQRCode(order_no);
|
|
|
+ //POS_OutQRCode(order_no);
|
|
|
+
|
|
|
+ POS_OutBmp(L"D:\\200.jpg");
|
|
|
|
|
|
//走纸几行再切
|
|
|
POS_FeedLine();
|
|
|
@@ -1238,7 +1240,7 @@ int CPosPrinter::WriteBuf(const unsigned char* buf, int len)
|
|
|
{
|
|
|
HANDLE hPort = (*it).hPort;
|
|
|
|
|
|
- if((*it).type == 1 || (*it).type == 3)
|
|
|
+ if((*it).type == 3)
|
|
|
{
|
|
|
//串口,同步写数据
|
|
|
//LOG_INFO("before com writefile handle:" << hPort);
|
|
|
@@ -1262,7 +1264,7 @@ int CPosPrinter::WriteBuf(const unsigned char* buf, int len)
|
|
|
if(GetLastError() == ERROR_IO_PENDING)
|
|
|
{
|
|
|
//LOG_INFO("Request queued, waiting... handle:" << hPort);
|
|
|
- WaitForSingleObject(hPort, 1000);
|
|
|
+ WaitForSingleObject(hPort, 3000);
|
|
|
//LOG_INFO("Request completed, handle:" << hPort);
|
|
|
|
|
|
//计算写入了多少字节的数据
|
|
|
@@ -1599,17 +1601,20 @@ void CPosPrinter::POS_OutBmp(std::wstring ImagePath)
|
|
|
int newHeight = (int)(nHeight / (nWidth / 380.0));
|
|
|
|
|
|
helper.ScaleBitmap(newWidth, newHeight);;
|
|
|
+
|
|
|
+ nWidth = newWidth;
|
|
|
+ nHeight = newHeight;
|
|
|
}
|
|
|
|
|
|
//二值化
|
|
|
helper.Image2Values();
|
|
|
|
|
|
+ //获得最新的图像指针
|
|
|
+ bmp = helper.getBmp();
|
|
|
+
|
|
|
//选择位图模式
|
|
|
unsigned char escBmp[5] = { 0x1B, 0x2A, 0x21, 0x00, 0x00 };
|
|
|
|
|
|
- nWidth = bmp->GetWidth();
|
|
|
- nHeight = bmp->GetHeight();
|
|
|
-
|
|
|
escBmp[3] = (unsigned char)(nWidth % 256);
|
|
|
escBmp[4] = (unsigned char)(nWidth / 256);
|
|
|
|