I have a Mettler Toledo UC EVO line scale of which I would like to control the printer with my own program. The scale is a Windows PC based scale with touchscreen, load cell and printer in one.
No dirvers and libraries are provided from Mettler toledo. I have to go find out for myself.
By means of a Mettler test tool that is already installed on the scale and a USB sniffer I was able to intercept the following code:
01 1b 5a 02 1b 4a 03 1b 56 30 04 1b 6c 30 05 1b
4d 30 06 1b 4a 07 1b 5a 08 1b 5a 09 1b 57 34 33
32 30 34 38 30 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
enz..
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 66 1f 98 18
61 81 80 66 7e 18 7e 66 66 7f 9e 18 61 e1 9e 06
78 19 e0 66 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 66 1f 98 18 61 81 80 66 7e 18 7e 66 66 7f
9e 18 61 e1 9e 06 78 19 e0 66 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 66 1f 98 18 61 81 80 66
7e 18 7e 66 66 7f 9e 18 61 e1 9e 06 78 19 e0 66
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 66 1f
98 18 61 81 80 66 7e 18 7e 66 66 7f 9e 18 61 e1
9e 06 78 19 e0 66 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 66 1f 98 18 61 81 80 66 7e 18 7e 66
66 7f 9e 18 61 e1 9e 06 78 19 e0 66 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 66 1f 98 18 61 81
80 66 7e 18 7e 66 66 7f 9e 18 61 e1 9e 06 78 19
e0 66 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
66 1f 98 18 61 81 80 66 7e 18 7e 66 66 7f 9e 18
61 e1 9e 06 78 19 e0 66 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 66 1f 98 18 61 81 80 66 7e 18
7e 66 66 7f 9e 18 61 e1 9e 06 78 19 e0 66 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 66 1f 98 18
61 81 80 66 7e 18 7e 66 66 7f 9e 18 61 e1 9e 06
78 19 e0 66 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 66 1f 98 18 61 81 80 66 7e 18 7e 66 66 7f
9e 18 61 e1 9e 06 78 19 e0 66 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 66 1f 98 18 61 81 80 66
7e 18 7e 66 66 7f 9e 18 61 e1 9e 06 78 19 e0 66
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 66 1f
98 18 61 81 80 66 7e 18 7e 66 66 7f 9e 18 61 e1
9e 06 78 19 e0 66 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 66 1f 98 18 61 81 80 66 7e 18 7e 66
66 7f 9e 18 61 e1 9e 06 78 19 e0 66 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 66 1f 98 18 61 81
80 66 7e 18 7e 66 66 7f 9e 18 61 e1 9e 06 78 19
e0 66 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
66 1f 98 18 61 81 80 66 7e 18 7e 66 66 7f 9e 18
61 e1 9e 06 78 19 e0 66 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 66 1f 98 18 61 81 80 66 7e 18
7e 66 66 7f 9e 18 61 e1 9e 06 78 19 e0 66 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 66 1f 98 18
61 81 80 66 7e 18 7e 66 66 7f 9e 18 61 e1 9e 06
78 19 e0 66 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 66 1f 98 18 61 81 80 66 7e 18 7e 66 66 7f
9e 18 61 e1 9e 06 78 19 e0 66 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 66 1f 98 18 61 81 80 66
7e 18 7e 66 66 7f 9e 18 61 e1 9e 06 78 19 e0 66
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 66 1f
98 18 61 81 80 66 7e 18 7e 66 66 7f 9e 18 61 e1
9e 06 78 19 e0 66 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 66 1f 98 18 61 81 80 66 7e 18 7e 66
66 7f 9e 18 61 e1 9e 06 78 19 e0 66 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 66 1f 98 18 61 81
80 66 7e 18 7e 66 66 7f 9e 18 61 e1 9e 06 78 19
e0 66 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
66 1f 98 18 61 81 80 66 7e 18 7e 66 66 7f 9e 18
61 e1 9e 06 78 19 e0 66 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 66 1f 98 18 61 81 80 66 7e 18
7e 66 66 7f 9e 18 61 e1 9e 06 78 19 e0 66 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 66 1f 98 18
61 81 80 66 7e 18 7e 66 66 7f 9e 18 61 e1 9e 06
78 19 e0 66 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 66 1f 98 18 61 81 80 66 7e 18 7e 66 66 7f
9e 18 61 e1 9e 06 78 19 e0 66 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 66 1f 98 18 61 81 80 66
7e 18 7e 66 66 7f 9e 18 61 e1 9e 06 78 19 e0 66
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 66 1f
98 18 61 81 80 66 7e 18 7e 66 66 7f 9e 18 61 e1
9e 06 78 19 e0 66 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 66 1f 98 18 61 81 80 66 7e 18 7e 66
66 7f 9e 18 61 e1 9e 06 78 19 e0 66 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 66 1f 98 18 61 81
80 66 7e 18 7e 66 66 7f 9e 18 61 e1 9e 06 78 19
e0 66 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
66 1f 98 18 61 81 80 66 7e 18 7e 66 66 7f 9e 18
61 e1 9e 06 78 19 e0 66 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 66 1f 98 18 61 81 80 66 7e 18
7e 66 66 7f 9e 18 61 e1 9e 06 78 19 e0 66 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 66 1f 98 18
61 81 80 66 7e 18 7e 66 66 7f 9e 18 61 e1 9e 06
78 19 e0 66 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 66 1f 98 18 61 81 80 66 7e 18 7e 66 66 7f
9e 18 61 e1 9e 06 78 19 e0 66 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 66 1f 98 18 61 81 80 66
7e 18 7e 66 66 7f 9e 18 61 e1 9e 06 78 19 e0 66
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 66 1f
98 18 61 81 80 66 7e 18 7e 66 66 7f 9e 18 61 e1
9e 06 78 19 e0 66 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 66 1f 98 18 61 81 80 66 7e 18 7e 66
66 7f 9e 18 61 e1 9e 06 78 19 e0 66 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 66 1f 98 18 61 81
80 66 7e 18 7e 66 66 7f 9e 18 61 e1 9e 06 78 19
e0 66 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
66 1f 98 18 61 81 80 66 7e 18 7e 66 66 7f 9e 18
61 e1 9e 06 78 19 e0 66 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 66 1f 98 18 61 81 80 66 7e 18
7e 66 66 7f 9e 18 61 e1 9e 06 78 19 e0 66 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 66 1f 98 18
61 81 80 66 7e 18 7e 66 66 7f 9e 18 61 e1 9e 06
78 19 e0 66 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 66 1f 98 18 61 81 80 66 7e 18 7e 66 66 7f
9e 18 61 e1 9e 06 78 19 e0 66 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 66 1f 98 18 61 81 80 66
7e 18 7e 66 66 7f 9e 18 61 e1 9e 06 78 19 e0 66
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 66 1f
98 18 61 81 80 66 7e 18 7e 66 66 7f 9e 18 61 e1
9e 06 78 19 e0 66 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 66 1f 98 18 61 81 80 66 7e 18 7e 66
66 7f 9e 18 61 e1 9e 06 78 19 e0 66 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 66 1f 98 18 61 81
80 66 7e 18 7e 66 66 7f 9e 18 61 e1 9e 06 78 19
e0 66 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
66 1f 98 18 61 81 80 66 7e 18 7e 66 66 7f 9e 18
61 e1 9e 06 78 19 e0 66 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 66 1f 98 18 61 81 80 66 7e 18
7e 66 66 7f 9e 18 61 e1 9e 06 78 19 e0 66 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 66 1f 98 18
61 81 80 66 7e 18 7e 66 66 7f 9e 18 61 e1 9e 06
78 19 e0 66 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 66 1f 98 18 61 81 80 66 7e 18 7e 66 66 7f
9e 18 61 e1 9e 06 78 19 e0 66 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 66 1f 98 18 61 81 80 66
7e 18 7e 66 66 7f 9e 18 61 e1 9e 06 78 19 e0 66
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 66 1f
98 18 61 81 80 66 7e 18 7e 66 66 7f 9e 18 61 e1
9e 06 78 19 e0 66 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 66 1f 98 18 61 81 80 66 7e 18 7e 66
66 7f 9e 18 61 e1 9e 06 78 19 e0 66 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 66 1f 98 18 61 81
80 66 7e 18 7e 66 66 7f 9e 18 61 e1 9e 06 78 19
e0 66 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
66 1f 98 18 61 81 80 66 7e 18 7e 66 66 7f 9e 18
61 e1 9e 06 78 19 e0 66 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 66 1f 98 18 61 81 80 66 7e 18
7e 66 66 7f 9e 18 61 e1 9e 06 78 19 e0 66 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 66 1f 98 18
61 81 80 66 7e 18 7e 66 66 7f 9e 18 61 e1 9e 06
78 19 e0 66 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 66 1f 98 18 61 81 80 66 7e 18 7e 66 66 7f
9e 18 61 e1 9e 06 78 19 e0 66 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 66 1f 98 18 61 81 80 66
7e 18 7e 66 66 7f 9e 18 61 e1 9e 06 78 19 e0 66
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 66 1f
98 18 61 81 80 66 7e 18 7e 66 66 7f 9e 18 61 e1
9e 06 78 19 e0 66 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 66 1f 98 18 61 81 80 66 7e 18 7e 66
66 7f 9e 18 61 e1 9e 06 78 19 e0 66 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 66 1f 98 18 61 81
80 66 7e 18 7e 66 66 7f 9e 18 61 e1 9e 06 78 19
e0 66 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
66 1f 98 00 00 00 00 00 00 00 00 06 60 00 00 00
00 00 00 00 00 19 e0 66 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 66 1f 98 00 00 00 00 00 00 00
00 06 60 00 00 00 00 00 00 00 00 19 e0 66 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 66 1f 98 00
00 00 00 00 00 00 00 06 60 00 00 00 00 00 00 00
00 19 e0 66 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
04 00 66 1f 98 00 01 e7 e7 1f 90 00 00 06 60 00
00 fc f0 81 83 00 00 19 e0 66 00 c0 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 06 00 66 1f 98 00 02 14 00 80
98 00 00 06 60 00 00 81 08 c2 44 80 00 19 e0 66
01 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 05 00 66 1f
98 00 02 12 00 40 94 00 00 06 60 00 00 41 08 a4
28 40 00 19 e0 66 02 10 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 05 00 66 1f 98 00 01 22 00 4f 94 00 00 06
60 00 00 21 00 84 28 40 00 19 e0 66 02 10 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 04 80 66 1f 98 00 00 c1
07 50 92 00 00 06 60 00 00 70 80 84 28 40 00 19
e0 66 02 10 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 80
66 1f 98 00 01 21 08 d0 12 00 00 06 60 00 00 80
80 84 28 40 00 19 e0 66 02 10 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 04 40 66 1f 98 00 02 10 88 50 11 00
00 06 60 00 00 80 40 84 28 40 00 19 e0 66 02 10
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 0f c0 00 00 00 00
02 10 88 50 bf 00 00 00 00 00 00 84 20 84 28 40
00 00 00 00 02 10 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
04 00 00 00 00 00 02 10 48 50 90 00 00 00 00 00
00 84 10 82 44 80 00 00 00 00 01 20 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 04 00 00 00 00 00 01 e0 47 8f
10 00 00 00 00 00 00 79 fb e1 83 00 00 00 00 00
00 c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
enz..
Full HEX file
It seems that there are ESC/POS commands in between. And there seems to be a count for every new ESC command.
I have made a C# app where I can control the printer by means of LibUSB. If I use the feedEvoBtn_Click method here, it will be printed by the printer. So there is communication with the printer and my program
public partial class Form1 : Form
{
private UsbDevice _evoLinePrinter;
private UsbEndpointWriter _evoEndpointWriter;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
_evoLinePrinter = UsbDevice.OpenUsbDevice(new UsbDeviceFinder(0x0EB8, 0x300C));
}
private void openEvoBtn_Click(object sender, EventArgs e)
{
try
{
_evoLinePrinter.Open();
IUsbDevice wholeUsbDevice = _evoLinePrinter as IUsbDevice;
if (!ReferenceEquals(wholeUsbDevice, null))
{
wholeUsbDevice.SetConfiguration(1);
wholeUsbDevice.ClaimInterface(0);
}
_evoEndpointWriter = _evoLinePrinter.OpenEndpointWriter(WriteEndpointID.Ep02, EndpointType.Bulk);
eventBox.Items.Add("Open reader/writer evo line");
}
catch (Exception ex)
{
eventBox.Items.Add(ex.Message);
}
}
private void feedEvoBtn_Click(object sender, EventArgs e)
{
try
{
_evoEndpointWriter.Write(new byte[] { 0x01, 0x1b, 0x53 }, 1000, out int outer);
eventBox.Items.Add("Feed evo line printer");
}
catch (Exception ex)
{
eventBox.Items.Add(ex.Message);
}
}
private void testLabelEvoBtn_Click(object sender, EventArgs e)
{
try
{
int lenght;
_evoEndpointWriter.Write(new byte[] { 0x01, 0x1b, 0x5a }, 1000, out lenght);
_evoEndpointWriter.Write(new byte[] { 0x02, 0x1b, 0x4a }, 1000, out lenght);
_evoEndpointWriter.Write(new byte[] { 0x03, 0x1b, 0x56, 0x30 }, 1000, out lenght);
_evoEndpointWriter.Write(new byte[] { 0x04, 0x1b, 0x6c, 0x30 }, 1000, out lenght);
_evoEndpointWriter.Write(new byte[] { 0x05, 0x1b, 0x4d, 0x30 }, 1000, out lenght);
_evoEndpointWriter.Write(new byte[] { 0x06, 0x1b, 0x4a }, 1000, out lenght);
_evoEndpointWriter.Write(new byte[] { 0x07, 0x1b, 0x5a }, 1000, out lenght);
_evoEndpointWriter.Write(new byte[] { 0x08, 0x1b, 0x57, 0x34, 0x33, 0x32, 0x30, 0x34, 0x38, 0x30 }, 1000, out lenght);
_evoEndpointWriter.Write(new byte[] { 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 1000, out lenght);
_evoEndpointWriter.Write(Encoding.UTF8.GetBytes("Line one\n\rline two\n\r"), 1000, out lenght);
eventBox.Items.Add("Print test label evo line printer");
}
catch (Exception ex)
{
eventBox.Items.Add(ex.Message);
}
}
}
Nothing happens without putting the count before the feed command.
The printer is probably controlled by ESC/P commands. Only I can't manage to just print a standard text.
When I use the testLabelEvoBtn_Click method, something happens to the printer, and after a few clicks a label comes out. There is just no text to be seen. This method does the same as the test tool, only with its own text in it. This produces the following result in the usb sniffer
The result of using testLabelEvoBtn
When I look at the HEX code sent from Mettler's test tool, I also don't see that this is sent to the printer as ASCII, while my own program does.
Can anyone explain to me what this encoding is that the test tool sends to the printer? I hope that this way I can control the printer myself with text, a barcode and possibly a logo.
Thanks
Looking at your hex trace, the commands don't seem to match any usual ESC/POS standard:
01 1B 5A [ESC Z]
02 1B 4A [ESC J]
03 1B 56 30 [ESC V 0]
04 1B 6C 30 [ESC l 0]
05 1B 4D 30 [ESC M 0]
06 1B 4A [ESC J]
07 1B 5A [ESC Z]
08 1B 5A [ESC Z]
09 1B 57 34333230343830 .. [ESC W "4320480" ...]
However, the last one seems to be your actual print data - as a bitmap image, not as text.
The initial 7 ASCII numbers problably indicate 432 dots/pixel width and (0)480 lines height.
And then every bit of the following bytes are one dot/pixel - although it seems the line direction is mirrored/reversed.
I'm not a C# programmer, but this tiny bit of Ruby produces an image from your hex (part after the ASCII width/heigh info in bitmap):
width_bytes = width/8
(0..height).each do |line|
line_bytes = bitmap[line*width_bytes, width_bytes].unpack('C*')
line_bytes.reverse.each do |byte|
print byte.to_s(2).gsub("0"," ").rjust(8).reverse
end
print "\n"
end
Some parts of the output (scroll right):
1111111 1111 111
1111111 1111 111
1111111 11 1111 111 111111
11111111111 11 1111111111
1111 1111 11 1111 1111
111 111 11 111 111
111 111 11 111111 11111 11 1111111 111 111111 11111111 111111111 111 111 1111111 1111111 11 111111 11111 11 111111
111 111 11 1111111111 11111111 111 111111111 111 1111111 11111111 111111111 111 11 111111111 111111111 111 11111111 11111111 111 1111111111
111 11 1111 1111 1111 11111 111 111 111 11111111 111 111 111 111 111 111 111 11111 1111 1111 11111 1111 1111
111 11 111 111 111 1111 111 111 111 111 111 111 111 111 111 111 111 1111 111 111 1111 111 111
111111 11 111 111 111 111 111 111 11111 111 111 111 111 111 111 111 111 111 111 111 111 111
11111111 11 11 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 11
11111111 11 11 111 111 111 111 111 111 111 111 1111111 111 111 111 111 111 111 111 111 11
111111 11 111111111 111 111 111111111111111 111 111 111 111 1111111 111 111 111111111111111 111 111 111 111 111111111
1111 11 11111111111 111 111 111111111111111 11 111 111 111 111 111 111 111111111111111 111 111 111 111 11111111111
111 11 1111 11 111 111 111 11 111 111 111 111 111 111 111 111 111 111 111 1111 11
111 11 111 11 111 111 111 11 111 111 111 111 111 111 111 111 111 111 111 111 11
11 111 11 111 111 111 111 111 11 111 111 1111 111 111 111 111 111 111 111 111 111 111
1111 111 11 111 111 111 111 111 11 11 111 111 111 111 111 111 111 11 111 111 111 111 111 111
111 111 11 111 11111 111 1111 111 111 11 111 111 1111 111 111 111 111 111 111 111 111 1111 111 11111
1111 1111 11 1111 11 111 1111 11111 1111 1111 11 111 111 1111 1111 111 111 1111 1111 111 111 1111 11111 1111 11 111
11111111111 111111111111111 11111111 11111 11111111 111 1111111111 11 111111111111111 111 11111111111 111111111 1111111111 111 111 11111111 111 11111111 11111
1111111 111111111111111 111111 1111 111111 111 111111 11 111111111111111 111 111111 1111111 111111 111 111 111111 111 111111 1111
111 111 111
111 111 111
111 111 111 111 111
111 111 111 111 111
1111 111 1111 1111 111
111111111 111111111 111111111
111111 1111111 111111
11 11 1111 11 1111 11 1111 11 1111 11 11 1111 11111111 11 11 11 11 111111 11 111111 11 11 11 11 11 11 11 111111 11 11
11 11 1111 11 1111 11 1111 11 1111 11 11 1111 11111111 11 11 11 11 111111 11 111111 11 11 11 11 11 11 11 111111 11 11
11 11 1111 11 1111 11 1111 11 1111 11 11 1111 11111111 11 11 11 11 111111 11 111111 11 11 11 11 11 11 11 111111 11 11
11 11 1111 11 1111 11 1111 11 1111 11 11 1111 11111111 11 11 11 11 111111 11 111111 11 11 11 11 11 11 11 111111 11 11
11 11 1111 11 1111 11 1111 11 1111 11 11 1111 11111111 11 11 11 11 111111 11 111111 11 11 11 11 11 11 11 111111 11 11
11 11 1111 11 1111 11 1111 11 1111 11 11 1111 11111111 11 11 11 11 111111 11 111111 11 11 11 11 11 11 11 111111 11 11
11 11 1111 11 1111 11 1111 11 1111 11 11 1111 11111111 11 11 11 11 111111 11 111111 11 11 11 11 11 11 11 111111 11 11
11 11 1111 11 1111 11 1111 11 1111 11 11 1111 11111111 11 11 11 11 111111 11 111111 11 11 11 11 11 11 11 111111 11 11
11 11 1111 11 11 11 11 111111 11 11
11 11 1111 11 11 11 11 111111 11 11
11 11 1111 11 11 11 11 111111 11 11
11 11 11 1111 11 11 11 1 1111 111111 11 11 1 111111 111 111111 1111 11 111111 11 11 1
1 1 11 11 1111 11 1 1 1 1 11 1 1 1 11 11 11 1 1 1 1 1 11 111111 11 11 11
1 1 11 11 1111 11 1 1 1 1 1 1 1 1 1 11 11 1 1 1 1 1 1 1 11 111111 11 11 1 1
1 1 11 11 1111 11 1 1 1 1 1 1 1 11 11 1 1 11111 1 1 1 1 11 111111 11 11 1 1
1 1 11 11 1111 11 1 1 1 1 1 1 111 11 11 1 1 1 1 1 111 1 11 11 111111 11 11 1 1
1 1 11 11 1111 11 1 1 1 1 1 1 1 11 11 1 1 1 11 1 1 1 1 11 111111 11 11 1 1
1 1 11 11 1111 11 1 1 1 1 1 1 1 11 11 1 1 1 1 1 1 1 1 11 111111 11 11 1 1
1 1 1 1 1 1 1 1 1 1 111111 1 1 1 1 1 1 1 111111
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
11 11 11 11111 111111 1111 1 1111 1111 1 1111 1
I am debugging some code right now (VS 2019, .NET Framework 4.7.2), stopped at a breakpoint, using the Immediate Window to evaluate variables. I have a BitVector32 which I am not understanding its state. Here is the content of the IW:
stillInHand.ToString()
"BitVector32{00000000000000000000000000001100}"
stillInHand
{BitVector32{00000000000000000000000000001100}}
Data: 12
stillInHand[0]
true
stillInHand[1]
false
stillInHand[2]
false
stillInHand[3]
false
stillInHand[4]
true
stillInHand[5]
false
stillInHand[6]
false
stillInHand[7]
false
There have been no calls to any of the Create* methods, and stillInHand was created with the BitVector32(Int32) ctor. Shouldn't indices 2 & 3 be true and all the rest be false?
Actually, this issue is related to the understanding of the index of BitVector32[ ].
First of all, stillInHand[1] doesn’t mean to get the second bit of stillInHand(BitVector32). It represents this action: use 00 00 … 00 01 to perform &(AND) operation with stillInHand(BitVector32).
For an example: stillInHand(BitVector32) is 00 00 00 00 00 … 00 00 00 11 00, and 1 is 00 00 00 00 00 … 00 00 00 00 01. Then perform &(AND) operation.
00 00 00 00 00 … 00 00 00 11 00 12 &(AND)
00 00 00 00 00 … 00 00 00 00 01 `1`
--------------------------------------------
00 00 00 00 00 … 00 00 00 00 00
And you can see that the last bit(focus on the index value 1) changes from 1 to 0, so the result will be false, if you output or see the result of stillInHand[1].
So, for stillInHand[2], you can see
00 00 00 00 00 … 00 00 00 11 00 12 &(AND)
00 00 00 00 00 … 00 00 00 00 10 2
--------------------------------------------
00 00 00 00 00 … 00 00 00 00 00
The second to last bit(focus on the index value 2) changes from 1 to 0, so the result will be false too.
And for stillInHand[8], you can see
00 00 00 00 00 … 00 00 00 11 00 12 &(AND)
00 00 00 00 00 … 00 00 00 10 00 8
--------------------------------------------
00 00 00 00 00 … 00 00 00 10 00
The fourth to last bit(focus on the index value 8) doesn’t change and it remains as 1, so the result will be true.
Actually, if you analyze the source code from here: Reference Source, you can see these codes:
/// <devdoc>
/// <para>Gets or sets a value indicating whether all the specified bits are set.</para>
/// </devdoc>
public bool this[int bit] {
get {
return (data & bit) == (uint)bit;
//clear other bits (to 0) through the AND operation of the data and mask.
//If the result of the operation is equal to the mask, return true.
//Otherwisse, return false.
}
set {
if (value) {
data |= (uint)bit;
//data = data OR mask, set the specified bit to “1”
}
else {
data &= ~(uint)bit;
//data = data AND ~mask, set the specified bit to “0”
}
}
}
Of course, you can consider it as mask, and this will be easy to understand.
I'm reading a hex byte array from a file using an instance of the BinaryReader class, and I need to decode it from UTF-16. From what I know, I need to do this using System.Text.Encoding.Unicode.GetString(byte[] array).
This is what my code looks like:
public static string ReadHex(string path, Int32 startOffset, Int32 endOffset, bool decode, bool utf16)
{
if (!File.Exists(path))
{
throw new FileNotFoundException($"Could not find a file in path {path}");
}
string result = "";
List<byte> bytes = new List<byte>();
BinaryReader br = new BinaryReader(File.OpenRead(path));
for (int i = startOffset; i < endOffset; i++)
{
br.BaseStream.Position = i;
bytes.Add(br.ReadByte());
}
br.Close();
if (decode && utf16)
{
result = System.Text.Encoding.Unicode.GetString(bytes.ToArray());
}
else if (decode)
{
result = System.Text.Encoding.UTF8.GetString(bytes.ToArray());
}
else
{
foreach (byte b in bytes)
{
result += b.ToString("X2");
}
}
return result;
}
It reads the given hex offsets provided by the parameters and decodes them if wanted. The UTF-8 part works perfectly, giving me valid decoded strings. But my issue is with the UTF-16 part.
This is the data that is read from the file:
4D 00 6F 00 6A 00 61 00 6E 00 67 00 20 00 41 00 42
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00
In theory, this is what should be outputted:
Mojang AB
It kinda works, but with one oddity, this is what is outputted when writing the string that the method returns:
Mojang AB ?
These question marks appear on anything that's UTF-16 I put into the method. I don't understand why they appear, as the data that was passed into System.Text.Encoding.Unicode.GetString(byte[] array) does not contain anything past the string it's supposed to contain, and is made up of zeroes (00). Anyone have an idea on why this is happening?
I am trying to compare Finger print string & GPS data by converting byte array but result are not working for same finger record from different ends.
Here is my string/hex values from finger scan device & GPS accordingly.
Finger print encoded result as below.
AwFZFo4A//7//vAA4ACAAIAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSDRiePJYW3mEcxF5jKZueCSwPPiitjx4atw0+KT7LvimYFd9IIFe/diDbN1yihb91sAffQLoKnzsgbNw+JxT8OqmR/T+wThpGMkpWNSFU90mxyBcspZJSAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMBWRqRAP/+/wLgAMAAgACAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMZMXXlcZhF5SoAYeWKXbnh8qTx4RtA1eILsLfm8TWj8eFJWfPp0XX2sdWx9xI4cfa6wHvze2Cl8QQEyfdMBfvzCdbLpCQWMSQz6K8yGjEnY0pBT0MKZRlSQfa9I5rkySLB6V8yKg1FMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
GPS Tracker sending in HEX Code as below
03 01 5A 16 96 00 FF FE E0 02 C0 00 80 00 80 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 0B 16 9E 59 91 03 FE 6D 15 1A BE 55 98 85 7E 5D 9E 5B 7E 3A A5 0E 1E 16 2C 8C BE 25 B2 8B 1E 1E 0D 95 5F 75 9A C6 B7 24 23 8E BF 70 A3 87 7F 3B AE 49 FF 16 B7 8B DF 36 91 00 1C 41 14 56 FC 3D 91 16 9A 37 9D 14 F8 33 1F 92 19 30 16 2C 56 24 1C 12 36 2C 17 55 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
How to compare both with byte array??
Finger print code required to Convert FromBase64 string to Byte and GPS code required to Hex to byte..
I am getting different array size from Finger print it returning 512 byte array and from GPS it comes 256 byte array..
below is my code form C#
Create demo aspx page and check it.
I have added Demo project here.
you can download and check it..
http://maplayout.com/demo.zip
Thanks
Abhi
I have been resolved issue by converting HEX Code string to Byte[] and
USB reader value convert fromBase64 string then Byte[]
I have created below method to Compare both with byte[],
below fpengine is the thirdparty COM Object that will use for compare finger scanned value with finger point algorithm.
public bool IsMatchFound(string HexCodeString , string USBReaderString)
{
try
{
int scope = 0, intdisc=0;
byte[] gmat = HexEncoding.GetBytes(HexCodeString, out intdisc); //StringToByteArray(str1);
byte[] gref = Convert.FromBase64String(USBReaderString);
scope = fpengine.MatchTemplate(gmat, gref);
return (scope > 30) ? true : false;
}
catch (Exception ex)
{
return false;
}
}
Let me know if anybody want help same kind of application..
I have data in the form of from TextBox1
00 00 00 4E FF 53 4D 42 25 00 00 00 00 18 01 28 ...N.SMB%......(
00 00 00 00 00 00 00 00 00 00 00 00 00 08 12 8B ................
01 08 7E 31 11 00 00 05 00 00 00 00 00 00 00 02 ..~1............
and I tried to change it to be like this on the result TextBox2
...N.SMB%......(
................
..~1............
I've tried the function *. remove but only the first row are deleted but the second line and so on are not deleted. Can anybody help me?
i use this code
string test = rtText1.Text;
rtText2.Text = test.Remove(0, 48);
and then this result rtText2
...N.SMB%......(
00 00 00 00 00 00 00 00 00 00 00 00 00 08 12 8B ................
01 08 7E 31 11 00 00 05 00 00 00 00 00 00 00 02 ..~1............
how can I make a command "test.Remove (0, 48);" can be done on each line? or is there another function?
It's hard to say exactly what you need based on what you've posted, but a regex may work well here:
TextBox2.Text = System.Text.RegularExpressions.Regex.Replace(
TextBox1.Text,
#"^.{49}",
"",
RegexOptions.Multiline );
This will simply replace the first 49 characters of each line with an empty string.
It looks to me as though you're trying to remove the hexadecimal representation of whatever string is on the right.
This did the trick for me:
// Initial data
string Data = #"00 00 00 4E FF 53 4D 42 25 00 00 00 00 18 01 28 ...N.SMB%......(
00 00 00 00 00 00 00 00 00 00 00 00 00 08 12 8B ................
01 08 7E 31 11 00 00 05 00 00 00 00 00 00 00 02 ..~1............";
// An array containing each line of data
string[] lines = Data.Split('\n');
Data = "";
// Loop for each line, removing each "byte" + it's space, plus the trailing space
for (int i = 0; i < lines.Length; i++)
{
Data += lines[i].Remove(0, (3 * 16) + 1);
if (i != lines.Length - 1)
Data += "\r\n";
}
Console.Write(Data);
And here is the output:
...N.SMB%......(
................
..~1............
ideone link