Skip to content
This repository was archived by the owner on Oct 7, 2024. It is now read-only.
This repository was archived by the owner on Oct 7, 2024. It is now read-only.

OSError: [Errno 5] Input/output error Occurs when calling i2c bus occasionally #1

@Joseph0M

Description

@Joseph0M

Error:

Traceback (most recent call last):
  File "/home/diyson/.local/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py", line 435, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/home/diyson/.local/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
  File "/home/diyson/.local/lib/python3.9/site-packages/fastapi/applications.py", line 276, in __call__
    await super().__call__(scope, receive, send)
  File "/home/diyson/.local/lib/python3.9/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/diyson/.local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/home/diyson/.local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/home/diyson/.local/lib/python3.9/site-packages/starlette/middleware/cors.py", line 83, in __call__
    await self.app(scope, receive, send)
  File "/home/diyson/.local/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/home/diyson/.local/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/home/diyson/.local/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/home/diyson/.local/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/home/diyson/.local/lib/python3.9/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/home/diyson/.local/lib/python3.9/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/home/diyson/.local/lib/python3.9/site-packages/starlette/routing.py", line 66, in app
    response = await func(request)
  File "/home/diyson/.local/lib/python3.9/site-packages/fastapi/routing.py", line 237, in app
    raw_response = await run_endpoint_function(
  File "/home/diyson/.local/lib/python3.9/site-packages/fastapi/routing.py", line 163, in run_endpoint_function
    return await dependant.call(**values)
  File "/home/diyson/PiZero/API/src/endpoints/v1/lamp.py", line 98, in get_distance
    distance = Sensor().get_distance_from_object(range = range,timing = timing)
  File "/home/diyson/PiZero/DIYson_lib/Hardware.py", line 37, in get_distance_from_object
    payload = self.pi2pi.get_payload('get_distance_from_object',[range,timing])
  File "/home/diyson/PiZero/DIYson_lib/i2c.py", line 51, in get_payload
    self.write(data)
  File "/home/diyson/PiZero/DIYson_lib/i2c.py", line 39, in write
    self.bus.write_byte(self.addr, i)
  File "/home/diyson/.local/lib/python3.9/site-packages/smbus2/smbus2.py", line 414, in write_byte
    ioctl(self.fd, I2C_SMBUS, msg)
OSError: [Errno 5] Input/output error

Cause: Unknown
Repeatability: Request data from i2c bus. Happens around 10% of all calls
Device: Master (RPi Zero W 2)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions