Skip to content
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

TimeoutError: Not connected to Midas-M #38

Open
dlee-bd opened this issue Jun 16, 2023 · 7 comments
Open

TimeoutError: Not connected to Midas-M #38

dlee-bd opened this issue Jun 16, 2023 · 7 comments

Comments

@dlee-bd
Copy link

dlee-bd commented Jun 16, 2023

Hello - thank you for this resource.

I am working with Midas-M sensor (link to manual), which is a newer version by the looks, but very much the same skeleton.

I was able to get the sensor hooked up to my PC with the PoE.

I can hit the sensor's default IP (169.254.60.47) from my PC's browser, as shown below.
image

Since I want to receive data using your drive, I set up a virtual environment with python 3.10 and successfully pip installed the midas package within.

However, when I run midas 169.254.60.47, I get a response below:

(midas) dlee@laptop-dlee01:~/myprojects/midas$ midas 169.254.60.47
Traceback (most recent call last):
  File "/usr/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/BOSDYN/dlee/venv/midas/lib/python3.10/site-packages/midas/util.py", line 134, in _request
    return await future(*args, **kwargs)
  File "/home/BOSDYN/dlee/venv/midas/lib/python3.10/site-packages/pymodbus/client/base.py", line 198, in async_execute
    resp = await asyncio.wait_for(req, timeout=self.params.timeout)
  File "/usr/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/BOSDYN/dlee/venv/midas/bin/midas", line 8, in <module>
    sys.exit(command_line())
  File "/home/BOSDYN/dlee/venv/midas/lib/python3.10/site-packages/midas/__init__.py", line 29, in command_line
    loop.run_until_complete(get())
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/BOSDYN/dlee/venv/midas/lib/python3.10/site-packages/midas/__init__.py", line 26, in get
    print(json.dumps(await detector.get(), indent=4, sort_keys=True))
  File "/home/BOSDYN/dlee/venv/midas/lib/python3.10/site-packages/midas/driver.py", line 67, in get
    return self._parse(await self.read_registers(0, 16))
  File "/home/BOSDYN/dlee/venv/midas/lib/python3.10/site-packages/midas/util.py", line 75, in read_registers
    r = await self._request('read_holding_registers', address, count)
  File "/home/BOSDYN/dlee/venv/midas/lib/python3.10/site-packages/midas/util.py", line 136, in _request
    raise TimeoutError("Not connected to Midas.") from e
TimeoutError: Not connected to Midas.

I can ping the address, as well as hit the sensor's website on my browser, so it doesn't look like a connectivity issue. Can you provide insight?

Much thanks.

@alexrudd2
Copy link
Member

Hmm, I did not know a Midas-M sensor existed. Interesting!

  1. Can you try 0.6.1?
  2. Is there a possibility Modbus TCP/IP functionality is turned off?

@dlee-bd
Copy link
Author

dlee-bd commented Jun 16, 2023

Hello, thanks for the response.

  • What do you mean by trying 0.6.1?
  • Is the Modbus TCP/IP functionality something that must be turned on within the sensor configuration?

@alexrudd2
Copy link
Member

  • What do you mean by trying 0.6.1?

pip install midas==0.6.1 to install an earlier version of this driver (with slightly different networking code). I have experienced a different, but perhaps related, connectivity bug with the latest version.

  • Is the Modbus TCP/IP functionality something that must be turned on within the sensor configuration?

I do not know, since I've never worked with a Midas-M. It was a guess.

@alexrudd2 alexrudd2 changed the title TimeoutError: Not connected to Midas TimeoutError: Not connected to Midas-M Jul 27, 2023
@dlee-bd
Copy link
Author

dlee-bd commented Oct 4, 2023

Tried it with version 0.6.1 but still no luck

