Search found 3821 matches

by dhylands
Wed Oct 15, 2014 8:47 pm
Forum: Hardware Projects
Topic: Module for MPU9150
Replies: 54
Views: 54294

Re: Module for MPU9150

You can now get a 4-channel Logic Pro for $100: https://www.saleae.com/?gclid=Cj0KEQjwtvihBRCd8fyrtfHRlJEBEiQAQcubtBXiWgjErLDTtHJOq6vIrvLyQNGrfg2q_Mi-aOCLVqAaAmZ58P8HAQ#PricingTile Or if you don't mind a clone, you can get a clone of one of the older 8-channel Logic's on eBay. Just search for "8 cha...
by dhylands
Wed Oct 15, 2014 6:47 pm
Forum: Hardware Projects
Topic: Module for MPU9150
Replies: 54
Views: 54294

Re: Module for MPU9150

What not just create a common module which both of your modules import. And have the common module ensure that the initialization only occurs once?
by dhylands
Wed Oct 15, 2014 3:21 pm
Forum: General Discussion and Questions
Topic: OSError: [Errno 5]
Replies: 28
Views: 28075

Re: OSError: [Errno 5]

Oh, interesting. I thought gc.collect() performs some defragmentation. If not, what would you recommend in this case? The gc can't move objects, since it would need to know where all of the references to the object are and update them. All it can do is free up objects which have no references. The ...
by dhylands
Wed Oct 15, 2014 2:52 pm
Forum: General Discussion and Questions
Topic: OSError: [Errno 5]
Replies: 28
Views: 28075

Re: OSError: [Errno 5]

I tried to preallocate a buffer and use readinto, but readinto doesn't seem to be supported, so I'm going to open an issue in github.
by dhylands
Wed Oct 15, 2014 2:39 pm
Forum: General Discussion and Questions
Topic: OSError: [Errno 5]
Replies: 28
Views: 28075

Re: OSError: [Errno 5]

You could be running into heap fragmentation. Here's a contrived case that demonstrates that: import gc def read_file(): l=0 print("About to open file") aFile = open('/sd/data.bin', 'rb') print("After opening file") while True: try: a = aFile.read(2048) if a == b'': print('done') break except OSErro...
by dhylands
Wed Oct 15, 2014 7:15 am
Forum: General Discussion and Questions
Topic: OSError: [Errno 5]
Replies: 28
Views: 28075

Re: OSError: [Errno 5]

Right - I've been nailed by this as well (switching from Python2 to Python 3). >>> b'' == '' False When I changed if a == '' to a == b'' or if len(a) == 0 then it exits the loop. Files open in binary mode return binary strings (hence the b prefix) whereas files in text mode return unicode strings.
by dhylands
Wed Oct 15, 2014 5:03 am
Forum: General Discussion and Questions
Topic: OSError: [Errno 5]
Replies: 28
Views: 28075

Re: OSError: [Errno 5]

I also tried 2048, 4096, and 8192 and they all worked fine: Read block 8192 so far 991232 next 999424 Read block 8192 so far 999424 next 1007616 Read block 5371 so far 1007616 next 1012987 About to open /sd/data.bin After opening /sd/data.bin Bytes to read 1012987 Read block 8192 so far 0 next 8192 ...
by dhylands
Wed Oct 15, 2014 4:59 am
Forum: General Discussion and Questions
Topic: OSError: [Errno 5]
Replies: 28
Views: 28075

Re: OSError: [Errno 5]

I tried a smaller file, 1012987 bytes long. import sys, pyb def Test(): print("About to open /sd/data.bin") aFile = open("/sd/data.bin",'rb') print("After opening /sd/data.bin") bytesToRead = aFile.seek(0,2) print('Bytes to read %d' % bytesToRead) bytesRead = 0 chunkCount = 0 chunkSize = 0 blockSize...
by dhylands
Wed Oct 15, 2014 4:51 am
Forum: Hardware Projects
Topic: Module for MPU9150
Replies: 54
Views: 54294

Re: Module for MPU9150

I think that probably deserves a bug report.

I filed issue: https://github.com/micropython/micropython/issues/908
by dhylands
Wed Oct 15, 2014 3:46 am
Forum: General Discussion and Questions
Topic: OSError: [Errno 5]
Replies: 28
Views: 28075

Re: OSError: [Errno 5]

I tried your original SDIO.py and changed the 'rU' passed to open to be 'rb', removed the sys.path.append("1://") line, and changed 1://data.bin to be /sd/data.bin. If you open the file using 'r' then it will assume text mode (i.e. same as 'rt'). If you pass in a binary file, then you might get erro...