ESCPOS Datamatrix command - printing

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

Related

Detect â in a string

I'm trying to detect the character â in a string in Objective C and can't seem to get it to work. It's displaying a bullet point when it's finally displayed on screen, so maybe that's why I can't detect it?
In iOS 10 these bullet points display larger than they should, so I need to find the range of each of these characters and make them a few sizes smaller. I've tried the following:
[inputString contains:#"â"]
[inputString contains:#"•"]
[inputString contains:#"\u00b7"]
[inputString contains:#"\u2022"]
The one that interests me the most is when I copy and paste exactly from the API response: [inputString contains:#"â "]. There's actually 4 or 5 spaces in that string, but they get truncated when pasting from the JSON I get back -- I'm not sure why but I feel like that has to do with why I can't recognize the string contains that character.
Any ideas on how to correctly deal with this character?
Edit: Few more details, here's the string that gets sent back from API:
â All of your exclusive deals in one place\nâ More deals matched specifically to you\nâ Get alerts to know when new deals are available or your saved deals are expiring"
I noticed something weird as well, when I edit the response and add in more of those a's with a hat, they get moved into bullet points, however when I add them into the string in code, they are displayed as simply bullet points. Maybe they're being encoded somehow? Although I don't see anywhere in our code where that could be happening, so I'm a little confused as to what's going on here.
Edit 2: Here's a hexdump of the line, this is probably more useful to some of you than it is to me:
000026c0 6e 74 65 6e 74 22 3a 20 22 e2 97 8f 20 41 6c 6c |ntent": "... All|
000026d0 20 6f 66 20 79 6f 75 72 20 65 78 63 6c 75 73 69 | of your exclusi|
000026e0 76 65 20 64 65 61 6c 73 20 69 6e 20 6f 6e 65 20 |ve deals in one |
000026f0 70 6c 61 63 65 5c 6e e2 97 8f 20 4d 6f 72 65 20 |place\n... More |
00002700 64 65 61 6c 73 20 6d 61 74 63 68 65 64 20 73 70 |deals matched sp|
00002710 65 63 69 66 69 63 61 6c 6c 79 20 74 6f 20 79 6f |ecifically to yo|
00002720 75 5c 6e e2 97 8f 20 47 65 74 20 61 6c 65 72 74 |u\n... Get alert|
00002730 73 20 74 6f 20 6b 6e 6f 77 20 77 68 65 6e 20 6e |s to know when n|
00002740 65 77 20 64 65 61 6c 73 20 61 72 65 20 61 76 61 |ew deals are ava|
00002750 69 6c 61 62 6c 65 20 6f 72 20 79 6f 75 72 20 73 |ilable or your s|
00002760 61 76 65 64 20 64 65 61 6c 73 20 61 72 65 20 65 |aved deals are e|
00002770 78 70 69 72 69 6e 67 22 2c 0d 0a 20 20 20 20 22 |xpiring",.. "|
The bytes e2 97 8f in your dump is the UTF8 encoding of U+25CF, BLACK CIRCLE. When interpreted as ISO-8859 or Windows-1252 e2 is â (a circumflex), 97 is an em dash, and 8f is unused.
This indicates the JSON itself is UTF8 and somewhere is being interpreted differently, probably as one of the above encodings. You need to check both in your code and in the full server response (for an example of the latter causing an issue see the question JSON character encoding).
I'm trying to detect the character â in a string
There is no "â" in your text, so there is nothing to detect. e2 97 8f is a bullet character, "●". Your problem is that you're not setting the encoding correctly.

I9300 sboot.bin 256-Byte signatures, or checksum?

Some time ago I started trying to mod my Samsung Galaxy S3 (International edition (I9300)), and I ended up with the Bootlogo, this is the FIRST image that you see when you turn on the Galaxy S3. I wanted to change it, as it is quite easy on other devices.
This is where I ran into troubles, I asked around on XDA-developes [link 1] (http://forum.xda-developers.com/galaxy-s3/help/removal-bootlogo-t2662444) and [link 2] (http://forum.xda-developers.com/showthread.php?t=2317694) but most of the answers led me nowhere. I ended up with the sboot.bin which is the secondary boot program (I guess this is how you can call it). To open it was quite difficult for a noob like me, but with hexadecimal editor HxD I opened it and actually found the bootlogo! (I copied the bytes into a jpg and it showed up normally.) I changed the bytes with another jpg image I made myself, and tried to flash it to the phone, but it failed. everything I tried afterwards failed, and I wondered why.
I downloaded a couple of sboot.bin for the i9300, but different countries, and I compared the hex code. There seemed to be subtle changes: one was in the compile date and serie nr. And there rest was a jumble of random character 256 bytes long.
I found that there are 4 sequences of 256 bytes long throughout the sboot.bin. An example of one:
EA E9 0C 62 B0 E0 68 86 5A 7B BD CA 50 3D 21 02
17 2C AC 10 09 49 62 E1 DA EB F4 94 B6 74 68 15
E6 90 2F CA 2F 75 67 C6 34 AE A3 A0 8F BC 60 62
63 87 8C C4 6C 8A 39 AA 7C 8A C7 E1 14 A3 C1 37
51 43 85 C0 09 97 05 AF 32 86 32 8C 58 7D C1 8F
91 A1 5E F1 9F D7 24 DF 08 82 1B AD FA C7 72 24
BC 35 34 6F 0F 42 C9 4E 7F AB FC 72 BC 64 71 84
DC 30 BB D5 AD D4 DE 01 9A E9 FB AA 1F 69 6F 52
3D E9 2A 52 6B 7E 9B 79 DE BD 7C 55 31 51 D6 99
BE 74 4F 22 6F 23 2F BF 7A 81 EF 5B 20 BF 75 03
D3 84 61 37 81 50 ED 71 66 4F 3D 34 0E 5A 33 4D
86 E2 E7 D0 8F 2B 48 5E 85 B5 E6 3F 56 51 70 74
CE 87 52 2D 47 D0 39 F6 CD 50 EE 76 F4 8E 79 7C
90 CF 4C 07 D5 47 AF 86 3D 33 3B A1 2A 70 74 4F
D1 60 9F 9E 28 96 C9 6E 9D DA 12 CB E1 8C 5B A5
CA AC 84 E2 26 1E 6F FD 4E EE B8 53 6E 7B 30 19
Maybe because it is helpful: one block is somewhat in the beginning, one is almost in the end, and the last two are at the real end of the file. So maybe the last two blocks are actually one big 512 byte block...
So I have come as far as to think that it might be a checksum or signature. But I am not sure how to find out what kind it is and how to generate one my self. searching for it hasn't helped me, because I cannot seem to find anything this long (256 bytes) only 256 bits long...
I was wondering if maybe someone could see what kind of siganture/checksum this is (Is this possible?) or how I can find out myself. or what I should do next...
[Edit on 25-08]
Alright, Since nobody has been able to answer the question yet, I was thinking of offering an incentive. I am willing to pay 1000 USD to whoever can help me alter the BOOTLOGO of the I9300!!!
Frank
Bootlogo is in the tar package /PARAMS and is called as logo.jpg, it should be writable via adb shell in twrp with this command:
cat /dev/block/platform/sdio_mmc/by-name/PARAMS > /sdcard/PARAMS.tar
Please note that PARAMS partition has stored SBOOT params at the end of the file. Just count 512 bytes from the last one, this is the last param, 512 bytes above is the next, until end of tar package.
Seems to be a checksum, though I cant be sure. One thing is certain, you've gone extremely deep in stuff. It could help to ask the guys at samsung, or somebody with great knowledge of kernels.
The first and second bootloader are signed.
A first bootloader that don't check the signatures of the second bootloader exist, so if you install that, you can then use u-boot as second bootloader.
See https://blog.forkwhiletrue.me/posts/an-almost-fully-libre-galaxy-s3/ for more details.

Encoding binary barcode in Passbook

I have to integrate Passbook with a website that provides PDF417 barcodes with data encoded in binary (as opposed to text), such as this:
Is there any way I can encode this binary chunk in pass.json so that Passbook displays it on the iPhone identically to the original picture?
Again, I cannot switch to text-based barcodes because I do not own the data. Just for clarification, the attached picture contains a PDF417 barcode that, when decoded, contains non-printable characters, such as the NULL character, which is why I refer to it as binary.
UPDATE
This is how the image decodes into a byte array:
01 00 01 00 02 00 E7 C4 B5 96 B8 42 94 B3 B4 75
1A D1 F2 38 92 EA B5 0E 17 5D 0B 2A AA 64 18 CC
28 62 86 E5 74 5D A3 89 09 12 6E D5 7A 1A C9 EE
BF 23 9C E1 60 AD 9E DE 92 6D E5 79 99 C7 91 F1
6A D5 82 2E B6 E3 81 24 F8 0A F8 E6 44 5D 56 D2
00 00 00 00 00 00 40 0D 00 09 20 23 00 96 13 5C
10 EC 0C EA A3 E8 A3 20 30 4B 2A 20 7D 0F BB DF
F7 5E FA 1E 76 F7 40 20 10 08 04 02 81 40 20 30
A3 D5 6C 1A 04 76 14 10
This is how I try to transform it into a utf-8 string:
{"message": "\u0001\u0000\u0001\u0000\u0002\u0000\u00E7\u00C4\u00B5\u0096\u00B8\u0042\u0094\u00B3\u00B4\u0075\u001A\u00D1\u00F2\u0038\u0092\u00EA\u00B5\u000E\u0017\u005D\u000B\u002A\u00AA\u0064\u0018\u00CC\u0028\u0062\u0086\u00E5\u0074\u005D\u00A3\u0089\u0009\u0012\u006E\u00D5\u007A\u001A\u00C9\u00EE\u00BF\u0023\u009C\u00E1\u0060\u00AD\u009E\u00DE\u0092\u006D\u00E5\u0079\u0099\u00C7\u0091\u00F1\u006A\u00D5\u0082\u002E\u00B6\u00E3\u0081\u0024\u00F8\u000A\u00F8\u00E6\u0044\u005D\u0056\u00D2\u0000\u0000\u0000\u0000\u0000\u0000\u0040\u000D\u0000\u0009\u0020\u0023\u0000\u0096\u0013\u005C\u0010\u00EC\u000C\u00EA\u00A3\u00E8\u00A3\u0020\u0030\u004B\u002A\u0020\u007D\u000F\u00BB\u00DF\u00F7\u005E\u00FA\u001E\u0076\u00F7\u0040\u0020\u0010\u0008\u0004\u0002\u0081\u0040\u0020\u0030\u00A3\u00D5\u006C\u001A\u0004\u0076\u0014\u0010";}
However, Passbook does not display an equivalent barcode. In fact, it displays just a few first bytes.
I don't think you want to decode the binary data of the image, but instead want to read the data from the barcode as if it were scanned.
You could use a service like http://zxing.org/w/decode.jspx which gives you the value of the barcode as if it were being scanned.
Send the 'Raw Text' value to pass.json.
I haven't used this service, but after a quick read I'm assuming it goes in 'message' below:
"barcode" : {
"message" : "ABCD 123 EFGH 456 IJKL 789 MNOP",
"format" : "PKBarcodeFormatPDF417",
"messageEncoding" : "iso-8859-1"
}
ref: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/PassKit_PG/Chapters/Creating.html#//apple_ref/doc/uid/TP40012195-CH4-SW1

Indy 10 IdTCPSever Readbytes scrambling data

I am trying to use Indy10 ReadBytes() in Delphi 2007 to read a large download of a series of data segments formatted as [#bytes]\r\n where #bytes indicates the number of bytes. My algorithm is:
Use ReadBytes() to get the [#]\r\n text, which is normally 10 bytes.
Use ReadBytes() to get the specified # data bytes.
Go to step 1 if more data segments need to be processed, i.e., # is negative.
This works well but frequently I don't get the expected text at step 1. Here's a short example after 330 successful data segments:
Data received from last step 2 ReadBytes(). NOTE embedded Step 1 [-08019]\r\n text.
Line|A033164|B033164|C033164|D033164|E033164|F033164|G033164|H033164|EndL\r|Begin
Line|A033165|B033165|C033165|D033165|E033165|F033165|G033165|H033165|EndL\r|Begin
Line|A033166|B033166|C033166|D033166|E033166|F033166|G033166|H033166|EndL\r[-08019]
\r\n|Begin
Line|A033167|B033167|C033167|D033167|E033167|F033167|G033167|H033167|EndL\r|Begin
Line|A033168|B033168|C033168|D033168|E033168|F033168|G033168|H033168|EndL\r|Begin
Socket data captured by WireShark.
0090 30 33 33 31 36 36 7c 42 30 33 33 31 36 36 7c 43 033166|B033166|C
00a0 30 33 33 31 36 36 7c 44 30 33 33 31 36 36 7c 45 033166|D033166|E
00b0 30 33 33 31 36 36 7c 46 30 33 33 31 36 36 7c 47 033166|F033166|G
00c0 30 33 33 31 36 36 7c 48 30 33 33 31 36 36 7c 45 033166|H033166|E
00d0 6e 64 4c 0d ndL.
No. Time Source Destination Protocol Length Info
2837 4.386336000 000.00.247.121 000.00.172.17 TCP 1514 40887 > 57006 [ACK] Seq=2689776 Ack=93 Win=1460 Len=1460
Frame 2837: 1514 bytes on wire (12112 bits), 1514 bytes captured (12112 bits) on interface 0
Ethernet II, Src: Cisco_60:4d:bf (e4:d3:f1:60:4d:bf), Dst: Dell_2a:78:29 (f0:4d:a2:2a:78:29)
Internet Protocol Version 4, Src: 000.00.247.121 (000.00.247.121), Dst: 000.00.172.17 (000.00.172.17)
Transmission Control Protocol, Src Port: 40887 (40887), Dst Port: 57006 (57006), Seq: 2689776, Ack: 93, Len: 1460
Data (1460 bytes)
0000 5b 2d 30 38 30 31 39 5d 0d 0a 7c 42 65 67 69 6e [-08019]..|Begin
0010 20 4c 69 6e 65 7c 41 30 33 33 31 36 37 7c 42 30 Line|A033167|B0
0020 33 33 31 36 37 7c 43 30 33 33 31 36 37 7c 44 30 33167|C033167|D0
0030 33 33 31 36 37 7c 45 30 33 33 31 36 37 7c 46 30 33167|E033167|F0
Does anyone know why this happens? Thanks
More information. We do socket reading from a single thread and don't call Connected() while reading. Here's relevant code snippet:
AClientDebugSocketContext.Connection.Socket.ReadBytes(inBuffer,byteCount,True);
numBytes := Length(inBuffer);
Logger.WriteToLogFile(BytesToString: '+BytesToString(inBuffer,0,numBytes),0);
Move(inBuffer[0], Pointer(Integer(Buffer))^, numBytes);
Embedded data like you describe, especially at random times, usually happens when you read from the same socket in multiple threads at the same time without adequate synchronization between them. One thread may receive a portion of the incoming data, and another thread may receive another portion of the data, and they end up storing their data in the InputBuffer in the wrong order. Hard to say for sure if that your problem since you did not provide any code. The best option is to make sure you never read from the same socket in multiple threads at all. That includes any calls to Connected(), since it performs a read operation internally. You should do all of your reading within a single thread. If that is not an option, then at least wrap your socket I/O with some kind of inter-thread lock, such as a critical section or mutex.
Update: You are accessing a TIdContext object via your own AClientDebugSocketContext variable. Where is that code being used exactly? If it is not in the context of the server's OnConnect, OnDisconnect, OnExecute, or OnException events, then you are reading from the same socket across multiple threads, because TIdTCPServer internally calls Connected() (which does a read) in between calls to the OnExecute event for that TIdContext object.

Delphi (2009) - Converting AnsiString reading or preserving line breaks?

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;

Resources