-
Notifications
You must be signed in to change notification settings - Fork 39
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 API for EV3Dev #114
Comments
You should look into autogen system first. It has ev3dev specification in spec.json, and it can generate code from the specification with liquid template files. You can look at the templates for python here: https://github.com/rhempel/ev3dev-lang-python/tree/master/templates. If you make the system work, then (almost) the only thing you need to implement is base I think its completely OK to reuse Device implementation from either of the existing bindings. |
Many thanks @ddemidov I will try to generate the infrastructure to run a basic example from Java and later, I start developing the whole support. I think that working with the same technology, low-level problems could be solved in team. Cheers Juan Antonio |
Hi @ddemidov, @dlech, @rhempel I have just tried to install dependencies with node, but I get the following error: ➜ autogen npm install
npm WARN package.json ev3dev-lang-autogen@1.0.0 No repository field.
npm WARN package.json ev3dev-lang-autogen@1.0.0 No license field.
npm ERR! git clone --template=/Users/jabrena/.npm/_git-remotes/_templates --mirror git://github.com/WasabiFan/liquid-node.git /Users/jabrena/.npm/_git-remotes/git-github-com-WasabiFan-liquid-node-git-344bec5b: xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.0.0
npm ERR! npm v2.11.2
npm ERR! code 1
npm ERR! Command failed: git clone --template=/Users/jabrena/.npm/_git-remotes/_templates --mirror git://github.com/WasabiFan/liquid-node.git /Users/jabrena/.npm/_git-remotes/git-github-com-WasabiFan-liquid-node-git-344bec5b
npm ERR! xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
npm ERR!
npm ERR! It says something about a problem an invalid active developer path. Any idea to fix the problem? Cheers Juan Antonio |
@WasabiFan is the node.js guy. It looks like maybe you are trying to install this on a Mac. It is meant to install on the EV3 itself. |
you need to run |
And it will work out of ev3, no need to install it there. |
Oh, wait. You are tying to run the autogen. I though you were trying to run the node.js binding. So never mind. |
Do you have XCode command line tools installed? |
I think that I don't have that tool: ➜ autogen XCode
zsh: command not found: XCode Is it necessary to be installed XCode on Mac? |
I read a bit and I have installed them: ➜ autogen xcode-select -p
/Library/Developer/CommandLineTools
➜ autogen xcode-select -v
xcode-select version 2343. |
I was reading a bit. I am installing xcode-select --install I will test again, in a while |
Installed. ➜ autogen git:(develop) node autogen.js
Queuing 5 file groups...
Completed processing file "python/spec_version.py"
Completed processing file "cpp/ev3dev-lang-demo.cpp"
Completed processing file "js/sensor.ts"
Completed processing file "cpp/ev3dev.cpp"
Completed processing file "js/motor.ts"
Completed processing file "js/extras.ts"
Completed processing file "cpp/ev3dev-lang-test.cpp"
Completed processing file "cpp/ev3dev.h"
Completed processing file "wrapper-specification.md"
Completed processing file "python/ev3dev.py"
Completed processing file "lua/ev3dev.lua" I suppose that I have observe the way for the rest of language to to the same for Java, isn't it? |
Yes. Python has most recently been updated, so use that for your guide. |
Ok, Tomorrow, I will research a bit about the system. |
Looks like this was resolved. Is there anything I should change about the autogen system to make it clearer/work better? P.S. Sorry I haven't been involved in the discussions these past weeks -- very busy! I plan to try to get caught up soon. |
Hi, the process to install the autogen infrastructure is clear, maybe we could update the documentation to add the commands for Mac to ensure that everybody with mac has Xcode installed.
Once, the developer has installed the system, the developer tests autogen with the following node command:
for python, the parts generated by the templates defined on: Completed processing file "python/spec_version.py"
Completed processing file "python/ev3dev.py" the system binds with templates in python in the file: autogen-list.json "python": {
"files": [
"python/ev3dev.py",
"python/spec_version.py"
],
"templateDir": "python/templates/"
}, but what is the mechanics? I have added a local copy of the repo for java on ev3dev-lang in the same level of other language: this project has 2 output files:
In theory, autogen will update both files. In autogen folder i updated the file to add java language but I only added a first file to experiment: "java": {
"files": [
"java/ev3dev.java"
],
"templateDir": "java/templates/"
}, ev3dev.java: //~autogen ../java/templates/java_spec_version
spec_version = "spec: 0.9.3-pre-r1, kernel: v3.16.7-ckt10-4-ev3dev-ev3"
//~autogen I suppose that autogen get the content of the .liquid template and paste the content into the file, but currently with this idea, i receive the following error: ➜ autogen git:(develop) ✗ node autogen
Queuing 6 file groups...
Completed processing file "python/spec_version.py"
/Users/jabrena/Documents/DATA/2015/RESEARCH/robotics/ev3dev/java/ev3dev-lang/autogen/autogen.js:189
if (commentInfo.start instanceof RegExp)
^
TypeError: Cannot read property 'start' of undefined
at processNextAutogenBlock (/Users/jabrena/Documents/DATA/2015/RESEARCH/robotics/ev3dev/java/ev3dev-lang/autogen/autogen.js:189:20)
at /Users/jabrena/Documents/DATA/2015/RESEARCH/robotics/ev3dev/java/ev3dev-lang/autogen/autogen.js:175:9
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
If you add the in .gitmodules this part: [submodule "java"]
path = java
url = https://github.com/jabrena/ev3dev-lang-java
branch = master you could observe the error. The idea is pretty interesting. In python exist other combinations more advanced but at the moment, the most easiest way, I can't update the first file. Juan Antonio |
Here is what you need to do:
There is no need to specify full relative path as long as you've told autogen where to look for the templates. I know python By the way, you can run autogen just for java by |
Right!!! Now, I begin seeing the light!! Updating the file: '.py': { start: /#~autogen *([\w-]+) *((\s*[\w\."']+>[\w\.]+)*)/, end: "#~autogen" },
'.java': { start: cStyleAutogenStart, end: cStyleAutogenEnd } I can update the files defined here: "java": {
"files": [
"java/ev3dev.java",
"java/spec_version.java"
],
"templateDir": "java/templates/"
}, Results: ➜ autogen git:(develop) ✗ node autogen.js java
Queuing 1 file groups...
Completed processing file "java/ev3dev.java"
Completed processing file "java/spec_version.java" Besides, you have reason, sending the parameter java is safer to not update other bindings. Juan Antonio |
Welcome to the club Juan Antonio - I think you will like this project and we look forward to your contributions on the Java binding. |
hehehe, Yes this idea is Smart because the system deacoplates languages from low level and this is the way to increase the scalability of the project. Anyway, I will need some hours to get the first result for Java binding. I continue with the researching!!! :D |
This is going to be held back until next release. Initial PR in #134. |
Good morning,
I have created a repo to offer an API for Java developers using EV3Dev.
https://github.com/jabrena/ev3dev-lang-java
I think that Python development has good progress. For other language, what is the best strategy to integrate with the native API?
http://www.ev3dev.org/docs/sensors/
http://www.ev3dev.org/docs/motors/
I would like to create a easy example from Java to read a Sensor and use a motor for example.
Later, if the PoC goes well, I would like to generate the API for the rest of elements.
Is it possible to reuse low level development used from Python to other language?
Cheers
Juan Antonio
The text was updated successfully, but these errors were encountered: