I have been capturing some data from an Epson TM-T88V esc/pos printer to see how they are doing things in the windows driver. I have encountered a few undocumented commands. Does anyone know what these commands do?
I have checked the various Application Programming guides, the online ESC/POS Command Reference for TM Printers, and Googled the heck out of the commands and have not been able to find any references.
Command 1:
[Format]
ASCII ESC ( s pL pH d1 d2 d3 d4
Hex 1b 28 73 04 00 31 41 ?? ??
Decimal 27 40 114 4 0 40 73 ?? ??
[Response]
7b 20 41 35 33 35 34 34 44 34 45 34 44 34 41 34 42 35 30 00
[Notes]
The Response looks like a 0x7b header-null block.
Command 2:
[Format]
ASCII ESC ( J pL pH d1 d2
Hex 1d 28 4a 02 00 ?? 00
Decimal 29 40 74 2 0 ? 0
[Response]
There seems to be no response to this command.
Command 3:
ESC I n where n = 113, 114
[Name] Transmit printer ID
[Format]
ASCII GS I n
Hex 1D 49 n
Decimal 29 73 n
[Response] 0x5f header-null block
[notes] The GS I command itself is document, but the command with n = 113 (0x71) or 114 (0x72) is not.
Related
I have some log file that I want to convert to PCAP file format to be opened in Wireshark. The log file is UDS (Unified Diagnostic Services) log of a car firmware update. What is the best practice to do that?
The log file lines look like this:
***BUSMASTER Ver 3.2.1***
***PROTOCOL CAN***
***NOTE: PLEASE DO NOT EDIT THIS DOCUMENT***
***[START LOGGING SESSION]***
***START DATE AND TIME 4:6:2018 9:2:12:212***
***HEX***
***SYSTEM MODE***
***START CHANNEL BAUD RATE***
***CHANNEL 2 - Kvaser - Kvaser USBcan Pro 5xHS #0 (Channel 1), Serial Number- 0, Firmware- 0x0000013b 0x00030007 - 500000 bps***
***END CHANNEL BAUD RATE***
***START DATABASE FILES***
***END DATABASE FILES***
***<Time><Tx/Rx><Channel><CAN ID><Type><DLC><DataBytes>***
00:00:00:0000 Rx 2 0x064 s 8 20 20 20 20 20 20 20 20
00:00:00:0574 Rx 2 0x7cd s 8 4d 72 2e 20 61 6e 64 20
00:00:00:0952 Rx 2 0x7df s 8 02 01 00 00 00 00 00 00
00:00:00:1457 Rx 2 0x05b s 8 ad dc 0b cc 0a c3 49 40
00:00:00:2069 Rx 2 0x05c s 8 63 d3 4a 21 90 4b c4 bf
00:00:00:2649 Rx 2 0x7cd s 8 4d 72 73 2e 20 44 75 72
I am trying to print a Datamatrix barcode using an EPSON m30 Printer.
When the following HEX values are transmitted, no action is taken.
I was able to get this HEX value from the page below.
https://download.epson-biz.com/modules/ref_escpos/index.php?content_id=170
1d 28 6b 0d 00 36 50 30 31 32 33 34 35 36 37 38 39 30
1d 28 6b 03 00 36 54 30 0d 0a
Can you please let me know if something is wrong?
thanks
Maybe the description on the reference page is incorrect.
For example, the printing of the Aztec code is Function 581, which is 35 51 30.
The second byte of other barcodes is 51.
By analogy, there is a possibility of 36 51 30 instead of 36 54 30.
Please try sending the following command.
Q:
1d 28 6b 0d 00 36 50 30 31 32 33 34 35 36 37 38 39 30 1d 28 6b 03 00 36 54 30 0d 0a
A:
1d 28 6b 0d 00 36 50 30 31 32 33 34 35 36 37 38 39 30 1d 28 6b 03 00 36 51 30 0d 0a
I want to generate random bytes in Ruby, but I also want to insert some constant values into specific positions of the random bytes.
random_hex_string = SecureRandom.hex (length)
random_hex_string.insert(0,"0102")
random_hex_string.insert(30*1,"36")
So I generate random hex bytes and insert my hex values there. The problem is that I have now a string not a byte array. So when I print it:
File.open("file.txt", 'w+b') do |f|
f.write(random_hex_string)
It - not surprisingly - converts the hex string into binary then writes it. So my hex values are not kept. To be more clear, when I write my hex string to the file, and then I want to see the same hex values when I hex dump the file. How can I do this?
You can turn it into a single element array and pack it as hex. For instance, when I run your code:
require 'securerandom'
length = 2 ** 6
random_hex_string = SecureRandom.hex (length)
random_hex_string.insert(0,"0102")
random_hex_string.insert(30*1,"36")
puts random_hex_string
File.open("file.txt", 'w+b') do |file|
file.write([random_hex_string].pack('H*')) # see also 'h'
end
I get the output
010299e84e9e4541d08cb800462b6f36a87ff118d6291368e96e8907598a2dfd4090658fea1dab6ed460ab512ddc54522329f6b4ddd287e4302ef603ce60e85e631591
and then running
$ hexdump file.txt
0000000 01 02 99 e8 4e 9e 45 41 d0 8c b8 00 46 2b 6f 36
0000010 a8 7f f1 18 d6 29 13 68 e9 6e 89 07 59 8a 2d fd
0000020 40 90 65 8f ea 1d ab 6e d4 60 ab 51 2d dc 54 52
0000030 23 29 f6 b4 dd d2 87 e4 30 2e f6 03 ce 60 e8 5e
0000040 63 15 91
0000043
Unless, I'm mistaken, it matches up perfectly with the output from the script.
I've never messed with Array#pack before, and haven't done much with hex, but this seems to be giving the results you require, so should be a step in the right direction at least.
Why ask for hex when you don't actually want hex? Just do this:
random_bytes = SecureRandom.random_bytes(length)
random_bytes.insert(0, "\x01\x02")
random_bytes.insert(15, "\x36")
I have a check printer that I want to connect in Delphi 7 by COM port and operate.
I have a command that I extracted with Serial Port Monitor:
STX "PIRI(781" FS NULL ETX "0B" wich is 02 50 49 52 49 28 37 38 31 1c 00 03 30 42 hex
The manual says the following:
CRC (which is the last two digits after the ETX) - packet checksum. It
is calculated by the following algorithm: executing XOR for every
byte of the block including ETX by excluding STX. The data of the
checksum take up two bytes and are a symbolic representation of the
numeric in a hexadecimal calculation system.
I tried to an ONLINE CRC calculator and return a 1B result and a 27 numeric.
How to do it? For "PIRI(781" FS NULL ETX it should be 0B
The documentation incorrectly identifies the check value as a CRC. It is not. It is simply the exclusive-or of the noted bytes. The exclusive-or of 50 49 52 49 28 37 38 31 1c 00 03 is 0b. You then convert the 0b to hex (with an upper case B, i.e. 0B), and get 30 42.
Using this (test) code to read a tEXt chunk from a PNG:
procedure TForm1.Button1Click(Sender: TObject);
var
PngVar: TPngImage;
n: Integer;
begin
PngVar := TPNGImage.Create;
PngVar.LoadFromFile('C:\test.png');
for n := 0 to pred(PngVar.Chunks.count) do
if PngVar.Chunks.item[n].Name='tEXt' then
with PngVar.Chunks.item[n] as TChunkTEXT do
memo1.lines.add(KeyWord+'='+Text);
end;
The code is from an example by the original author of the TPNGObject and was downloaded from embercardo's website. KeyWord contains the value of what the tEXt chunk is, in this case comment. Text contains the text we need. It is an AnsiString and should have breaks in them but when casting from AnsiString to unicode they are lost and it becomes one string with not even a space between the end and start of a line.
Stepping through the debugger I noticed It had each line in single quotes and between the lines it has #$A which I assume if I check in hex are some form of control character.
comment=PunkBuster Screenshot (ñ) BF3 Levels/MP_017/MP_017'#$A'1135998 31.204.131.11:25530 GoTBF3.nl #4 | 32p | TDM Canals Only | 500 Tickets'#$A'geawtaw46y4w63a46a34643a BorislavFatsolka'#$A'Attempted: w=320 X h=240 at (x=50%,y=50%)'#$A'Resulting: w=320 X h=200 sample=1'
Sample Image
http://www.pbbans.com/pbss_evidence/bf3/31.204.131.11:25530/5d00a95d22fae4a287bd510c076db1bf-2e36c3b4.png
Here is the sample. What I am doing is reading data off punkbuster images to make them searchable in our communities database. But I also display the information next to the image and id like to have the line breaks and or know when the line ends.
When placed into memo or string list directly it comes out all one line like:
comment=PunkBuster Screenshot (ñ) BF3 Levels/MP_017/MP_0171135998 31.204.131.11:25530 GoTBF3.nl #4 | 32p | TDM Canals Only | 500 Tickets*geawtaw46y4w63a46a34643a* BorislavFatsolkaAttempted: w=320 X h=240 at (x=50%,y=50%)Resulting: w=320 X h=200 sample=1
Question
What is the best way to handle this ansistring which is what it is from the original image and or TPNGImage no real choice there. Putting it into a memo, rich edit or string list with the breaks intact.
The first thing that comes to mind is probably inefficient and thats just to throw it into a byte array or the like and read it byte by byte cutting each line at the end of line marks.
More Data from the example
You should be able to see this by downloading the example image but, this is how it looks in a hex editor (First part of the file intact, png header, tEXt chunk header keyword etc.
‰PNG........IHDR...Ž...2.....ûŒÆ$....tEXtcomment.PunkBuster Screenshot (ñ) BF3 Levels/MP_017/MP_017.1135998 31.204.131.11:25530 GoTBF3.nl #4 | 32p | TDM Canals Only | 500 Tickets.*geawtaw46y4w63a46a34643a* BorislavFatsolka.Attempted: w=320 X h=240 at (x=50%,y=50%).Resulting: w=320 X h=200 sample=1.
89 50 4E 47 0D 0A 1A 0A 00 00 00 0D 49 48 44 52 00 00 02 8E 00 00 01 32 08 02 00 00 00 FB 8C C6 24 00 00 01 03 74 45 58 74 63 6F 6D 6D 65 6E 74 00 50 75 6E 6B 42 75 73 74 65 72 20 53 63 72 65 65 6E 73 68 6F 74 20 28 F1 29 20 42 46 33 20 20 4C 65 76 65 6C 73 2F 4D 50 5F 30 31 37 2F 4D 50 5F 30 31 37 0A 31 31 33 35 39 39 38 20 33 31 2E 32 30 34 2E 31 33 31 2E 31 31 3A 32 35 35 33 30 20 47 6F 54 42 46 33 2E 6E 6C 20 23 34 20 7C 20 33 32 70 20 7C 20 54 44 4D 20 43 61 6E 61 6C 73 20 4F 6E 6C 79 20 7C 20 35 30 30 20 54 69 63 6B 65 74 73 0A 2A 67 65 61 77 74 61 77 34 36 79 34 77 36 33 61 34 36 61 33 34 36 34 33 61 2A 20 42 6F 72 69 73 6C 61 76 46 61 74 73 6F 6C 6B 61 0A 41 74 74 65 6D 70 74 65 64 3A 20 77 3D 33 32 30 20 58 20 68 3D 32 34 30 20 61 74 20 28 78 3D 35 30 25 2C 79 3D 35 30 25 29 0A 52 65 73 75 6C 74 69 6E 67 3A 20 77 3D 33 32 30 20 58 20 68 3D 32 30 30 20 73 61 6D 70 6C 65 3D 31 0A
Other Findings
If I dump the Chunk (PngVar.Chunks.item[n].SaveToStream) it gives me basically what we find in the hex editor. The control characters are 0A. I am not sure if the #$A is a before or after conversion effect maybe even being caused by the pngimage code.
Try:
memo1.lines.add(KeyWord+'='+StringReplace(Text,#10,sLineBreak,[rfReplaceAll]));
Another approach would be Jedi CodeLib
sl := TJclStringList.Create;
sl.Split(Text, #10);
sl[0] := 'Keyword=' +sl[0]
memo1.lines.AddStrings(sl);
sl.Free;