<feed xmlns='http://www.w3.org/2005/Atom'>
<title>suspect-devices/circuitpython/extmod/machine_i2c.c, branch 5.1.x</title>
<subtitle>CircuitPython - a Python implementation for teaching coding with microcontrollers</subtitle>
<id>https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=5.1.x</id>
<link rel='self' href='https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=5.1.x'/>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/'/>
<updated>2019-12-04T15:29:57+00:00</updated>
<entry>
<title>protocols: Allow them to be (optionally) type-safe</title>
<updated>2019-12-04T15:29:57+00:00</updated>
<author>
<name>Jeff Epler</name>
<email>jepler@gmail.com</email>
</author>
<published>2019-12-03T20:50:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=238e12123690debaf2cf8488fb2a4d4003a06506'/>
<id>urn:sha1:238e12123690debaf2cf8488fb2a4d4003a06506</id>
<content type='text'>
Protocols are nice, but there is no way for C code to verify whether
a type's "protocol" structure actually implements some particular
protocol.  As a result, you can pass an object that implements the
"vfs" protocol to one that expects the "stream" protocol, and the
opposite of awesomeness ensues.

This patch adds an OPTIONAL (but enabled by default) protocol identifier
as the first member of any protocol structure.  This identifier is
simply a unique QSTR chosen by the protocol designer and used by each
protocol implementer.  When checking for protocol support, instead of
just checking whether the object's type has a non-NULL protocol field,
use `mp_proto_get` which implements the protocol check when possible.

The existing protocols are now named:
    protocol_framebuf
    protocol_i2c
    protocol_pin
    protocol_stream
    protocol_spi
    protocol_vfs
(most of these are unused in CP and are just inherited from MP; vfs and
stream are definitely used though)

I did not find any crashing examples, but here's one to give a flavor of what
is improved, using `micropython_coverage`.  Before the change,
the vfs "ioctl" protocol is invoked, and the result is not intelligible
as json (but it could have resulted in a hard fault, potentially):

    &gt;&gt;&gt; import uos, ujson
    &gt;&gt;&gt; u = uos.VfsPosix('/tmp')
    &gt;&gt;&gt; ujson.load(u)
    Traceback (most recent call last):
      File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    ValueError: syntax error in JSON

After the change, the vfs object is correctly detected as not supporting
the stream protocol:
    &gt;&gt;&gt; ujson.load(p)
    Traceback (most recent call last):
      File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    OSError: stream operation not supported
</content>
</entry>
<entry>
<title>Fix unix build</title>
<updated>2019-01-18T20:52:27+00:00</updated>
<author>
<name>Scott Shawcroft</name>
<email>scott@tannewt.org</email>
</author>
<published>2019-01-18T20:52:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=58a2009cc11ac6b080d182854d0f669a6f65647a'/>
<id>urn:sha1:58a2009cc11ac6b080d182854d0f669a6f65647a</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Fix esp and samd</title>
<updated>2018-08-17T00:41:35+00:00</updated>
<author>
<name>Scott Shawcroft</name>
<email>scott@tannewt.org</email>
</author>
<published>2018-08-16T20:34:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=2cd166b57370ab4877ec2d9666225faeac6127ce'/>
<id>urn:sha1:2cd166b57370ab4877ec2d9666225faeac6127ce</id>
<content type='text'>
</content>
</entry>
<entry>
<title>all: Convert remaining "mp_uint_t n_args" to "size_t n_args".</title>
<updated>2017-08-30T00:59:58+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-08-30T00:59:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=71c9cfb028d423bf4760d66b1afe8951335fa5da'/>
<id>urn:sha1:71c9cfb028d423bf4760d66b1afe8951335fa5da</id>
<content type='text'>
This is to have consistency across the whole repository.
</content>
</entry>
<entry>
<title>extmod/machine_i2c: Add hook to constructor to call port-specific code.</title>
<updated>2016-11-23T13:12:51+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-11-23T13:12:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=5d2279bec12da4da62e38544608198b57a47efd2'/>
<id>urn:sha1:5d2279bec12da4da62e38544608198b57a47efd2</id>
<content type='text'>
If MICROPY_PY_MACHINE_I2C_MAKE_NEW is defined then it is called when an
I2C object is constructed with an id which is not -1.
</content>
</entry>
<entry>
<title>extmod/machine_i2c: Expose soft I2C obj and readfrom/writeto funcs.</title>
<updated>2016-11-23T13:11:45+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-11-23T13:11:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=8b74048d2a94bf254a49504a8c11a65fd5ec322f'/>
<id>urn:sha1:8b74048d2a94bf254a49504a8c11a65fd5ec322f</id>
<content type='text'>
For external use by ports if needed.
</content>
</entry>
<entry>
<title>extmod/machine_i2c: Remove trivial function wrappers.</title>
<updated>2016-11-23T06:05:38+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-11-23T05:54:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=4c905616f08fa29d83e2fc2c0b2a5233c998e008'/>
<id>urn:sha1:4c905616f08fa29d83e2fc2c0b2a5233c998e008</id>
<content type='text'>
</content>
</entry>
<entry>
<title>extmod/machine_i2c: Add 'stop' argument to i2c readfrom/writeto meths.</title>
<updated>2016-11-23T06:05:38+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-11-23T05:37:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=37333cb00a9e08961045b444a4b090c358e57b1c'/>
<id>urn:sha1:37333cb00a9e08961045b444a4b090c358e57b1c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>extmod/machine_i2c: Make i2c.write[to] methods return num of ACKs recvd.</title>
<updated>2016-11-23T06:05:38+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-11-23T05:36:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=0bc99b48365d52a18685c1faf26e155817dd536c'/>
<id>urn:sha1:0bc99b48365d52a18685c1faf26e155817dd536c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>extmod/machine_i2c: Add 'nack' argument to i2c.readinto.</title>
<updated>2016-11-23T06:05:38+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-11-23T05:34:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=07e83573c8f69c673a8bea78d6a2f242152da00c'/>
<id>urn:sha1:07e83573c8f69c673a8bea78d6a2f242152da00c</id>
<content type='text'>
</content>
</entry>
</feed>
