Skip to content

OSError: [Errno 121] Remote I/O error on second run #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andrasfuchs opened this issue Mar 27, 2019 · 14 comments
Closed

OSError: [Errno 121] Remote I/O error on second run #8

andrasfuchs opened this issue Mar 27, 2019 · 14 comments

Comments

@andrasfuchs
Copy link

When I run the adafruit_mlx90393_simpletest.py script for the first time, it runs correctly.

image
[note: I made some formatting changes, but I didn't touch the sensor communication instructions]

But when I run the exact same script again, I get "OSError: [Errno 121] Remote I/O error":
image

I tried to disable and re-enable the I2C bus on my Raspberry Pi 3 Model B, but the only thing that fixed it was restarting the Pi, so I need to restart it every single time I want to test the sensor.

@caternuson
Copy link
Contributor

How are you stopping the first run of the program? ?

After stopping the first run, try power cycling the MLX before the second run. You can just pull the VIN wire out for a bit and put it back in.

@ladyada
Copy link
Member

ladyada commented Mar 27, 2019

MLX has a terrible i2c interface, the chip may require a power cycle if you stop it mid-conversion?

@andrasfuchs
Copy link
Author

I tried the power cycle, but it didn't fix the problem.

I also made the infinite loop finite with a counter, so that I don't need to manually terminate the script with Ctrl+C, but the results were the same as before.

Then I commented some lines of the script to check if the bus initialization or the value reading causes the problem.

The only thing that fixed it when I commented the MX, MY, MZ = SENSOR.magnetic line.

@ladyada
Copy link
Member

ladyada commented Mar 28, 2019

well, thats the line that reads the sensor ;) is there any other MLX library that works? we could see if they do something different
i wonder if we call reset() earlier if that will help https://github.com/adafruit/Adafruit_CircuitPython_MLX90393/blob/master/adafruit_mlx90393.py#L141

andra, can you try downloading the 'raw' python file and uninstalling from pip so you can make adjustments to the library to try different things?

@andrasfuchs
Copy link
Author

@ladyada Sure, I'd be glad to help in any way. Could you tell me how should I do that? That's my first python project to be honest :) I think I know how to uninstall the library with pip, but could you assist me with the "raw python file" usage?

I also have an Adafruit ADS1115 and a ATSAMD09 seesaw, I'm not sure if they can assist the testing in any way.

@ladyada
Copy link
Member

ladyada commented Mar 28, 2019

@kattni @caternuson do either of you have an MLX sensor you can also try with?

@caternuson
Copy link
Contributor

@ladyada Sorry, I do not :(

@kattni
Copy link
Contributor

kattni commented Mar 29, 2019

@ladyada It looks like I do have one. I need to get it assembled, and then try it on Pi.

@haikunguyen
Copy link

haikunguyen commented Apr 8, 2019

@ladyada I found this piece of code online for a different MLX90393 (it works for Adafruit's MLX90393 too). It runs every time without fail even after a ctrl+C interrupt. I noticed that if I run this code first, then run your guys' simpletest code, it would run fine. However, it does not convert the numbers into microteslas.

Other code:
image

@caternuson
Copy link
Contributor

This sensor appears to want repeated starts.
image
which requires special attention on Linux SBC's:
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice/blob/master/adafruit_bus_device/i2c_device.py#L147
The above is limited to a single byte for the write:
https://github.com/adafruit/Adafruit_Blinka/blob/master/src/adafruit_blinka/microcontroller/generic_linux/i2c.py#L62
There are two commands that send out more than one byte on the write:
image

The sensor appears to be somewhat forgiving about the repeated starts since it was working for the most part without them in the current driver. But by aborting the read loop and starting over the sensor was in a bad state and wouldn't play nice. A power cycle does fix this, but you have to pull all the wires - it stays back powered through the logic pins.

Not sure why same thing does not happen on a native CP board (M4, etc).

Anywho, checkout PR #10 for a possible fix.

@siddacious
Copy link
Contributor

excellent find and analysis @caternuson!

ladyada added a commit that referenced this issue Jun 18, 2019
Update transceive for repeated start for #8
@ladyada
Copy link
Member

ladyada commented Jun 18, 2019

merged!

@caternuson
Copy link
Contributor

@andrasfuchs Please try the 1.3.0 release when it becomes available:
https://github.com/adafruit/Adafruit_CircuitPython_MLX90393/releases/tag/1.3.0

@andrasfuchs
Copy link
Author

Thank you guys for your efforts! I can confirm that it works perfectly now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants