Possible Project - slightly off-topic!

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
RWAP
Site Admin
Posts: 1316
Joined: Thu May 08, 2008 8:42 am
Location: Stoke-on-Trent, UK
Contact:

Possible Project - slightly off-topic!

Post by RWAP » Fri Sep 13, 2013 10:41 pm

Every now and then I keep thinking of a nice project that has been in the back of my mind for a number of years.

With all of the inqusitive and technical minds on here, does anyone have much experience of programming a Raspberry Pi or similar?

Basically I can see a market for a small inteface which would connect anything with a centronics interface to a modern printer - obviously the printer would need Linux drivers available, but that's it...

The Raspberry Pi and similar are ideal as it could easily be set up to load new drivers as required, has a small footprint and needs low power.

It would basically need to run a single program which looks for data coming from the centronics / parallel port and would then output that using the inbuilt printer driver to its own installed printer - via USB or similar. The program would need to understand ESC/P2 codes and potentially HP's PCL5 codes...

It would suit a range of retro computers, such as the QL, Spectrum and ZX81 with a centronics interface, but also would suit anyone running a DOS based system, or even industrial machinery....

Any suggestions as to how to take this project forward? Anyone interested in partnering with me?

swensont
Posts: 61
Joined: Tue Jan 18, 2011 4:55 am
Location: SF Bay Area

Re: Possible Project - slightly off-topic!

Post by swensont » Sat Sep 14, 2013 6:59 am

From what you written, the needs would be this:

1. catch any print output coming into the parallel port.
2. Convert to what ever the local printer is
3. Send to local printer.

For #1, a daemon could be written that read the parallel port device. With Linux/Unix all ports are files, so the program would just monitor a file on the /dev/ tree. Any incoming data would be send to a file. The hard part would be to determine when the data is done being sent. There might be some character code that defines end of data.

The next step would be getting the file to step #2. To make sure the file is not processed before it is completed, the daemon would have to send a signal, release a lock file, move the file to a new directory, or something to let the follow on program know the print file is ready.

For #2, this program would translate the print data into a format needed by the Linux printer driver. I've never looked into the details of the Linux printer driver, but since it handles the config of the printer, I'm sure that all programs just send data to the printer driver in the format it wants and the printer driver then converts it into the format needed by the printer, be it PCL or Postscript. This might be the hardest part to write, as it would require research into the printer driver.

Step #3, would be handled by the program from Step #2.

If done right, the whole thing could be very portable and run on any Linux system, and not just the Raspberry PI. The advantage of a system like this is that to the QL/ZX81 user, printing would be transparent. It might be a little delayed, but pretty much hands off. The down side is that the Linux system would have to be on while the QL/ZX81 is also on. So the system would be a desktop system and not a laptop.

There are other ways to printing from the QL/ZX81 to a remote printer, but not as transparent as this approach.

As for moving forward, you can start on the first part and it should be fairly easy. The program could be written in C or Perl. C gives you more power, but Perl is easier to code. Part 2 could also be done in C or Perl, depending on the needs of the Linux printer driver.

I know there is a segment of the Sinclair community that prefers original hardware, but I'm one for using emulators and would prefer to see different emulators with a print capability added on. This might take more work as it would take an understanding of the different emulators.

Tim Swenson

RWAP
Site Admin
Posts: 1316
Joined: Thu May 08, 2008 8:42 am
Location: Stoke-on-Trent, UK
Contact:

Re: Possible Project - slightly off-topic!

Post by RWAP » Sat Sep 14, 2013 9:59 am

Step 1 could finish as soon as there is no more data for a specific time (say 200ms) (not sure if a parallel port uses CTRL Z or handshaking of any kind to signify end of data) or if an ESC @ code is sent (printer reset).

Step 2 is the major issue - yes....

I presume that what would be needed is to create an intermediate document which replicates the layout from the original print codes - you could then use the built in print functions as though you were sending a text file to the printer...

User avatar
1024MAK
Posts: 2574
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Possible Project - slightly off-topic!

Post by 1024MAK » Sat Sep 14, 2013 1:33 pm

Dot matrix line printers and the software designed to drive them normally uses a FF (form feed) control code to force a move to the next page at the end of printing (so ejecting the last page of printed output).

However, in simple print on demand applications (like BASIC), data is sent as and when it is processed by the computer. Dot matrix printers typically buffer only one line of characters (so in 80 column mode, 80 characters) before printing. They then print the whole line. They will then wait for more data. They will print the line if they get a CR and or LF control code (depending on the printer mode setting).

Old ink-jets that have parallel ports and which are "DOS compatible" do something similar (at least the two that I have do).

If a dot matrix is using fan-fold paper, unless a skip mode is enabled, it will just keep printing line by line.

For dot matrix printers, when using A4 sheet paper, with the proper mode selected, once paper end (paper out) is detected, the printer will stop printing and set the busy signal to the computer. If the sheet feeder is human, the printer and computer will wait (some computer printer drivers did time out after X minutes). If there is a automatic sheet feeder, printing will restart on the next page.

