Welcome! Log In Create A New Profile

Advanced

Serial port unavailable error with wireless EEG connection

Posted by kms 
kms
Serial port unavailable error with wireless EEG connection
October 25, 2019 07:19AM
Hi Jaewon,

I am trying to integrate a wireless EEG recording (Emotiv 32 channel headset) into my task code.

At the beginning of the task script, I initialize the particular serial port (the virtual pair selected using a virtual serial port driver), specify the baudrate, parity etc. and 'fopen' it. At the end of the script, I 'fclose', 'delete' and 'clear' it.

When I run the code, for some reason, after about a trial, monkey logic closes with the error that the specific port is 'unavailable'. I tried deleting and switching to a different pair of virtual ports, but while a small test script of 'for' loop (2-3 mins) ran without errors, the monkey logic code was throwing up an 'unavailable port' error almost after a single trial.

Any thoughts on what could be going wrong?

Thank you!
Re: Serial port unavailable error with wireless EEG connection
October 25, 2019 10:59AM
There is not so much that I can tell without seeing the hardware configuration and the code. Maybe the port failed to reopen because it was still in use in the next trial. Try opening it again immediately after closing at the end of the timing script.

If it doesn't have to be opened and closed every trial, you may want to initialize it in the alert_function.
https://monkeylogic.nimh.nih.gov/board/read.php?2,6,6#msg-6
kms
Re: Serial port unavailable error with wireless EEG connection
October 28, 2019 03:54PM
Initializing the port via the alert_function did help! Thank you so much, Jaewon!

The National Institute of Mental Health (NIMH) is part of the National Institutes of Health (NIH), a component of the U.S. Department of Health and Human Services.