Closed plhought closed 2 years ago
I think, it would solve the "problem" when the MCDU program gives out a normal word or .txt document instead of a .pdf
One workaround is to increase the font size in the server code (I found 28 works well). It gives imperfect but perfectly readable output. This could be made an option.
The other way is to print directly to the printer in raw mode.. this is very easy in Python using the excellent escpos library but I cannot find a good JS library (the “escpos” library on npm is unrelated unfortunately). At the moment I am using a small Python script that connects to the MCDU websocket server, listens for print events, and prints in raw mode. It’s by no means production ready; there is no error handling or reconnect logic, everything is hardcoded including the printer name. Dependencies are escpos and websockets (you will need to install these with pip).
#!/usr/bin/env python
import asyncio
import json
import textwrap
from escpos.printer import Win32Raw
import websockets
# tune for your printer
COLUMNS = 44
PRINTER_NAME = 'HP Receipt'
def flatten(t):
return [item for sublist in t for item in sublist]
def printer(message):
print(message)
p = Win32Raw(PRINTER_NAME)
p.open()
p.set(align='left', smooth=True)
p.text(message + "\n")
p.print_and_feed(n=3)
p.cut(mode='PART')
p.close()
async def printer_relay():
async with websockets.connect("ws://localhost:8080") as websocket:
while True:
message = await websocket.recv()
if message.startswith('print:'):
msg = json.loads(message[6:])
lines = flatten([m.replace('\\n', '\n').splitlines() for m in msg['lines']])
output = '\n'.join([textwrap.fill(l.rstrip(), COLUMNS) for l in lines])
printer(output)
asyncio.run(printer_relay())
thank you @tracernz , but its very hard to understand for no-Pro´s and even hard to replicate/dublicate :/
thank you @tracernz , but its very hard to understand for no-Pro´s and even hard to replicate/dublicate :/
Don't worry. We think about something to configure it.
Do you think it’s a quick fix to sort.
I also have a POS-58 printer and would really love this to be solved! Here is a photo of a .txt file printed (right) vs the MCDU PDF (left), and also the printer I’m using.
Has anybody tried it on the exp version check if that works.
Has anybody tried it on the exp version check if that works.
Experimental is only different for LNAV - otherwise identical to Dev
Same issue for me, different printer. It is a thermal printer though.
Several improvements in development: https://github.com/flybywiresim/a32nx/pull/6446
New parameters font-size and paper-size to adapt output to different printers.
Several improvements in development: #6446
New parameters font-size and paper-size to adapt output to different printers.
Amazing! What variable do need to enter after the new —paper-size argument ?
Several improvements in development: #6446 New parameters font-size and paper-size to adapt output to different printers.
Amazing! What variable do need to enter after the new —paper-size argument ?
This will all be documented - a draft of the documentation (which will be removed after the feature is released) is here: https://docs-git-fork-frankkopp-updt-webmcdu-docs-flybywire.vercel.app/fbw-a32nx/feature-guides/web-mcdu/#advanced-start-options Note: This is all still in development and subject to change!!
would it be possible that the MCDU gives out a .txt/word file, or is it just a .pdf?
Sorry folks I’m new to all this, are these changes now live in either the Development or experimental versions in the installer? Or can I download the server exe from here on GitHub?
thanks in advance from an enthusiastic newbie!!
Sorry folks I’m new to all this, are these changes now live in either the Development or experimental versions in the installer? Or can I download the server exe from here on GitHub?
thanks in advance from an enthusiastic newbie!!
Patience please :) - the PR with the improvements is still in development. https://github.com/flybywiresim/a32nx/pull/6446
Sorry folks I’m new to all this, are these changes now live in either the Development or experimental versions in the installer? Or can I download the server exe from here on GitHub? thanks in advance from an enthusiastic newbie!!
Patience please :) - the PR with the improvements is still in development. #6446
Ah understood! Thank you @frankkopp, I will sit down and wait in line with everyone else 😬 thanks for the amazing work!
Several improvements in development: #6446 New parameters font-size and paper-size to adapt output to different printers.
Amazing! What variable do need to enter after the new —paper-size argument ?
This will all be documented - a draft of the documentation (which will be removed after the feature is released) is here: https://docs-git-fork-frankkopp-updt-webmcdu-docs-flybywire.vercel.app/fbw-a32nx/feature-guides/web-mcdu/#advanced-start-options Note: This is all still in development and subject to change!!
The paper-size option doesn't really help with thermal-printers though? Won't it just spit out unneccesary lengths of blank thermal paper before printing the text itself?
Several improvements in development: #6446
New parameters font-size and paper-size to adapt output to different printers.
Amazing! What variable do need to enter after the new —paper-size argument ?
This will all be documented - a draft of the documentation (which will be removed after the feature is released) is here: https://docs-git-fork-frankkopp-updt-webmcdu-docs-flybywire.vercel.app/fbw-a32nx/feature-guides/web-mcdu/#advanced-start-options Note: This is all still in development and subject to change!!
The paper-size option doesn't really help with thermal-printers though? Won't it just spit out unneccesary lengths of blank thermal paper before printing the text itself?
Not according to the users who already tested this.
The paper-size option doesn't really help with thermal-printers though? Won't it just spit out unneccesary lengths of blank thermal paper before printing the text itself?
It does for me. The smaller the paper size the larger the text comes out.
Just tried this with my GoojPrt PT-200 58mm thermal printer (Paper Size set to C8 & font size10). The printout is perfect :-)
How can I get this option? I have only the old one's
I don't appear to have the options to change the text and the paper size they are not appearing on my command line
I don't appear to have the options to change the text and the paper size they are not appearing on my command line
This improvement feature is not yet released.
ahh okay just wasn't sure as @Tuftymeercat37 seem to have changed theirs
I have just purchased the thermal printer so I was testing it by downloading/installing the build from PR #6446. This is not merged into the published Dev or Experimental versions yet. Hopefully it will be soon as it looks like it's just waiting for review.
Aircraft Version
Development
Build info
Describe the bug
Utilizing the new print interface of the MCDU server, when utilizing a widely avialiable and inexpensive POS style thermal printer ("POS-58" type - which is widely re-branded as resold under a number of different brands - TEROW, WAVA, MUNBYN, Zjiang etc etc), the text is very small an unreadable - along with going through about a foot and half of thermal paper before actually attempting to print something. This is in contrast to a similar function on the FSLabs Airbus, which actually includes pre-built settings to support POS-58 thermal printers, as they are widely utilized by some of their userbase.
Expected behavior
The text would print more in a manner similar to the actual aircraft - which also uses a thermal-printer - although wider.
Steps to reproduce
References (optional)
Additional info (optional)
No response
Discord Username (optional)
Patrick#2854