How to use the escpos.conn.serial.Serial function in escpos

To help you get started, we’ve selected a few escpos examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github base4sistemas / pyescpos / escpos / conn / serial.py View on Github external
Scan for known serial ports available in the underling system.
    Returns a tuple of tuples where each inner tuple contains the port
    number and port name. For example:

    .. sourcecode:: python

        scan_ports()
        ((0, '/dev/ttyS0'), (1, '/dev/ttyS1'), ...)

    """
    names = []
    for number in range(256):
        try:
            # attempt attr `name` for PySerial >= 2.5-rc2,
            # where attr `portstr` is for older PySerial versions
            s = pyserial.Serial(number)
            name = getattr(s, 'name', getattr(s, 'portstr', str(number)))
            names.append((number, name,))
        except:
            pass
    return tuple(names)
github base4sistemas / pyescpos / escpos / conn / serial.py View on Github external
def get_databits():
    """
    Returns supported byte sizes in a Django-like choices tuples.
    """
    databits = []
    s = pyserial.Serial()
    for name, value in s.getSupportedByteSizes():
        databits.append((value, name,))
    return tuple(databits)
github base4sistemas / pyescpos / escpos / conn / serial.py View on Github external
def get_baudrates():
    """
    Returns supported baud rates in a Django-like choices tuples.
    """
    baudrates = []
    s = pyserial.Serial()
    for name, value in s.getSupportedBaudrates():
        baudrates.append((value, name,))
    return tuple(baudrates)
github base4sistemas / pyescpos / escpos / conn / serial.py View on Github external
def get_stopbits():
    """
    Returns supported stop bit lengths in a Django-like choices tuples.
    """
    stopbits = []
    s = pyserial.Serial()
    for name, value in s.getSupportedStopbits():
        stopbits.append((value, name,))
    return tuple(stopbits)