Modifiche ai comandi, mainDime e cose
parent
af78d34797
commit
4c361f2cc3
|
|
@ -47,7 +47,8 @@ MKPcommands = {
|
||||||
'command': 'TZ',
|
'command': 'TZ',
|
||||||
'success': '\x06\x02([0-9])OK\x03',
|
'success': '\x06\x02([0-9])OK\x03',
|
||||||
'error': '([0-9])E([0-9])',
|
'error': '([0-9])E([0-9])',
|
||||||
'args': ['imageName', 'printMode']
|
'args': ['imageName', 'printMode', 'fieldContent']
|
||||||
|
|
||||||
},
|
},
|
||||||
'sendImage': {
|
'sendImage': {
|
||||||
'defPrefix': True,
|
'defPrefix': True,
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,25 @@ import sys
|
||||||
import printer as p
|
import printer as p
|
||||||
import commands
|
import commands
|
||||||
import logging
|
import logging
|
||||||
|
import test
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
printer = p.MarkoPrinter('./conf.json')
|
isRunning = True
|
||||||
printer.connetti()
|
while isRunning:
|
||||||
|
connessa=True
|
||||||
|
#printer = p.MarkoPrinter('./conf.json', LOGGER)
|
||||||
|
#connessa = printer.connetti()
|
||||||
|
while connessa:
|
||||||
|
lastTimestamp = int(time.time()*100)
|
||||||
|
commandString = test.cmdString('callPrintImage', {'imageName': 'TM2.00I',
|
||||||
|
'printMode': '10',
|
||||||
|
'fieldContent': '\r{0}\r{0}\r'.format(lastTimestamp)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
LOGGER.debug(commandString)
|
||||||
|
#printer.sendCommand(commandString)
|
||||||
|
pass
|
||||||
|
pass
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
import socket
|
import socket
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
import test
|
||||||
|
|
||||||
class MarkoPrinter:
|
class MarkoPrinter:
|
||||||
def __init__(self, configFilePath):
|
def __init__(self, configFilePath, LOGGER):
|
||||||
|
self.LOGGER = LOGGER
|
||||||
self.inkStatCounter = 0
|
self.inkStatCounter = 0
|
||||||
self.printSock = None
|
self.printSock = None
|
||||||
self.headStatus = dict()
|
self.headStatus = dict()
|
||||||
|
|
@ -112,6 +114,20 @@ class MarkoPrinter:
|
||||||
self.printSock.recv(5)
|
self.printSock.recv(5)
|
||||||
self.sending = False
|
self.sending = False
|
||||||
return response, statusUpdated
|
return response, statusUpdated
|
||||||
|
|
||||||
|
def sendCommand(self, c):
|
||||||
|
self.sending = True
|
||||||
|
if self.connected:
|
||||||
|
try:
|
||||||
|
self.printSock.settimeout(1.0)
|
||||||
|
self.printSock.send(bytearray(test.cmdString(c, "ascii")))
|
||||||
|
self.printSock.settimeout(0.5)
|
||||||
|
return True
|
||||||
|
except socket.error as e:
|
||||||
|
self.LOGGER.error('Socket Error: {}'.format(e))
|
||||||
|
return False
|
||||||
|
self.sending = False
|
||||||
|
pass
|
||||||
|
|
||||||
def keepalive(self):
|
def keepalive(self):
|
||||||
statusUpdated = False
|
statusUpdated = False
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,12 @@ Created on Fri Sep 27 14:35:31 2019
|
||||||
import commands as cmd
|
import commands as cmd
|
||||||
import re
|
import re
|
||||||
|
|
||||||
def cmdString(cmdName):
|
def cmdString(cmdName, cmdArgs=None):
|
||||||
cmdDict = cmd.MKPcommands[cmdName]
|
cmdDict = cmd.MKPcommands[cmdName]
|
||||||
return str(cmd.DEFprefix['begin'] if cmdDict['defPrefix'] else cmdDict['begin']) + str(cmdDict['command']) + str(cmd.DEFprefix['end'] if cmdDict['defPrefix'] else cmdDict['end'])
|
return str(cmd.DEFprefix['begin'] if cmdDict['defPrefix'] else cmdDict['begin']) \
|
||||||
|
+ str(cmdDict['command']) \
|
||||||
|
+ str(';'.join([cmdArgs[k] for k in cmdDict['args']]) if cmdArgs is not None else '') \
|
||||||
|
+ str(cmd.DEFprefix['end'] if cmdDict['defPrefix'] else cmdDict['end'])
|
||||||
|
|
||||||
def checkResponse(cmdName,response):
|
def checkResponse(cmdName,response):
|
||||||
sucKey = 'success'
|
sucKey = 'success'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue