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

Unexpected Response Error #1

Open
ColbySawyer7 opened this issue Jan 19, 2023 · 3 comments
Open

Unexpected Response Error #1

ColbySawyer7 opened this issue Jan 19, 2023 · 3 comments

Comments

@ColbySawyer7
Copy link

I have a OPC-N3 connected to Raspberry PI via USB to SPI cabling. I have three of these setups and can successfully connect to the OPC and read data 50% of the time.

Upon reboot or at random sampling windows i receive the following error:

ERROR:opcng:Error while reading bytes from the device: Received unexpected response 0x3F for command: 0x3F 

Traceback (most recent call last): 

File "test_opc.py", line 10, in  

dev = opc.detect(spi) 

File "/usr/local/lib/python3.7/dist-packages/opcng/init.py", line 680, in detect 

info = o.info() 

File "/usr/local/lib/python3.7/dist-packages/opcng/init.py", line 381, in info 

buf = self._read_bytes(_OPC_CMD_READ_INFO_STRING, 60) 

File "/usr/local/lib/python3.7/dist-packages/opcng/init.py", line 302, in _read_bytes 

logger.error('Something failed while reading byte sequence, expected size: {}, received: {}'.format(sz, len(l))) 

NameError: name 'l' is not defined

Any suggestions as to what may be causing this issue?

@fargiolas
Copy link
Owner

fargiolas commented Jan 19, 2023

Just a quick feedback, will look into this better tomorrow.
There is actually a bug there as len(l) should be len(result) but it's just a coincidence of the problem you're seeing.

If you connect the N3 to power and send no SPI command for about 65 seconds (chapter 9 of Alphasense Manual) it goes into Standalone mode and starts recording data on the on-board SD card. You can easily see it yourself as the fan powers on on its own if you connect the device and don't do anything with it for a while.

If I recall correctly when the device enters this mode it doesn't answer SPI commands as it's supposed to. The solution is to unplug the USB and plug it again and start acquiring data before it enters this automatic mode.

I have to run a few tests to see if is there a software way to reset it, stop this Standalone mode and enter the normal SPI operation mode.

I personally always used them in continous data acquisition mode so as soon as the Raspberry boots it starts a service that turns on the device and starts getting PM and histogram data and it doesn't have time to enter this mode.

Will investigate a bit more and let you know if I find anything useful.

@fargiolas
Copy link
Owner

Apparently when the device is working in this autonomous mode it still listens to SPI commands but it's probably busy most of the time so it doesn't meet the timing requirements from Alphasense SPI specs. Sometimes commands seems to work sometimes they fail.

It seems that if you manage to send an off() command it exits this mode and starts to respond properly again. But I'm just speculating, maybe it still keeps some of the state and who knows. I'd say the best is to power cycle it and use it through SPI before it enters this state.

Could be worth asking for more information to Alphasense or dig into the manuals to see if this standalone mode can be disabled.

@ColbySawyer7
Copy link
Author

Thank you for you quick feedback! I will implement your suggestions and let you know if it resolves the problems. I assumed it was getting stuck in a certain state but wasn't sure on the specifics.

@fargiolas fargiolas reopened this Jan 20, 2023
fargiolas added a commit that referenced this issue Jan 20, 2023
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