home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / hplip / prnt / pcl.py < prev    next >
Encoding:
Python Source  |  2007-04-04  |  1.9 KB  |  54 lines

  1. # -*- coding: utf-8 -*-
  2. #
  3. # (c) Copyright 2003-2007 Hewlett-Packard Development Company, L.P.
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  18. #
  19. # Author: Don Welch
  20. #
  21.  
  22.  
  23. import struct
  24. from base import pml
  25.  
  26. ESC = '\x1b'
  27. RESET = '\x1bE'
  28. UEL = '\x1b%-12345X'
  29. PJL_ENTER_LANG = "@PJL ENTER LANGUAGE=PCL3GUI\n"
  30. PJL_BEGIN_JOB = '@PJL JOB NAME="unnamed"\n'
  31. PJL_END_JOB = '@PJL EOJ\n'
  32.  
  33. def buildPCLCmd(punc, letter1, letter2, data=None, value=None):
  34.     if data is None:
  35.         return ''.join([ESC, punc, letter1, str(value), letter2])
  36.  
  37.     return ''.join([ESC, punc, letter1, str(len(data)), letter2, data])
  38.  
  39.  
  40. def buildEmbeddedPML(pml):
  41.     return ''.join([UEL, PJL_ENTER_LANG, RESET, pml, RESET, UEL])
  42.  
  43.  
  44. def buildEmbeddedPML2(pml):
  45.     return ''.join([RESET, UEL, PJL_BEGIN_JOB, PJL_ENTER_LANG, RESET, pml, RESET, PJL_END_JOB, RESET, UEL])
  46.  
  47.  
  48. def buildDynamicCounter(counter):
  49.     #return ''.join([UEL, PJL_ENTER_LANG, ESC, '*o5W\xc0\x01', struct.pack(">I", counter)[1:], UEL])
  50.     return ''.join([UEL, PJL_ENTER_LANG, ESC, '*o5W\xc0\x01', struct.pack(">I", counter)[1:], PJL_END_JOB, UEL])
  51.  
  52. def buildRP(a, b, c, d, e):
  53.     return ''.join(['\x00'*600, RESET, UEL, PJL_ENTER_LANG, buildPCLCmd('&', 'b', 'W', pml.buildEmbeddedPMLSetPacket('1.1.1.36', a + b + c + d + e, pml.TYPE_STRING)), RESET, UEL])
  54.