Skip to main content

Silabs CP2110 USB HID to UART bridge library

Project description

# Silicon Labs cp2110 Python library

This library provides a Python interface to the [Silicon Labs CP2110]( HID USB to UART bridge.

At this point in time this library presents only the parts of the [available API]( that are required for basic UART access.

# cp2110 Installation

Install via pip: `python -m pip install cp2110`.

The cp2110 library depends on the [pyhidapi]( Python module, which itself requires the `hidapi` shared library. On Linux distributions, this is generally in the repositories (for instance, under Debian you can install either libhidapi-hidraw0 or libhidapi-libusb0 depending on which backend you want to use).

# Example usage

import cp2110
import time

# This will raise an exception if a device is not found. Called with no
# parameters, this looks for the default (VID, PID) of the CP2110, which are
# (0x10c4, 0xEA80).
d = cp2110.CP2110Device()

# In some cases the device maker will override the VID and/or PID at the
# factory, so you'll need to pass parameters
cp2110.CP2110Device(vid=0xDEAD, pid=0xBEEF)

# You can also find a device by path.

# If you want to avoid the exception or want to detect the presence of a
# device without creating an object as a side-effect, use the
# `cp2110.enumerate` function. This has the same default values as the
# `CP2110Device` constructor.
usb_info = cp2110.enumerate()
if usb_info:

usb_info = cp2110.enumerate(vid=0xDEAD, pid=0xBEEF)
if usb_info:

# Fetch the current uart configuration. This is the UART connection from the
# CP2110 to the microcontroller (or whatever) it's wired up to.
c = d.get_uart_config()

# The UART settings are dictated by the device that embeds the CP2110. It
# may be configured correctly by default, or you may need to set manually.

# If you ever need to disable the UART, you can.

# And you can clear any pending data in the on-chip I/O buffers.
d.purge_fifos() # The default is cp2110.FIFO.BOTH

# Check if the UART is enabled.

# The UART in your device may need to be explicitly enabled, particularly if
# you've already explicitly disabled it as in this example.

# The write method accepts byte strings or arrays of ints.
d.write(b'hello world')
d.write([0x01, 0xff])

# The default read size will return 63 bytes (at most), which is the maximum
# supported by this chip. Reads do not block.
rv =


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pycp2110, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size pycp2110-1.0.0-py3-none-any.whl (6.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pycp2110-1.0.0.tar.gz (4.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page