At no point is there an end of data communication.

So a system to interface a parallel port input to a modern printer driver should look for the Form Feed control character and keep track of how many lines have been received. Then if no more data arrives, either "time-out" and print, or we need to ask the user to indicate that they want the current page printing (include a push button?).

Of course, this is tricky as not all fonts are the same height, graphics and different control settings can change the line spacing, etc
And of course this all needs to be processed so that it can be printed on A4 paper (taking into account that most printers cannot print right up to the edge of the paper unlike older dot matrix printers).

Mark

sirmorris
Posts: 2813
Joined: Thu May 08, 2008 5:45 pm

Re: Possible Project - slightly off-topic!

Post by sirmorris » Sat Sep 14, 2013 3:08 pm

No, no no you've got it all wrong. You need to emulate the following behaviour:

0. Attach printer to computer.
1. Turn printer on.
2. Select print.
3. Wait.
4. Get tired of waiting and poke some buttons.
5. Paper starts spooling out of the printer uncontrolably.
6. Press random buttons till it stops, fiddle with settings.
7. Select print.
8. Watch as random characters emerge onto the paper, some in double-height
9. Poke at random buttons until it stops.
10. Turn off printer.
11. Goto 1.

As someone wise once said: 'I'll worry about intelligent machines taking over the world when my computer recognises my printer'.

User avatar
1024MAK
Posts: 2574
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Possible Project - slightly off-topic!

Post by 1024MAK » Sat Sep 14, 2013 3:25 pm

:lol: :lol: :lol:
ImageImageImage

Mark

RWAP
Site Admin
Posts: 1316
Joined: Thu May 08, 2008 8:42 am
Location: Stoke-on-Trent, UK
Contact:

Re: Possible Project - slightly off-topic!

Post by RWAP » Sat Sep 14, 2013 4:11 pm

sirmorris wrote:No, no no you've got it all wrong. You need to emulate the following behaviour:

0. Attach printer to computer.
1. Turn printer on.
2. Select print.
3. Wait.
4. Get tired of waiting and poke some buttons.
5. Paper starts spooling out of the printer uncontrolably.
6. Press random buttons till it stops, fiddle with settings.
7. Select print.
8. Watch as random characters emerge onto the paper, some in double-height
9. Poke at random buttons until it stops.
10. Turn off printer.
11. Goto 1.

As someone wise once said: 'I'll worry about intelligent machines taking over the world when my computer recognises my printer'.
Sorry - but stage 11 is wrong.... In my experience most printers don't clear the print queue when switched off, so when you turn it back on, it is in the middle of processing whatever information it was dealing with, so just spools out even more reams of rubbish.....

User avatar
Andy Rea
Posts: 1546
Joined: Fri May 09, 2008 2:48 pm
Location: notts UK

Re: Possible Project - slightly off-topic!

Post by Andy Rea » Sat Sep 14, 2013 5:14 pm

ah ah i once has an old fx-80 that behaved in a very similar fashion, sadly it died and was replaced by an ultra modern 24pin model that too misbehaved on a regular basis
6 x ZX81, 1 x TS1500 , 1 x +3e, 1 x timex 2040 printer, 1 x timex 2020 cassette deck, siclair printer and some spectrum

User avatar
PokeMon
Posts: 2225
Joined: Sat Sep 17, 2011 6:48 pm

Re: Possible Project - slightly off-topic!

Post by PokeMon » Sat Sep 14, 2013 7:40 pm

sirmorris wrote: 0. Attach printer to computer.
1. Turn printer on.
2. Select print.
3. Wait.
4. Get tired of waiting and poke some buttons.
5. Paper starts spooling out of the printer uncontrolably.
6. Press random buttons till it stops, fiddle with settings.
7. Select print.
8. Watch as random characters emerge onto the paper, some in double-height
9. Poke at random buttons until it stops.
10. Turn off printer.
11. Goto 1.
You really got it. I love my small ZX printer. :lol:
But you have a small bug.
I have to adjust the position of the connector on the back.
If not positioned correct, it will print nonsens.
So you have to go back to 0 if it doesn't print at all. ;)

Rink
Posts: 165
Joined: Wed Jun 27, 2012 5:48 pm

Re: Possible Project - slightly off-topic!

Post by Rink » Sat Sep 14, 2013 8:10 pm

My first printer was a dot matrix Mannesnann-Tally. The process above looks about right to me except for a few missing steps along the lines of the random prints using up the last of my paper and me going crying to my parents to buy me some more.

Edit: Think I gave up quite often and decided it was quicker just to write things on paper myself. Weirdly, my (former) workplace has spent thousands on fancy network printers which work so well that over 20 years since that dot matrix, it's still quicker to write the damn things out on paper. :roll:

Post Reply