Traceback (most recent call last):
  File "/home/BOSDYN/dlee/.local/lib/python3.10/site-packages/pymodbus/client/tcp.py", line 69, in connect
    return await self._connect()
  File "/home/BOSDYN/dlee/.local/lib/python3.10/site-packages/pymodbus/client/tcp.py", line 101, in _connect
    transport, protocol = await asyncio.wait_for(
  File "/usr/lib/python3.10/asyncio/tasks.py", line 432, in wait_for
    await waiter
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/BOSDYN/dlee/.local/lib/python3.10/site-packages/midas/util.py", line 52, in _connect
    await asyncio.wait_for(self.client.connect(), timeout=self.timeout)  # 3.x
  File "/usr/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/BOSDYN/dlee/.local/bin/midas", line 8, in <module>
    sys.exit(command_line())
  File "/home/BOSDYN/dlee/.local/lib/python3.10/site-packages/midas/__init__.py", line 29, in command_line
    loop.run_until_complete(get())
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/BOSDYN/dlee/.local/lib/python3.10/site-packages/midas/__init__.py", line 26, in get
    print(json.dumps(await detector.get(), indent=4, sort_keys=True))
  File "/home/BOSDYN/dlee/.local/lib/python3.10/site-packages/midas/driver.py", line 67, in get
    return self._parse(await self.read_registers(0, 16))
  File "/home/BOSDYN/dlee/.local/lib/python3.10/site-packages/midas/util.py", line 70, in read_registers
    r = await self._request('read_holding_registers', address, count)
  File "/home/BOSDYN/dlee/.local/lib/python3.10/site-packages/midas/util.py", line 122, in _request
    await self.connectTask
  File "/home/BOSDYN/dlee/.local/lib/python3.10/site-packages/midas/util.py", line 56, in _connect
    raise OSError(f"Could not connect to '{self.ip}'.") from e
OSError: Could not connect to '192.254.60.43'.


@alexrudd2
Copy link
Member

I'm sorry I can only speculate, since I've never encountered a Midas-M.

If two different versions of the netcode don't work, I suspect the network or device.

Is it possible your device doesn't support Modbus TCP/IP? It looks to me like that's an option at purchase time, but I can't tell from the screenshot of the web interface you provided. What's in the Setup menu?
Screenshot 2023-10-04 at 11 07 10 AM

Is it possible you have port 502 blocked in your firewall?

For instance, here's checking the open ports on a "regular" (non-M) Midas with nmap:

❯ sudo nmap 192.168.10.215 -p1-520
Starting Nmap 7.94 ( https://nmap.org ) at 2023-10-04 11:10 CDT
Nmap scan report for 192.168.10.215
Host is up (0.077s latency).
Not shown: 517 closed tcp ports (reset)
PORT    STATE SERVICE
21/tcp  open  ftp
80/tcp  open  http
502/tcp open  mbap.         <=== MODBUS TCP/IP PORT OPEN

Nmap done: 1 IP address (1 host up) scanned in 0.82 seconds

@dlee-bd
Copy link
Author

dlee-bd commented Oct 11, 2023

Hello Alex, thanks for the response. After port setting change, the nmap output shows below:

The device does support TCP/IP. Its IP address shows 169.254.60.47 upon hookup.

My nmap output shows below:

dlee@laptop-dlee01:~/Documents/Code/midas$ sudo nmap 169.254.60.47 -p1-520
Starting Nmap 7.80 ( https://nmap.org ) at 2023-10-11 12:04 EDT
Nmap scan report for 169.254.60.47
Host is up (0.00074s latency).
Not shown: 518 closed ports
PORT    STATE SERVICE
80/tcp  open  http
502/tcp open  mbap
MAC Address: 00:12:45:20:04:53 (Zellweger Analytics)

Nmap done: 1 IP address (1 host up) scanned in 3.61 seconds

However, running midas 169.254.60.47 shows:

dlee@laptop-dlee01:~/Documents/Code/midas/midas$ midas 169.254.60.47
Traceback (most recent call last):
  File "/home/BOSDYN/dlee/.local/bin/midas", line 8, in <module>
    sys.exit(command_line())
  File "/home/BOSDYN/dlee/.local/lib/python3.10/site-packages/midas/__init__.py", line 29, in command_line
    loop.run_until_complete(get())
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/BOSDYN/dlee/.local/lib/python3.10/site-packages/midas/__init__.py", line 26, in get
    print(json.dumps(await detector.get(), indent=4, sort_keys=True))
  File "/home/BOSDYN/dlee/.local/lib/python3.10/site-packages/midas/driver.py", line 67, in get
    return self._parse(await self.read_registers(0, 16))
  File "/home/BOSDYN/dlee/.local/lib/python3.10/site-packages/midas/util.py", line 76, in read_registers
    r = await self._request('read_holding_registers', address, count)
  File "/home/BOSDYN/dlee/.local/lib/python3.10/site-packages/midas/util.py", line 135, in _request
    return await future(*args, **kwargs)
  File "/home/BOSDYN/dlee/.local/lib/python3.10/site-packages/pymodbus/client/base.py", line 207, in async_execute
    raise ModbusIOException(
pymodbus.exceptions.ModbusIOException: Modbus Error: [Input/Output] ERROR: No response received after 3 retries


FYI, the same error occurs with both midas 0.6.1 and 0.6.5. My pymodbus version is 3.2.2.

@alexrudd2
Copy link
Member

OK, so that's progress. The software is connecting successfully on port 502 now, which was failing before.

The relevant error is here:
Modbus Error: [Input/Output] ERROR: No response received after 3 retries

It suggests the Midas-M is not replying with the Modbus protocol for whatever reason. I don't know what this could be. At this point I'd recommend
(1) downloading a Modbus scanner (I use QModMaster) and experimenting with the settings
(2) exploring the settings of the web interface to see if, for instance, Modbus is disabled somehow
(3) contacting Honeywell support.

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

2 participants