I am trying to send font commands to a Videojet printer using scripts.
It works up until I try to send a Data Font command.
Here is the script as it worked before using a single line print
#Select the 5x HQ dual Line Matrix for use when creating a message
command = "1B".decode('hex') + "04".decode('hex') + "05".decode('hex')
#Create Message to print
message = line1 + TAB + line2 + CRETURN
command = command + message + CRETURN
reply = socketReqWithReply(host,command)
reply = reply.encode('hex')
return reply
Now what I am trying that is failing. I believe it is due to the “81”.decode(‘hex’) portion as if I change that number it stops giving me the error
#Select the 7x9 Tri Line Matrix for use when creating a message
command = "1B".decode('hex') + "04".decode('hex') + "07".decode('hex')
command2 = "1B".decode('hex') + '81'.decode('hex') + "20".decode('hex')
command3 = "1B".decode('hex') + '81'.decode('hex') + "20".decode('hex')
command = command + command2 + line1 + TAB + command3 + line2 + CRETURN
reply = socketReqWithReply(host,command)
reply = reply.encode('hex')
The error I get
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x81 in position 4: unexpected code byte