Modern thermal printer to emulate 82240B
02-25-2018, 01:24 AM (This post was last modified: 02-25-2018 12:14 PM by tcab.)
Post: #1
 tcab Junior Member Posts: 31 Joined: Dec 2017
Modern thermal printer to emulate 82240B
I'm looking for advice on how to print to a modern day thermal printer from my PC/Mac using the HP calculator codepage Modified_HP_Roman-8 in order to emulate a HP 82240B thermal printer. I happen to have a Epson TM-T20 thermal printer which uses the ESCPOS language.

Note that I'm not trying to print from a calculator to this printer (that's hard, needs infra red electronics etc). I'm just trying to print Free42 virtual printer output to this modern (and fast!) thermal printer.

The TM-T20 has a custom codepage feature but I don't know how to build that codepage and use it? There is some heavy duty Epson documentation - perhaps I need to send some custom bytes to the printer to define the custom code table and then select it that codepage before I print to the printer. Not at all sure how to define this codepage to match the 82240. Does anyone have any thoughts, advice or resources I could draw upon? Some 'code' in some programming language that defines the relevant codepage would be great.

There is a related thread on the HP codepage used in the 82240 printer.
02-25-2018, 03:17 AM
Post: #2
 Thomas Okken Senior Member Posts: 450 Joined: Feb 2014
RE: Modern thermal printer to emulate 82240B
If you can send graphics to the printer, you might be better off translating the bitmap part of the shell_print() calls to graphics escape sequences and sending only those. That way you'd get the actual HP-42S character shapes, no worrying about code pages, and as a bonus, PRLCD would also work.
02-25-2018, 11:41 AM (This post was last modified: 02-25-2018 11:43 AM by martinot.)
Post: #3
 martinot Junior Member Posts: 40 Joined: Aug 2017
RE: Modern thermal printer to emulate 82240B
Now you already have a printer, but if you ever get a new one there are several POS printers that support the full Unicode UTF-8 character set, which should be trivial to set up a convert map of HP Roman 8 charters to.

(One example of such POS printer: http://www8.hp.com/h20195/v2/GetDocument...pt-printer)

HP 35s, HP 50g, HP Elite X3, SwissMicros DM42
02-25-2018, 12:42 PM
Post: #4
 tcab Junior Member Posts: 31 Joined: Dec 2017
RE: Modern thermal printer to emulate 82240B
(02-25-2018 03:17 AM)Thomas Okken Wrote:  If you can send graphics to the printer, you might be better off translating the bitmap part of the shell_print() calls to graphics escape sequences and sending only those. That way you'd get the actual HP-42S character shapes, no worrying about code pages, and as a bonus, PRLCD would also work.

I presume this would mean a custom build of Free42, adding some code to its shell_print() function. This would indeed be a powerful approach, with the downside of having to recompile Free42. Perhaps Free42 could have an option to generate another kind of file, a 'raw virtual out' which has all the information needed to print both text and graphics, which would mean custom builds of Free42 would not be necessary.

My current lazy approach has been to watch the text file generated by the 'Print to textfile' feature of Free42 - detect and read any new text output and print it to the TM-T20 thermal printer, using ESCPOS commands. This works, except for the rendering of special characters. And yes, I don't get graphics.
02-25-2018, 11:12 PM
Post: #5
 Thomas Okken Senior Member Posts: 450 Joined: Feb 2014
RE: Modern thermal printer to emulate 82240B
(02-25-2018 12:42 PM)tcab Wrote:
(02-25-2018 03:17 AM)Thomas Okken Wrote:  If you can send graphics to the printer, you might be better off translating the bitmap part of the shell_print() calls to graphics escape sequences and sending only those. That way you'd get the actual HP-42S character shapes, no worrying about code pages, and as a bonus, PRLCD would also work.

I presume this would mean a custom build of Free42, adding some code to its shell_print() function. This would indeed be a powerful approach, with the downside of having to recompile Free42. Perhaps Free42 could have an option to generate another kind of file, a 'raw virtual out' which has all the information needed to print both text and graphics, which would mean custom builds of Free42 would not be necessary.

In other words, you don't want to do it, and would prefer if I did it?
Sorry, but no.

(02-25-2018 12:42 PM)tcab Wrote:  My current lazy approach has been to watch the text file generated by the 'Print to textfile' feature of Free42 - detect and read any new text output and print it to the TM-T20 thermal printer, using ESCPOS commands. This works, except for the rendering of special characters. And yes, I don't get graphics.

That's not a bad approach, but as far as the special characters are concerned, bear in mind that the text file output from Free42 is UTF-8 encoded, not HP Roman.

You could even get graphics this way, using the "print to gif" feature.
02-26-2018, 02:08 AM
Post: #6
 mfleming Member Posts: 241 Joined: Jul 2015
RE: Modern thermal printer to emulate 82240B
(02-25-2018 03:17 AM)Thomas Okken Wrote:  If you can send graphics to the printer, you might be better off translating the bitmap part of the shell_print() calls to graphics escape sequences and sending only those. That way you'd get the actual HP-42S character shapes, no worrying about code pages, and as a bonus, PRLCD would also work.

Here's a link to an interesting project in which the author was trying to build an HP82240B replacement using a low cost Chinese POS printer from TAS. He took the bitmap approach so you can learn something from his experience doing so.

My conclusion from his travails with two low cost units is that POS has an alternative scatological meaning
~Mark

Where's my personal jet pack?
02-26-2018, 06:12 PM (This post was last modified: 02-26-2018 06:13 PM by martinot.)
Post: #7
 martinot Junior Member Posts: 40 Joined: Aug 2017
RE: Modern thermal printer to emulate 82240B
(02-25-2018 11:12 PM)Thomas Okken Wrote:  That's not a bad approach, but as far as the special characters are concerned, bear in mind that the text file output from Free42 is UTF-8 encoded, not HP Roman.

Great! When it is very easy if you just get a modern POS printer which supports Unicode UTF-8 (like the HP I linked to above).

Not applicable for the original poster (unless he sells his current and get a new), but generally a very good thing for us other users.

HP 35s, HP 50g, HP Elite X3, SwissMicros DM42
02-28-2018, 05:37 AM
Post: #8
 tcab Junior Member Posts: 31 Joined: Dec 2017
RE: Modern thermal printer to emulate 82240B
(02-25-2018 11:12 PM)Thomas Okken Wrote:  You could even get graphics this way, using the "print to gif" feature.

I've been playing with this approach today and got something working. The Free42 "print to gif" feature generates sequentially numbered GIF files. Specifying out.gif in Free42 preferences creates the following sequence of files:

Code:
 out.0000.gif out.0001.gif out.0002.gif ...

My algorithm looks for new files being generated and prints them to the thermal printer. New files are generated once 'Maximum GIF height (pixels)' has been filled (see Free42 preferences). Depending on how the user sets this value, new files can be emitted rarely or very frequently. I want new GIF files as frequently as possible because my goal is to have the thermal printer respond and track Free42 virtual tape output exactly.

It turns out that I cannot print a GIF file until it has been fully flushed and closed by Free42 - till then the file sits at 0 bytes and thus has no content, as far as my external program/script can see. Ideally I need to set the maximum gif height to 10.667 which seems to correspond to exactly one line of Free42 text output. My algorithm:
• Each Free42 text line that gets emitted to virtual tape is output to a new GIF file
• That new GIF file containing that line is flushed and closed
• My program/script sees the new, non zero byte GIF file and prints it to the thermal printer immediately

Nice plan - except Free42 won't let me enter 10.667 into the dialog box, 32 is the minimum value. This means that there is a 'buffer' of 3 lines before you see anything on my epson tm-ts20 escpos thermal printer. You may be lucky and your Free42 output happens to correspond with a filling up and closing of the most recent gif file- or you may not be so lucky. I can work around this by manually sending a few paper ADV commands in Free42 to 'flush' things out.

So close to a nice solution! At least I didn't have to modify Free42 and compile it etc :-) This approach works with standard Free42 builds available to everyone. The proliferation of GIF files is a nuisance but my script could potentially delete them as it prints them. And the GIF files seem to mesh perfectly on the thermal printer output - one wouldn't know the output was comprised of separate files.

02-28-2018, 09:05 PM
Post: #9
 Marcus von Cube Senior Member Posts: 753 Joined: Dec 2013
RE: Modern thermal printer to emulate 82240B
There is another way: Connect the emulated calculator and the (emulated) printer with a local socket. Here is some code from WP-34s (print.c):
Code:
/*  *  Send printer output to emulated HP 82440B by Christoph Gieselink  */ #undef State #undef Alpha #define shutdown shutdown_socket #include <winsock.h> #define UDPPORT 5025 #define UDPHOST "127.0.0.1" int put_ir( int c ) {     int s;     WSADATA ws;     struct sockaddr_in sa;     set_IO_annunciator();     WSAStartup( 0x0101, &ws );     sa.sin_family = AF_INET;     sa.sin_port = htons( UDPPORT );     sa.sin_addr.s_addr = inet_addr( UDPHOST );     s = socket( AF_INET, SOCK_DGRAM, 0 );     sendto( s, (const char *) &c, 1, 0, (struct sockaddr *) &sa, sizeof( struct sockaddr_in ) );     closesocket( s );     return 0; }
The output goes typically to Christoph Gieselink's HP 82440B emulator or its equivalent which is part of the WP-34s project. Only the latter would need to be adapted to send output to a physical printer instead of the screen.

I'm not proficient enough with Free42 to tell if the application can do the same, i. e. sent its IR output to a socket.

Marcus von Cube
Wehrheim, Germany
http://www.mvcsys.de
http://wp34s.sf.net
http://mvcsys.de/doc/basic-compare.html
03-01-2018, 01:50 AM
Post: #10
 Thomas Okken Senior Member Posts: 450 Joined: Feb 2014
RE: Modern thermal printer to emulate 82240B
(02-28-2018 09:05 PM)Marcus von Cube Wrote:  I'm not proficient enough with Free42 to tell if the application can do the same, i. e. sent its IR output to a socket.

Free42 generates its simulated printer output directly, by painting on the screen, generating GIF files, or generating UTF-8 encoded text. There is no 82240 emulation, and no output to infrared or to a socket.

Of course it is possible to hack Free42 to make it drive an actual printer, and that is what SwisdMicros have done in the DM42. But vanilla Free42 does not have that functionality.
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)