Closed kungpfui closed 5 years ago
Hi Karl-Petter,
Regarding i2c_read and i2c_write: I trust in comments ... most of the time. When there is no 32 bytes limit in .i2c_rdwr() there is, also in my opinion, no rational reason for additional read/write functions.
Regarding the perfomance: I made a comparision with a 32kbit EEPROM which I had by hand. There is a measureable difference but it's negliable. My old Raspi 1 needed with i2c_rdwr ~400ms to readout and return the whole EEPROM. Write/Read were slightly quicker (~370ms). So no big deal and the measured times are reasonable as well. I2C is running at 100kbit/s.
Keep up the great work, Stefan
Hi Karl-Petter
I've extended your smbus2 class by some functionality which was, in my opinion, missing. It would be nice to see them all or partly in your base repository.
What I've done:
As request by request #17 - Support names buses. SMBus.init(), SMBus.open():
bus
can be a file path as well. Rationale: file system links to /dev/i2c-x can't be used at momentclass i2c_msg_iter replaced by a simple generator function Rationale: a generator function does the job as well. I use index/while because this is in python 2 more performant than for/range where range can create huge tuple objects.
Added enter/exit handler to
SMBus
class. Rationale: get rid of the additional wrapper class. In the past, Python library classes were extended by enter/exit handler as well.Added i2c_write and i2c_read, some very basic and most simple read/write function. Rationale: The are not Smbus related but they work with the Raspberry Pi. They allow to read or write a continuous data stream and are not as limited as i2c_rdwr (32 bytes). I've used them in the past to read or write some 64/128kByte EEPROMs as quickly as possible.
additional test cases. Essentially I've added some with/open/close test cases
What do you think? Good ideas or bad ideas?
Stefan