Compare commits

..

No commits in common. "749dd37e1a49b41bdb150f4e4e7a32b909b0a5e5" and "890be17c996fc8aefdf11013b93bae1487b128bf" have entirely different histories.

1 changed files with 13 additions and 24 deletions

View File

@ -9,16 +9,21 @@ serialdevice='/dev/ttyUSB0'
chars=" qwertzuiopü+asdfghjklöä#yxcvbnm,.-QWERTZUIOPÜ*ASDFGHJKLÖÄ'´`YXCVBNM;:_1234567890ß!\"§$%&/()=?°²³|"
chars=" qwertzuiopü+asdfghjklöä#yxcvbnm,.-QWERTZUIOPÜ*ASDFGHJKLÖÄ'YXCVBNM;:_1234567890ß!\"§$%&/()=?°²³"
'''
Teilung 10: 65
Teilung 12: 78
Teilung 15: 97
'''
def main():
parser = argparse.ArgumentParser(description='Send Textfile over serial')
parser.add_argument('filename', help="file to print")
parser.add_argument('-d', '--device', nargs='?', help="serial device name")
parser.add_argument('-l', '--length', nargs='?', type=int, help="maximum line length")
parser.add_argument('-w', '--wait', nargs='?', type=int, help="wait after x characters")
parser.add_argument('-x','--dryrun', action="store_true", help="do not send anything to printer")
args = parser.parse_args()
@ -28,11 +33,6 @@ def main():
charsperline=int(args.length)
print("args.length: "+str(args.length))
print("Checking for maximum line length: "+str(charsperline))
waitafter=0
if args.wait is not None:
waitafter=int(args.wait)
print("Waiting after every "+str(charsperline)+" characters sent")
filename=args.filename
@ -46,11 +46,6 @@ def main():
lines=[x.rstrip() for x in lines] # remove whitespaces and linebreaks
lines=[x.replace("´", "´ ") for x in lines] # add space to chars where printer is not advancing
lines=[x.replace("`", "` ") for x in lines] # add space to chars where printer is not advancing
for iline,line in enumerate(lines):
if not set(line).issubset(chars+'\\'):
print(str(iline)+":"+str(line))
@ -62,21 +57,15 @@ def main():
exit()
if (args.dryrun):
print("Dry Run enabled")
print("Dry Run enabled. Exiting")
exit()
with serial.Serial(serialdevice, 9600, timeout=1) as ser:
charssent=0
for iline,line in enumerate(lines):
if waitafter>0 and charssent>waitafter:
input("Press Enter to continue...")
charssent=0
print(str(iline)+"/"+str(len(lines))+" ("+str(charssent)+")"+":"+str(line))
charssent+=len(line)
if (not args.dryrun):
ser.write(line.encode())
ser.write(b'\n')
for line in lines:
print(line)
ser.write(line.encode())
ser.write(b'\n')