trigger brother_ql
This commit is contained in:
parent
4c3e40a658
commit
af66314336
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
# Install #
|
# Install #
|
||||||
|
|
||||||
`pip install qrcode sysv-ipc pycstruct`
|
`pip install qrcode sysv-ipc pycstruct brother-ql`
|
||||||
|
|
||||||
```
|
```
|
||||||
cd /root/
|
cd /root/
|
||||||
|
@ -14,7 +14,7 @@ cd reHDDPrinter
|
||||||
chmod +x reHDDPrinter.py
|
chmod +x reHDDPrinter.py
|
||||||
cp reHDDPrinter.service /lib/systemd/system/reHDDPrinter.service
|
cp reHDDPrinter.service /lib/systemd/system/reHDDPrinter.service
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable /lib/systemd/system/reHDDPrinter.service
|
systemctl enable --now /lib/systemd/system/reHDDPrinter.service
|
||||||
```
|
```
|
||||||
|
|
||||||
## Test printer manually ##
|
## Test printer manually ##
|
||||||
|
|
|
@ -7,12 +7,17 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sysv_ipc
|
import sysv_ipc
|
||||||
import pycstruct
|
import pycstruct
|
||||||
|
import os
|
||||||
|
from brother_ql.brother_ql_create import create_label
|
||||||
|
from brother_ql.raster import BrotherQLRaster
|
||||||
import layouter
|
import layouter
|
||||||
|
|
||||||
str_buffer_size = 64 #keep this synchronous to reHDD
|
str_buffer_size = 64 #keep this synchronous to reHDD
|
||||||
msg_queue_key = 0x1B11193C0 #keep this synchronous to reHDD
|
msg_queue_key = 0x1B11193C0 #keep this synchronous to reHDD
|
||||||
|
|
||||||
|
file_name = "output.png"
|
||||||
|
|
||||||
def get_struct_format():
|
def get_struct_format():
|
||||||
#keep this synchronous to struct in reHDD
|
#keep this synchronous to struct in reHDD
|
||||||
driveData = pycstruct.StructDef()
|
driveData = pycstruct.StructDef()
|
||||||
|
@ -39,7 +44,6 @@ def main():
|
||||||
driveData = get_struct_format().deserialize(message)
|
driveData = get_struct_format().deserialize(message)
|
||||||
|
|
||||||
rehdd_info = layouter.ReHddInfo("https://git.mosad.xyz/localhorst/reHDD", driveData['driveReHddVersion'])
|
rehdd_info = layouter.ReHddInfo("https://git.mosad.xyz/localhorst/reHDD", driveData['driveReHddVersion'])
|
||||||
|
|
||||||
drive = layouter.DriveData(
|
drive = layouter.DriveData(
|
||||||
drive_index=int(driveData['driveIndex']),\
|
drive_index=int(driveData['driveIndex']),\
|
||||||
drive_state=str(driveData['driveState']),\
|
drive_state=str(driveData['driveState']),\
|
||||||
|
@ -53,11 +57,14 @@ def main():
|
||||||
shred_timestamp=int(driveData['driveShredTimestamp']),\
|
shred_timestamp=int(driveData['driveShredTimestamp']),\
|
||||||
shred_duration=int(driveData['driveShredDuration']))
|
shred_duration=int(driveData['driveShredDuration']))
|
||||||
|
|
||||||
layouter.generate_image(drive, rehdd_info, "output.png")
|
layouter.generate_image(drive, rehdd_info, file_name)
|
||||||
|
qlr = BrotherQLRaster("QL-570")
|
||||||
|
create_label(qlr, file_name, '62')
|
||||||
|
with open("/dev/usb/lp0", 'wb') as file:
|
||||||
|
file.write(qlr.data)
|
||||||
|
os.remove(file_name)
|
||||||
except sysv_ipc.ExistentialError:
|
except sysv_ipc.ExistentialError:
|
||||||
print("ERROR: message queue creation failed")
|
print("ERROR: message queue creation failed")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -8,6 +8,7 @@ User=root
|
||||||
Group=root
|
Group=root
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
RestartSec=5s
|
RestartSec=5s
|
||||||
|
WorkingDirectory=/root/reHDDPrinter/
|
||||||
ExecStart=/usr/bin/python3 /root/reHDDPrinter/reHDDPrinter.py
|
ExecStart=/usr/bin/python3 /root/reHDDPrinter/reHDDPrinter.py
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
|
Loading…
Reference in New Issue