-
Notifications
You must be signed in to change notification settings - Fork 0
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
Api logging #4
Api logging #4
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks great so far! Just some questions about how things work here
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) | ||
localhost_pem = pathlib.Path(__file__).with_name("cert.pem") | ||
ssl_context.load_verify_locations(localhost_pem) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you link to where in the documentation this was mentioned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you also add where in the documentation if mentions to include cert.pem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note that Cortex only supports the WebSocket Secure (wss) protocol. It doesn't support the plain WebSocket (ws) protocol without encryption.
The Cortex web socket server uses a self-signed certificate. When you install Emotiv softwares, the installer has already installed the Emotiv Root CA file and ask the system to trust it, so most of the time, your application don't need to configure anything else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we passing in a cert.pem
file if it's saying that it doesn't need it? Do you have reference to where you got this code from? Have you tried running this code without the cert.pem
file and without the SSLContext?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think that means the launcher itself because the section after that is talking about using a raspberry pi as the wss server. it wasn't working without the cert.pem
file
async with websockets.connect("wss://localhost:6868", ssl=ssl_context) as websocket: | ||
# by default emotiv uses port 6868, uses wss protocol | ||
# first need to request access | ||
await send_message({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: but in the documentation they say to call getUserLogin
to check if the user already logged in.
https://emotiv.gitbook.io/cortex-api/authentication
First, you should call [getUserLogin](https://emotiv.gitbook.io/cortex-api/authentication/getuserlogin) to check if the user has already logged in though [EMOTIV Launcher](https://emotiv.gitbook.io/emotiv-launcher/). Then, you must call [requestAccess](https://emotiv.gitbook.io/cortex-api/authentication/requestaccess) to ask the user to approve your application.
"status": "open" | ||
} | ||
}, websocket) | ||
session_id = response["result"]["id"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does the value of session_id change? Will it be different every time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, after the script stops running the session is closed so a new session id needs to be generated on the next run
A session is linked to an application. All the sessions of an application are automatically closed when the application is disconnected from the Cortex service. A session is also closed if the headset is disconnected.
from docs
@@ -185,7 +342,7 @@ def run_experiment(trials, window, subj, session_number, n_images, all_images): | |||
|
|||
# Display break message at the end of each block | |||
display_break_message(window, trial['block']) | |||
|
|||
await teardown_eeg() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we call this twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops, that was remenants from testing, i don't think it ever reached the call on line 421 when i was testing it but hopefully that's just because i was exiting the experiment early/no actual hardware
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no worries! Just remote it pls
print(response) | ||
# wait for warning 18 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is warning 18?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's for successfully saved record
You must stop the record before you can export it. If you want to export a record immediately after you stop it then you must wait for the warning 18 before you try to export.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha. Maybe link to the documentation and copy paste this:
The record data has been successfully saved. Cortex sends this warning when a record is done with some long-run post processing after record is stopped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice. Thanks for addressing the comments. Please make the changes here and in the main repo too.
print(response) | ||
# wait for warning 18 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha. Maybe link to the documentation and copy paste this:
The record data has been successfully saved. Cortex sends this warning when a record is done with some long-run post processing after record is stopped.
@@ -185,7 +342,7 @@ def run_experiment(trials, window, subj, session_number, n_images, all_images): | |||
|
|||
# Display break message at the end of each block | |||
display_break_message(window, trial['block']) | |||
|
|||
await teardown_eeg() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no worries! Just remote it pls
Setup steps
other files etc