MindRove / MindRoveSDK

Apache License 2.0
5 stars 4 forks source link

Running the SDK on MacOS #6

Closed jamesonrader closed 1 year ago

jamesonrader commented 1 year ago

I am trying to run the example python files on MacOS. I've ran python -m pip install mindrove and also installed everything in examples/python/plot_real_time/requirements.txt. However, when I run python ./plot_real_time_min.py I still get the issue:

Traceback (most recent call last):
  File "/Users/Home/Projects/mindrove/./plot_real_time_min.py", line 89, in <module>
    main()
  File "/Users/Home/Projects/mindrove/./plot_real_time_min.py", line 68, in main
    BoardShim.enable_dev_board_logger()
  File "/Users/Home/Projects/mindrove/venv/lib/python3.11/site-packages/mindrove/board_shim.py", line 468, in enable_dev_board_logger
    cls.set_log_level(LogLevels.LEVEL_TRACE.value)
  File "/Users/Home/Projects/mindrove/venv/lib/python3.11/site-packages/mindrove/board_shim.py", line 451, in set_log_level
    res = BoardControllerDLL.get_instance().set_log_level_board_controller(log_level)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Home/Projects/mindrove/venv/lib/python3.11/site-packages/mindrove/board_shim.py", line 105, in get_instance
    cls.__instance = cls()
                     ^^^^^
  File "/Users/Home/Projects/mindrove/venv/lib/python3.11/site-packages/mindrove/board_shim.py", line 130, in __init__
    raise FileNotFoundError(
FileNotFoundError: Dynamic library /Users/Home/Projects/mindrove/venv/lib/python3.11/site-packages/mindrove/lib/libBoardController.dylib is missed, did you forget to compile MindRove before installation of python package?

How should I go about fixing this for MacOS?

rokaijano commented 1 year ago

Hi! I have updated the pip package, so if you update your mindrove package to 0.0.5, then it should work. Let me know if it works for you too !

jamesonrader commented 1 year ago

Finally, if I update the code to fix this issue, I run the file and get this:

python ./plot_real_time_min.py
[2023-06-17 10:21:00.243] [board_logger] [info] incoming json: {
    "file": "",
    "ip_address": "",
    "ip_port": 0,
    "ip_protocol": 0,
    "mac_address": "",
    "other_info": "",
    "serial_number": "",
    "serial_port": "",
    "timeout": 0
}
[2023-06-17 10:21:00.243] [board_logger] [trace] Board object created 0
[2023-06-17 10:21:00.243] [board_logger] [trace] start stream
[2023-06-17 10:21:00.243] [board_logger] [debug] use stub streamer
[2023-06-17 10:21:00.603] [data_logger] [error] Incorrect Data arguments. Data must not be empty and data_len must be >=1
Traceback (most recent call last):
  File "/Users/Home/Projects/mindrove/./plot_real_time_min.py", line 53, in update
    DataFilter.detrend(data[channel], DetrendOperations.CONSTANT.value)
  File "/Users/Home/Projects/mindrove/venv/lib/python3.11/site-packages/mindrove/data_filter.py", line 840, in detrend
    raise MindRoveError('unable to detrend data', res)
mindrove.board_shim.MindRoveError: INVALID_ARGUMENTS_ERROR:13 unable to detrend data
[2023-06-17 10:21:00.643] [data_logger] [error] Incorrect Data arguments. Data must not be empty and data_len must be >=1
Traceback (most recent call last):
  File "/Users/Home/Projects/mindrove/./plot_real_time_min.py", line 53, in update
    DataFilter.detrend(data[channel], DetrendOperations.CONSTANT.value)
  File "/Users/Home/Projects/mindrove/venv/lib/python3.11/site-packages/mindrove/data_filter.py", line 840, in detrend
    raise MindRoveError('unable to detrend data', res)
mindrove.board_shim.MindRoveError: INVALID_ARGUMENTS_ERROR:13 unable to detrend data
[2023-06-17 10:21:00.692] [data_logger] [error] Incorrect Data arguments. Data must not be empty and data_len must be >=1
Traceback (most recent call last):
  File "/Users/Home/Projects/mindrove/./plot_real_time_min.py", line 53, in update
    DataFilter.detrend(data[channel], DetrendOperations.CONSTANT.value)
  File "/Users/Home/Projects/mindrove/venv/lib/python3.11/site-packages/mindrove/data_filter.py", line 840, in detrend
    raise MindRoveError('unable to detrend data', res)
mindrove.board_shim.MindRoveError: INVALID_ARGUMENTS_ERROR:13 unable to detrend data
[2023-06-17 10:21:00.743] [data_logger] [error] Incorrect Data arguments. Data must not be empty and data_len must be >=1
Traceback (most recent call last):
  File "/Users/Home/Projects/mindrove/./plot_real_time_min.py", line 53, in update
    DataFilter.detrend(data[channel], DetrendOperations.CONSTANT.value)
  File "/Users/Home/Projects/mindrove/venv/lib/python3.11/site-packages/mindrove/data_filter.py", line 840, in detrend
    raise MindRoveError('unable to detrend data', res)
mindrove.board_shim.MindRoveError: INVALID_ARGUMENTS_ERROR:13 unable to detrend data
[2023-06-17 10:21:00.793] [data_logger] [error] Incorrect Data arguments. Data must not be empty and data_len must be >=1
Traceback (most recent call last):
  File "/Users/Home/Projects/mindrove/./plot_real_time_min.py", line 53, in update
    DataFilter.detrend(data[channel], DetrendOperations.CONSTANT.value)
  File "/Users/Home/Projects/mindrove/venv/lib/python3.11/site-packages/mindrove/data_filter.py", line 840, in detrend
    raise MindRoveError('unable to detrend data', res)
mindrove.board_shim.MindRoveError: INVALID_ARGUMENTS_ERROR:13 unable to detrend data
[2023-06-17 10:21:00.843] [data_logger] [error] Incorrect Data arguments. Data must not be empty and data_len must be >=1
Traceback (most recent call last):

It just keeps doing this forever and Control + C doesn't even stop the file from running. There seems to be no way of interrupting this error once I run the file.

In my code, all I changed was self.app.exec_() to self.app.exec()

jamesonrader commented 1 year ago

For the keyboard interrupt, while Control + c doesn't work, I can still kill it using Control + z.

I am playing around with it to try and resolve these errors, but bumping into the issue above and also this one:

[2023-06-19 11:56:29.156] [board_logger] [info] incoming json: {
    "file": "",
    "ip_address": "",
    "ip_port": 0,
    "ip_protocol": 0,
    "mac_address": "",
    "other_info": "",
    "serial_number": "",
    "serial_port": "",
    "timeout": 0
}
[2023-06-19 11:56:29.156] [board_logger] [trace] Board object created 0
[2023-06-19 11:56:29.156] [board_logger] [error] failed to bind socket: 3
WARNING:root:Exception
Traceback (most recent call last):
  File "/Users/Home/Projects/mindrove/attempt/plot_real_time/plot_real_time.py", line 128, in main
    board_shim.prepare_session()
  File "/Users/Home/Projects/mindrove/venv/lib/python3.11/site-packages/mindrove/board_shim.py", line 930, in prepare_session
    raise MindRoveError('unable to prepare streaming session', res)
mindrove.board_shim.MindRoveError: GENERAL_ERROR:17 unable to prepare streaming session
jamesonrader commented 1 year ago

After some troubleshooting, I believe these issues are from my macbook not recognizing the EDUP wireless adapter. Of course, I can't use USB and have to use USB-c. That said, I have a converter that has never failed me. I am very confused why my macbook would not be able to recognize the USB device.

Do you have any recommendations?

I am going to buy another USB to USB-c converter on amazon and try with that when it arrives, as that may be the issue.

MindRove commented 1 year ago

Hi.

Sorry for the late response. It's good to see that the problem is now better identified, thanks.

Could you try to connect the MindRove device with the built-in WiFi adapter of your MacBook? Later we could try to troubleshoot the USB WiFi dongle.

jamesonrader commented 1 year ago

@MindRove do you mean without using the EDUP Wireless Adapter that came with my mindrove order? If so, do you have instructions on how to do that?

For example, when I turn the armband on, I see within my wifi networks Mindrove_ARB_d0b444 but it requests a password for me to connect, which I do not have. On top of that, if I connect to this as a network, am I not able to use wifi on my macbook?

MindRove commented 1 year ago

Yes, without the Wireless Adapter. The MindRove device after you switch it on, creates a WiFi network and you can connect to it with the password #mindrove (like it was a WiFi router). While doing this, you will have no internet unfortunately (that's why we send the adapter - so that you can use the device and connect to the internet at the same time). But if you manage to make the device work like this, we can find another USB dongle for an internet connection.

jamesonrader commented 1 year ago

OK got it. I tried that and connected. Unfortunately I still bump into these errors as I run each of the three sample python files.

boardconfig.py:

> /Users/Home/Projects/mindrove/venv/bin/python /Users/Home/Projects/mindrove/attempt/boardconfig/boardconfig.py
[2023-06-20 09:15:50.061] [board_logger] [info] incoming json: {
    "file": "",
    "ip_address": "",
    "ip_port": 0,
    "ip_protocol": 0,
    "mac_address": "",
    "other_info": "",
    "serial_number": "",
    "serial_port": "",
    "timeout": 0
}
[2023-06-20 09:15:50.061] [board_logger] [trace] Board object created 0
[2023-06-20 09:15:50.061] [board_logger] [error] failed to bind socket: 3
<class 'mindrove.board_shim.MindRoveError'>
Traceback (most recent call last):
  File "/Users/Home/Projects/mindrove/attempt/boardconfig/boardconfig.py", line 34, in <module>
    board_shim.config_board(mindrove.MindroveConfigMode.EEG_MODE)
  File "/Users/Home/Projects/mindrove/venv/lib/python3.11/site-packages/mindrove/board_shim.py", line 1076, in config_board
    res = BoardControllerDLL.get_instance().config_board(config_string, string, string_len, self.board_id,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ctypes.ArgumentError: argument 1: TypeError: wrong type

plot_real_time_min.py:

> /Users/Home/Projects/mindrove/venv/bin/python /Users/Home/Projects/mindrove/attempt/plot_real_time/plot_real_time_min.py
[2023-06-20 09:16:11.775] [board_logger] [info] incoming json: {
    "file": "",
    "ip_address": "",
    "ip_port": 0,
    "ip_protocol": 0,
    "mac_address": "",
    "other_info": "",
    "serial_number": "",
    "serial_port": "",
    "timeout": 0
}
[2023-06-20 09:16:11.775] [board_logger] [trace] Board object created 0
[2023-06-20 09:16:11.775] [board_logger] [error] failed to bind socket: 3
WARNING:root:Exception
Traceback (most recent call last):
  File "/Users/Home/Projects/mindrove/attempt/plot_real_time/plot_real_time_min.py", line 76, in main
    board_shim.prepare_session()
  File "/Users/Home/Projects/mindrove/venv/lib/python3.11/site-packages/mindrove/board_shim.py", line 930, in prepare_session
    raise MindRoveError('unable to prepare streaming session', res)
mindrove.board_shim.MindRoveError: GENERAL_ERROR:17 unable to prepare streaming session
INFO:root:End

plot_real_time.py:

> /Users/Home/Projects/mindrove/venv/bin/python /Users/Home/Projects/mindrove/attempt/plot_real_time/plot_real_time.py
[2023-06-20 09:17:06.298] [board_logger] [info] incoming json: {
    "file": "",
    "ip_address": "",
    "ip_port": 0,
    "ip_protocol": 0,
    "mac_address": "",
    "other_info": "",
    "serial_number": "",
    "serial_port": "",
    "timeout": 0
}
[2023-06-20 09:17:06.298] [board_logger] [trace] Board object created 0
[2023-06-20 09:17:06.298] [board_logger] [error] failed to bind socket: 3
WARNING:root:Exception
Traceback (most recent call last):
  File "/Users/Home/Projects/mindrove/attempt/plot_real_time/plot_real_time.py", line 128, in main
    board_shim.prepare_session()
  File "/Users/Home/Projects/mindrove/venv/lib/python3.11/site-packages/mindrove/board_shim.py", line 930, in prepare_session
    raise MindRoveError('unable to prepare streaming session', res)
mindrove.board_shim.MindRoveError: GENERAL_ERROR:17 unable to prepare streaming session

I will attempt to debug more on my own of course, but wanted to share this quickly.

rokaijano commented 1 year ago

Hi!

Usually the failed to bind socket error is due to firewall problems. Can you try it without having firewall enabled? If it works like that, then it means you will need to put the python on the firewall exception list.

jamesonrader commented 1 year ago

I cannot even hit a breakpoint on the first line of my main() function because the second the code gets into import mindrove, it never comes out.

I also don't see any description of what the various LED lights mean (green, red, blue).

Finally, I don't think the issue would be a firewall as I have those disabled completely.

Running ifconfig in the command line, there is no difference whether or not the USB wireless adapter is plugged in.

If I check my mac for connected devices following Apples documentation, I am not seeing this Wireless Adapter / EMG wristband.

That said, this can't be the only issue because if I connect directly to the wifi network, I get those errors I shared in my previous comment (even though I have all firewalls disabled).

MindRove commented 1 year ago

We will contact you by email shortly to schedule an online meeting in which we could look at the connection issue if that's ok. The user manual of the Visaulizer on Desktop contains info about the meaning of the LEDs.