johntalton / mcp2221

MCP 2221 Controler Library
MIT License
3 stars 0 forks source link

Is this library/package useable? #314

Closed CerebrallyPerplexed closed 2 months ago

CerebrallyPerplexed commented 1 year ago

Excuse my lack of Node experience but this package appears to offer (potentially) exactly what I require i.e. a way to communicate with a USB > GPIO board which uses the MCP2221(A?) chip for UART/I2C/GPIO

I am using Node 18.15.0 and need to incorporate a way to set GPIO HIGH/LOW via an SB Components USB UART/I2C Debugger which exposes 4 x GPIO PINS This then controls a TB6600 stepper motor driver.

I do not really want to rely on python for this...

How would I use this package as there is no NPM module etc.?

johntalton commented 1 year ago

Thank for your interest

First, this is a WIP 😀

The preferred method of inclusion is to check out the repo and add to the package json as a local reference:

"@johntalton/mcp2221": "../mcp2221"

This is, as you noted, because there is no published npm

The main driver for this is the lack of full implementation and stability of this code

This code is 90% ... But the last 10% is always the hardest :)

The majority of testing has been focused on the i2c implementation (in the associated repo i2c-bus-mcp2221)

The most outstanding issue is the initialization code

The mcp2221 has a "unique" initialization procedure, this code currently "fails" to do that properly (as I test this from chrome browser)

This bug has "put on hold" all other testing as it's q blocker...

I hope that helps set the stage, as this lib should be a viable solution for your use case. But it will require some work :P

Addition testing / pull requests / feedback is always welcome.

As alternative, there are several other usb-i2c bridges... Sone have gpio embedded, sone require a second chip.. (iv used the excamera driver to control a mcp230XX chip for gpio)

Working in the browser is a unique environment that requires some filament and ever changing testing

Thanks again for your interest

CerebrallyPerplexed commented 1 year ago

Thank you for the detailed response.

I fully understand the WIP status and you have already undertaken a lot of work on it.

My area has always been / is more the trad side of web dev but I am becoming more exposed to Node.js now, and the area of PC > hardware (physical things like stepper motors etc.) interaction.

It has been a deep rabbit hole looking for readily available hardware at the right price, having the appropriate software support, in a convenient language that suits my needs. Plenty of hardware across the RPi / Arduino spectrum of course, and I have plenty of RPi's but that isn't the way I want to go on this current task.

It seems that the Numato USB>GPIO modules have good Node.js support but have found them long winded to obtain when in a hurry! I have an RTk.GPIO in the post as have found a PHP library / driver.

I will look more at this repo and if I am able to contribute, I will.

johntalton commented 2 months ago

As a clarification for posterity ... :)

this code has gone though "battle testing" and now is reliable and fully functional.

it supports the full range of GP functions as well as both FLASH and SRAM reads and updates

It supports Passwords Locking / Unlocking

it supports a full range of I²C communications (tested with a dozen or so real world devices)

it supports native WebHID as well node-hid implementations via ReadableStream APIs

Validation agains other implementations (python etc ...) for additional sanity checking

🚀 overall, this rock now :P