-
Notifications
You must be signed in to change notification settings - Fork 236
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
Java Port #55
Java Port #55
Conversation
@bschumacher @qdot @daeken @openyou Could one of you please provide me with an example array of raw input data and the corresponding unencrypted? I'd like to use it for a unit test of the Java decryption. (Also, I'll need the serial number) If you could also give me the final data structure too, that would be great because it means I could also use it in unit tests of the frame objects. |
I have AES decryption running, but I'm not sure if it's working - the decrypted bytes 29/30 (gyro) seem to be coming out randomly. Without a test input/output I'm a bit buggered. |
Just check the first byte which counts from 0 to 127 consecutively and then |
@ozancaglayan I'll do that. BTW, what the C code is doing (to extract keys) and what is written here https://github.com/openyou/emokit/blob/master/doc/emotiv_protocol.asciidoc don't agree – at all! |
I'd rather not bring a java port not maintained by me into the main repo. I recommend making your own repo, or else if you want it hosted under openyou to centralize things, I'd be happy to make a repo there and add you as a commiter. I'm probably going to split the C and python at some point too (the python was only Proof of Concept until recently, and I prefer reference implementations in C). I really prefer one repo per language (see reasoning about this at signal11/hidapi#87), with the library as a submodule, and I can put a link in the README. This is much easier to maintain for all parties, and makes sure that API upgrades don't break language bindings. |
@qdot whatever you think is easiest. I'll do all that admin stuff once I've written it. Let's leave this pull request open though as it serves as an adhoc QA. |
@ozancaglayan hmm, I'm not getting the right first byte, whether I use the "research" or "consumer" key from my code. I'll need to do some debugging. |
ok, now I can't even build the C code – think I was using qdot's branch when I last built it.
@qdot's branch works though. Not sure what's different between them. |
W00T!!!! Got decryption working. The docs are totally up the left – the C code is the best reference. I think this deserves a short break to have a wee dram of a single malt... |
@bschumacher you recommended doing the decryption in a separate thread. In Java the reading takes about 8 milliseconds and it sometimes takes as much as 1 millisecond to do the decryption. I think it makes sense to do the decryption in the same thread as the USB reading as this thread is suffering from a lot of blockage otherwise. |
@bschumacher just did a nanosecond analysis: reading takes 7.5 milliseconds, decryption takes 0.058 milliseconds. |
Depends on platform I guess, I'm using this on a Raspberry Pi. It doesn't decrypt the packets fast enough to keep up with the flow(in Python). Although I haven't tested Java performance vs Python on the Pi. From: Sam Halliday [mailto:notifications@github.com] @bschumacherhttps://github.com/bschumacher you recommended doing the decryption in a separate thread. In Java the reading takes about 8 milliseconds and it sometimes takes as much as 1 millisecond to do the decryption. I think it makes sense to do the decryption in the same thread as the USB reading as this thread is suffering from a lot of blockage otherwise. — |
@bschumacher I'm actually hoping to run this on a blackberry pi too – I'll leave the timing debugging in here so that maybe you can run it and give me the numbers :-P |
@bschumacher yes, what I'll do is put in an |
I'll pull your code down and see how it does. From: Sam Halliday [mailto:notifications@github.com] @bschumacherhttps://github.com/bschumacher I'm actually hoping to run this on a blackberry pi too – I'll leave the timing debugging in here so that maybe you can run it and give me the numbers :-P — |
@bschumacher try commit #0fd66fc as it has special debugging in it just for you. |
@bschumacher one of the Java dependencies uses JNI which targets 32/64 bit linux/osx/windows. Is that going to be a problem for the raspberry? |
We shall see. From: Sam Halliday [mailto:notifications@github.com] @bschumacherhttps://github.com/bschumacher one of the Java dependencies uses JNI which targets 32/64 bit linux/osx/windows. Is that going to be a problem for the raspberry? — |
@bschumacher I don't think it will work actually – give it a try but I think we might have to use the ARM binary from https://github.com/mirkojahn/net.mjahn.hid.driver (or similar). |
OK, I'm happy with the state of this now. Tomorrow I'll look into creating a little GUI for obtaining data (and showing a graphic with the quality of connections) in a format that is easily parsed into R. |
I've almost got this running on the Pi I believe. From: Sam Halliday [mailto:notifications@github.com] OK, I'm happy with the state of this now. Tomorrow I'll look into creating a little GUI for obtaining data (and showing a graphic with the quality of connections) in a format that is easily parsed into R. — |
@bschumacher that quite amazes me because the USB backend doesn't have an ARM binary. There is one floating around, but I'm not sure if it it works. |
Let me rephrase that, I got the maven to build successful. From: Sam Halliday [mailto:notifications@github.com] @bschumacherhttps://github.com/bschumacher that quite amazes me because the USB backend doesn't have an ARM binary. There is one floating around, but I'm not sure if it it works. — |
@bschumacher My money is on an UnsatisfiedLinkException :-D How much Java do you know? If you want you could try the ARM binary listed above, comment out the following line from ClassPathLibraryLoader.loadNativeHIDLibrary(); and load the ARM binary manually. |
@bschumacher @qdot @daeken @openyou does anyone have a graphic with the names of the sensors and their location on the device? I want to create a user friendly GUI that points out which probes are not sitting correctly. |
@bschumacher lol - that'll do. :-D |
Yeah I'll make it work, unfortunately my girlfriend wants me to be social tonight and I have to leave in a bit. From: Sam Halliday [mailto:notifications@github.com] @bschumacherhttps://github.com/bschumacher My money is on an UnsatisfiedLinkException :-D How much Java do you know? If you want you could try the ARM binary listed above, comment out the following line from EmotiveHid
and load the ARM binary manually. — |
Yeah I was never very good at writing. I'm left handed so everything comes out like crap. From: Sam Halliday [mailto:notifications@github.com] @bschumacherhttps://github.com/bschumacher lol - that'll do. :-D — |
@bschumacher the test subjects are controlling the mind readers?? This will never do! Have fun! :-D I'm GMT so I'm already well past my bedtime. |
@bschumacher four of these sensors still have question marks on them – have you worked them out yet? |
Yeah they do not return a value, unless it is related to the last bit that is still unknown, like a meditation value or something. I know that if they do not have good quality the other sensors will not report quality. The emotiv docs say there are only 14 sensors on the headset also. I'm supposed to be able to run this jar file right? I've tried all sorts of different combinations for the main class. java -cp emokit-1.0-SNAPSHOT.jar Emotiv |
if you grab the latest you should be able to just run
the main method is |
I've fixed the typo now: everything should be "Emotiv". |
@bschumacher apologies, the jar didn't have the main class or dependencies – I forget Maven didn't do this automatically. now a
will create a jar in
You might find the following logging setup to be a bit prettier
|
Following @qdot's recommendation, I'm going to close this Pull Request and set it up as a separate project here https://github.com/fommil/emokit-java @qdot, please feel free to fork to @openyou and I'll close the wiki / issue tracker on my repo with a note in the README to point to the "communal central". |
(let's leave this pull request open until it's fully implemented)
Access in Java (and Scala) to Emotive EEG devices.