Cover image
Try Now
2020-04-17

Interface Python avec le MCP2200

3 years

Works with Finder

2

Github Watches

6

Github Forks

9

Github Stars

Drive the MCP2200 with python

MCP2200 is the Microchip USB-Serial transceiver. Datasheet

The USB link is also used to configure the device, and, as a bonus, to easily manage some GPIO and EEPROM on the device.

When connected to a computer, it creates 2 new USB devices

  • A USB CDC that's the actual virtual serial port any tool will use to communicate.
  • A USB HID, that can be used to personalize and configure the chip.

The MCP2200 is delivered along with a user interface that helps easily configuring it. BUT... it's pure Windows !!

Thanksfully, Microchip delivers this document as well : The fully documented HID protocol

This project implements the microchip specifications at 3 levels :

  • The graphical configuration tool
  • The USB HID specification
  • The API as described in the component's datasheet

Install

git clone https://github.com/cdtx/mcp2200.git
cd mcp2200
pip install -r requirements.txt
python setup install

GUI

GUI

Example at USB HID level

from cdtx.mcp2200.device import MCP2200Device

try:
    dev = mcp2200Device(autoConnect=True)
except:
    sys.exit('Cannot connect the device')

try:
    # Set GPIO 0 as output and set it
    config = dev.read_all()
    # Reset bit0 of IO_bmap
    config['IO_bmap'] &= 0xFE
    dev.configure(**config)
    dev.set_clear_outputs(Set_bmap=0x01, Clear_bmap=0x00)
finally:
    mcp2200.disconnects()

Example at API level

from cdtx.mcp2200.api import SimpleIOClass

# Init class and connect device
dev = SimpleIOClass()
dev.InitMCP2200(0x04d8, 0x00df)
assert dev.GetNoOfDevices() == 1

# Set GPIO 0 as output and set it
dev.SelectDevice(0)
assert dev.IsConnected() == True
# Set all pins as outputs
dev.ConfigureIO(0x00)
dev.SetPin(0)
assert dev.ReadPinValue(0) == 1

Problem with permissions ?

1. Quick and dirty solution is to install and run as root

2. Prefer allowing current user to manage USB devices

Add the following rule to file /etc/udev/rules.d/50-myrules.rules (create if necessary)
```
ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="00df", GROUP:="plugdev", MODE="0660"
```

The current user must belong to the __plugdev__ group
```
sudo usermode -a -G plugdev ${USER}
```

[Source](https://askubuntu.com/questions/112568/how-do-i-allow-a-non-default-user-to-use-serial-device-ttyusb0)

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • https://appia.in
  • Siri Shortcut Finder – your go-to place for discovering amazing Siri Shortcuts with ease

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • tomoyoshi hirata
  • Sony α7IIIマニュアルアシスタント

  • apappascs
  • Découvrez la collection la plus complète et la plus à jour de serveurs MCP sur le marché. Ce référentiel sert de centre centralisé, offrant un vaste catalogue de serveurs MCP open-source et propriétaires, avec des fonctionnalités, des liens de documentation et des contributeurs.

  • ShrimpingIt
  • Manipulation basée sur Micropython I2C de l'exposition GPIO de la série MCP, dérivée d'Adafruit_MCP230XX

  • jae-jae
  • MCP Server pour récupérer le contenu de la page Web à l'aide du navigateur sans tête du dramwright.

  • ravitemer
  • Un puissant plugin Neovim pour gérer les serveurs MCP (Protocole de contexte modèle)

  • patruff
  • Pont entre les serveurs Olllama et MCP, permettant aux LLM locaux d'utiliser des outils de protocole de contexte de modèle

  • pontusab
  • La communauté du curseur et de la planche à voile, recherchez des règles et des MCP

  • av
  • Exécutez sans effort LLM Backends, API, Frontends et Services avec une seule commande.

  • WangRongsheng
  • 🧑‍🚀 全世界最好的 LLM 资料总结 (数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Résumé des meilleures ressources LLM du monde.

  • Mintplex-Labs
  • L'application tout-en-un desktop et Docker AI avec chiffon intégré, agents AI, constructeur d'agent sans code, compatibilité MCP, etc.

  • appcypher
  • Serveurs MCP géniaux - une liste organisée de serveurs de protocole de contexte de modèle

    Reviews

    3 (1)
    Avatar
    user_1ZnlJ6UD
    2025-04-17

    The mcp2200 by cdtx is a phenomenal tool for efficient USB-to-serial conversion. I appreciate its reliable functionality and seamless integration in my projects. The detailed documentation on GitHub makes it easy to get started and utilize its full potential. If you need a solid converter, this is a must-have!