Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bft_takeout
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guanghui.cui
bft_takeout
Commits
5610b6fa
Commit
5610b6fa
authored
Oct 27, 2017
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
所有订单打印
parent
61dc935d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
240 additions
and
38 deletions
+240
-38
fmTakeaway/Util/wbillcontrol.cpp
+167
-16
fmTakeaway/Util/wbillcontrol.h
+3
-0
fmTakeaway/pos_print.h
+1
-1
print_bft/pos_print.c
+63
-17
print_bft/pos_print.h
+6
-4
No files found.
fmTakeaway/Util/wbillcontrol.cpp
View file @
5610b6fa
This diff is collapsed.
Click to expand it.
fmTakeaway/Util/wbillcontrol.h
View file @
5610b6fa
...
...
@@ -111,6 +111,9 @@ private:
//上菜单打印
void
printMenu
(
const
OrderObject
*
obj
);
//收银账单打印
void
printBill
(
const
OrderObject
*
obj
);
//上菜单打印
QString
getPrintTitle
(
const
QString
&
channel
,
int
index
);
...
...
fmTakeaway/pos_print.h
View file @
5610b6fa
...
...
@@ -2,7 +2,7 @@
#define _FMSPOSDLL_H_
int
open_port
(
const
char
*
szPort
);
void
close_port
();
void
set_port
(
int
fd
,
int
Baudrate
);
bool
set_port
(
int
Baudrate
);
void
cut_paper
();
//---------------------------------------------
...
...
print_bft/pos_print.c
View file @
5610b6fa
...
...
@@ -13,9 +13,8 @@ int g_Handle=INVALID_HANDLE_VALUE;
int
g_uBaudrate
=
0
;
int
open_port
(
const
char
*
szPort
)
{
int
fd
;
/* 端口文件描述符 */
if
(
g_Handle
!=
INVALID_HANDLE_VALUE
)
close
(
g_Handle
);
//if(g_Handle != INVALID_HANDLE_VALUE)
// close(g_Handle);
g_Handle
=
open
(
szPort
,
O_RDWR
|
O_NOCTTY
|
O_NDELAY
);
if
(
g_Handle
==
INVALID_HANDLE_VALUE
)
...
...
@@ -25,14 +24,14 @@ int open_port(const char* szPort)
return
(
g_Handle
);
}
void
set_port
(
int
fd
,
int
Baudrate
)
bool
set_port
(
int
Baudrate
)
{
struct
termios
options
;
int
flag
;
tcgetattr
(
fd
,
&
options
);
tcgetattr
(
g_Handle
,
&
options
);
fcntl
(
fd
,
F_SETFL
,
0
);
fcntl
(
g_Handle
,
F_SETFL
,
0
);
if
(
9600
==
Baudrate
)
g_uBaudrate
=
B9600
;
...
...
@@ -59,20 +58,38 @@ void set_port(int fd,int Baudrate)
options
.
c_cc
[
VMIN
]
=
0
;
options
.
c_cc
[
VTIME
]
=
1
;
flag
=
tcsetattr
(
fd
,
TCSANOW
,
&
options
);
flag
=
tcsetattr
(
g_Handle
,
TCSANOW
,
&
options
);
if
(
flag
<
0
)
{
p
error
(
"set_port: Setting port /dev/ttyS0 error -
"
);
p
rintf
(
"setting port error
\n
"
);
}
//test
char
strCutPaper
[]
=
"
\x10\x04\x01\x00
"
;
//打印机状态指令,如果打印机正常,返回长度为1 否则为0
write
(
g_Handle
,
&
strCutPaper
,
4
);
//sleep(1);
char
temp
[
3
]
=
{
0
};
int
recvLen
=
read
(
g_Handle
,
temp
,
3
);
temp
[
recvLen
]
=
'\0'
;
printf
(
"-----length:%d recv:%d
\n
"
,
recvLen
,
temp
[
0
]);
if
(
0
==
recvLen
){
tcflush
(
g_Handle
,
TCIOFLUSH
);
//清空终端未完成的输入/输出请求及数据
close_port
();
return
false
;
}
return
true
;
}
void
close_port
()
{
if
(
g_Handle
!=
INVALID_HANDLE_VALUE
)
{
sleep
(
1
);
int
res
=
tcflush
(
g_Handle
,
TCIOFLUSH
);
close
(
g_Handle
);
sleep
(
2
);
// int res = tcflush(g_Handle,TCIOFLUSH);
printf
(
"close begin
\n
"
);
close
(
g_Handle
);
printf
(
"close end
\n
"
);
g_Handle
=
INVALID_HANDLE_VALUE
;
g_uBaudrate
=
0
;
}
...
...
@@ -86,7 +103,7 @@ void cut_paper()
write
(
g_Handle
,
&
strCutPaper
,
9
);
}
void
print
(
char
*
data
,
int
type
)
void
print
(
c
onst
c
har
*
data
,
int
type
)
{
printf
(
"data:%s
\n
"
,
data
);
char
*
str
=
(
char
*
)
malloc
(
1024
);
...
...
@@ -111,7 +128,7 @@ void print(char *data,int type)
else
{
strcpy
(
str
,
"
\x1B\x40
"
);
strcat
(
str
,
"
\x1D\x21\x11
"
);
//strcat(str,"\x1B\x21\x3
0
");
//strcat(str,"\x1B\x21\x3
8
");
strcat
(
str
,
data
);
}
}
...
...
@@ -125,13 +142,41 @@ void print(char *data,int type)
}
else
{
strcpy
(
str
,
"
\x1B\x40
"
);
strcat
(
str
,
"
\x1C\x57\x
0
1
"
);
strcat
(
str
,
"
\x1C\x57\x
1
1
"
);
strcat
(
str
,
"
\x1B\x21\x38
"
);
strcat
(
str
,
data
);
}
}
else
if
(
5
==
type
){
if
(
B9600
==
g_uBaudrate
){
strcpy
(
str
,
"
\x1B\x40\x1B\x21\x00\x1B\x33\x18\x1B\x52\x00\x1B\x63\x34\x05
"
);
strcat
(
str
,
"
\x1C\x57\x01
"
);
strcat
(
str
,
"
\x1B\x21\x10
"
);
strcat
(
str
,
data
);
}
else
{
strcpy
(
str
,
"
\x1B\x40
"
);
strcat
(
str
,
"
\x1D\x21\x01
"
);
strcat
(
str
,
data
);
}
}
else
if
(
6
==
type
){
if
(
B9600
==
g_uBaudrate
){
strcpy
(
str
,
"
\x1B\x40\x1B\x21\x00\x1B\x33\x18\x1B\x52\x00\x1B\x63\x34\x05
"
);
strcat
(
str
,
"
\x1C\x57\x01
"
);
strcat
(
str
,
"
\x1B\x21\x18
"
);
strcat
(
str
,
data
);
}
else
{
strcpy
(
str
,
"
\x1B\x40
"
);
strcat
(
str
,
"
\x1D\x21\x01
"
);
strcat
(
str
,
"
\x1B\x21\x38
"
);
strcat
(
str
,
data
);
}
}
else
if
(
7
==
type
){
if
(
B9600
==
g_uBaudrate
){
strcpy
(
str
,
"
\x1B\x40
"
);
strcat
(
str
,
"
\x1C\x57\x01
"
);
strcat
(
str
,
"
\x1B\x21\x38
"
);
...
...
@@ -143,7 +188,7 @@ void print(char *data,int type)
strcat
(
str
,
data
);
}
}
else
if
(
6
==
type
){
else
if
(
8
==
type
){
if
(
B9600
==
g_uBaudrate
){
strcpy
(
str
,
"
\x1B\x40
"
);
strcat
(
str
,
"
\x1C\x57\x01
"
);
...
...
@@ -167,9 +212,10 @@ void print(char *data,int type)
//strcpy(str,data);
//strcat(str," thanks");
strcat
(
str
,
"
\x0A\x0D
"
);
printf
(
"str is:%s
\n
"
,
str
);
//
printf("str is:%s\n",str);
printf
(
"str length:%d
\n
"
,
strlen
(
str
));
write
(
g_Handle
,
str
,
strlen
(
str
));
int
res
=
write
(
g_Handle
,
str
,
strlen
(
str
));
printf
(
"write result:%d
\n
"
,
res
);
free
(
str
);
}
...
...
print_bft/pos_print.h
View file @
5610b6fa
...
...
@@ -2,7 +2,7 @@
#define _FMSPOSDLL_H_
int
open_port
(
const
char
*
szPort
);
void
close_port
();
void
set_port
(
int
fd
,
int
Baudrate
);
bool
set_port
(
int
Baudrate
);
void
cut_paper
();
//---------------------------------------------
...
...
@@ -13,8 +13,10 @@ void cut_paper();
// 2、标准加粗
// 3、两倍宽高
// 4、两倍宽高,加粗
// 5、三倍宽高
// 6、三倍宽高,加粗,红色
// 5、两倍高
// 6、两倍高,加粗
// 7、三倍宽高
// 8、三倍宽高,加粗,红色
//---------------------------------------------
void
print
(
char
*
data
,
int
type
);
void
print
(
c
onst
c
har
*
data
,
int
type
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment