-
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
Conversation on language binding spec #4
Comments
Re enums: in general I would like to stay with the native sysfs types, so 'on' and 'off' as strings are fine. Regarding the port IDs (1 .. 4 for inputs, A .. D for outputs I would prefer numbers for the parameters, but unnamed enums as helper (INPUT_1 = 1, INPUT_2, .. OUTPUT_A = 1, OUTPUT_B = 2, ...). The value '0' for ports I would like to be interpret as 'Don't care', as in my implementation. This leads to re: Device initialization: I agree with your approach, but with '0' as 'Don't care'. In this case, we take the first matching device that we find (this is my current implementation). Another remark to sensors: I would like to have two getValue members, one for the raw value and one for the scaled (dp) value. Return type for the raw data should be int, scaled data should be float. Does that seem reasonable? |
So, 0 would mean "find the first motor that is plugged in" for motors, and "find the first sensor that is plugged in" for generic sensors? If so, would that also mean that specific types of sensors would store the list of sensor IDs that they can handle, and use that to narrow the search? Or would the device type be an argument? I personally like the first option better, but we could probably combine the two with a separate function. I'll add this to the spec, and we can see how it looks. Separate topic: Versioning I think we are getting close to the point where we can start adapting our existing code around our spec. That means that we will need to figure out a versioning system. Do we want to have all of our packages maintain the same version number (along with the spec)? I'm thinking we have them all start out at |
I have made the discussed changes to the specification. |
Re versioning: 0.9 is ok for me. Re error handling during initialization: in C++, throwing exceptions from constructors is pretty problematic, we should avoid this. In my implementation motors and sensors have a member Regarding the device enumeration discussion, we should probably first think about the sensor class hierarchy. For which sensors do we want to have special classes? Should we introduce base classes for similar sensors? Re: |
I have added the version info and error info to the spec, and I renamed those two methods. For a start, I was thinking these sensors would be good to have special classes for:
Other than maybe the ultrasonic sensor (where the EV3 and NXT versions are very similar but slightly different), I don't think we need base classes other than How do you want to handle special sensor classes? For example, the color sensor has modes for RGB, color index, and reflection. Would there be a property for each (R, G, B, Color Index, Reflected), and then getting each value would change the mode to what is needed automatically? Or would it throw an error if it wasn't on the correct mode, and have the user change it? Tonight, I am going to bring in my Node JS binding and start gutting it so I can rebuild it for the new spec when it's done. |
|
I think support for non-mindstorms I2C sensors should probably wait for a later release. Managing drivers manually will take a lot of custom code in many languages, something that would probably greatly delay an 0.9 release. I2C/M sensors are auto detected and loaded in to the
Hmmmm... good point. I guess our options then are either to just get the index that the value should be at (and if it's the wrong mode, that is their problem), or have an option to enable/disable the checks (which would still require a comparison, but Boolean comparisons are fairly fast). Something like a "safe mode"? I think that would give a fairly good balance of performance and error-checking/ease-of-use. Or, maybe we could convert the mode to an index (as listed in the |
My classes
I suggest giving a base class for non-mindstorms I2C to encapsulate low level I2c operations. I use the smbus binding for python. |
Do you have implemented the "0" port? if not, I suggest using "-1". Because "0" is really confused for user to remember if the port index is 0 based or 1 based. My 2 cents |
There are enums / constants for the ports, so I do not see a problem here. I want to reserve negative port numbers for future extensions like "take the second connected sensor". |
Using Anyway, I just committed a small change to the spec that defines a |
When converting my code to the new spec I realize that both sensors and motors do lack an initialization parameter: type. In case of sensors this is the lego sensor type ID (number), in case of sensors this is a string. Do you agree? |
Yes; that makes sense. But can we say that it is optional (in all languages that support optional parameters)? One might want to be able to just allow all sensor or motor types, like if they are running a test or don't care what sensor it is. Past that, someone might want to allow multiple sensors (for example, the EV3 or NXT version). So maybe the parameter should be an array? |
At the moment, in my implementation 0 (as sensor type) / an empty string (as motor type) does mean "don't care". I like your idea with a list of allowed types. This is easily realizable in lua and c++. |
Ok; I will write this up in the spec. |
Sorry it took so long, but I have finally implemented sensors in the JS binding. I will be closing up my old separate repo and redirecting people over here in the coming hours, just so you are aware. By the way, thanks again for letting us use your repo for our combined library efforts. |
@fdetro What do you want to do about the branches? Maybe set |
Excerpt from ev3dev/ev3dev.github.io#14:
|
I have merged the changes from master into the language-binding-unification branch. If you have completed your changes we can merge language-binding-unification back into master and create the 0.9 release. For me it's OK to move the repo under the ev3dev organization. |
My JS binding is ready for a release, and my Vala binding is close. I'll finish up there and then we should be ready. @dlech, if we move this over to the ev3dev org, we can still have push access, right? If so, I think that will work out nicely. |
Yes, we can create a "language bindings team" and give the 3 of you write access. Then you can approve my pull requests for a change 😄 |
I just created this group and sent invites. @fdetro should be able to go into the settings for this repo and select transfer ownership and transfer it to the ev3dev organization. GitHub will automatically create redirect links to the new location. Or we can create a new repo under ev3dev and you can push there and leave this repo for posterity. |
Also, here are some things to consider... I have started issue ev3dev/ev3dev#143 to discuss some of these things further if you would like to have any input.
|
I have moved the repo into the ev3dev organization. Thanks to @dlech. |
Re @dlech on port names and sensor / motor multiplexing: we should also consider a USB daisy chaining as implemented in the stock LEGO ev3 image. But first of all we need to get the basic functionality working, next steps are unified APIs for LEDs, buttons, battery etc. |
For daisy chaining, I am thinking that we just implement a remote control protocol over TCP/IP, then you can have USB, Bluetooth or WiFi "daisy chaining". In this case, the port names could be |
@dlech the issue I have with using TCP is that it can be fairly slow. I tried reporting Xbox 🎮 controller values through the USB networking connection, and only 40 bytes/sec was enough that the ev3 slowed and crashed. I would prefer that we implement LEGO's proprietary protocol. If we can send and receive those same commands, then one could use an ev3dev EV3 to control a stock ev3 (which I did in a custom program; its pretty cool). You can get an idea of how the protocol works in the stock kernel source. Basically, if the port number addressed is out of the hardware range, it propagates it to the next device in the line. |
@fdetro I have finished and fully tested my vala/js bindings. They are both fully compliant with v0.9 of the spec, and I tested all the basic functionality in both. Assuming the other two are good-to-go, I think we can tag this and make a release. Sound good? |
Sound good. I have merged the changes from the branch to master and drafted a release v0.9.0. Feel free to review / extend the comment and finalize the release. |
Should we now proceed with LEDs and battery? These should be easy, buttons will need some more thinking regarding synchronous vs. asynchronous reads. |
I think so; can I create a GitHub release for our current code, and push my Node module to NPM? Once we do that, I think starting on LEDs and battery (for maybe a 0.9.5 release?) would be good. |
Never mind... didn't see your other comment. Tagging and releasing now! |
Should I also delete the separate branch so that we work off of master? Or keep the separate one for dev work, and only merge to master on release? |
From my experience working on GitHub, I would suggest working on master if you want other people to be able to follow along. Other branches stay kind of hidden from view unless you go looking for them. So, I guess it just depends on how much you want people (like me) poking their noses in your business. 😄.
Switching my philosophy from "cover every possibility" to "keep it simple", I would suggest having 2 functions for buttons based on what people are probably used to from EV3-G and NXT. Have one function that reads the current state of a button and a second function that blocks until a button has a certain state (pressed or released). |
I would prefer to continue major rework on branches, so let’s stay on the language-binding-unification branch for now. OK?= |
I agree on the function which checks the current state of a single button, but probably the blocking one should deliver a bit set or maybe even some kind of events?= |
Agree with @dlech, need both asynchronous and blocking button read capability. |
The binding branch is currently set to show up by default on the GitHub page, so I think that makes it easier for people to find. |
Sorry, I used the wrong terminology. I meant master == GitHub default branch rather than master == branch named master. |
I have merged the binding branch back to master and also prepared the release on master. It is common git practice to have the stable code on master and doing the work on other branches. Do you know the git flow model? http://nvie.com/posts/a-successful-git-branching-model/ |
@fdetro Yep; I'm good to work off of the current binding branch. |
@fdetro I was just saying that having the GitHub "main" branch (the one that shows up when you first open the repo) be the work branch ( |
I think this issue worked well for conversing about the initial work, but now we're at the stage that there are specific features that we are looking to implement. Can we close this issue and use dedicated ones from here on out to discuss the new features that we will be wanting to implement? |
Just to finish up the branching conversation, how do we want to operate? Currently, we have the main branch sitting as the repo was when we finished I'm thinking we rename the current |
This starts the conversation around what "master" is. Is it the last shpped version, and the branches/tags are works in progress, or is the next version we'll ship, and you go back to a tag to get a specific shiiped version. |
Short version:
No.
Yes. Long version: I put @fdetro and @WasabiFan in charge of this particular repo, so as far as I am concerned, they can decide to manage it how they like. 😄 For reference though, most projects on GitHub use Also, generally speaking on GitHub, feature development branches usually happen in the users fork of the main repo rather than in the main repo itself. The exception would be if multiple core contributors were collaborating on the same feature at the same time. In the case of ev3dev, most of our main development branches are called |
@dlech That makes sense. I'd say we call it As for the branching/tagging, I'd say we branch it off at every release. Maybe we adopt a naming convention (something like |
WHen you say branch in this context, I think you mean tag.
|
I still vote for using a standard git / github model. If a fix is needed on the current release, it is merged to Does this sound reasonable? |
@fdetro Sure, I'd be fine with doing it like that. So we would keep the current "master" as-is ( and tag releases there), and then rename "language-binding-unification" to something like "development"? Is it O.K. with you if we keep the development branch as the 'default' on GitHub, so that it shows up when you load the page? Assuming that @dlech and @rhempel are fine with this system, @fdetro feel free to rename the branches as you see fit (I'll back whatever names you chose). |
I think @fdetro is asking for tags to be created on |
Yes, I think that is what @fdetro is saying. P.S. Upon further reflection, I realized that I hadn't written the same thing that I was thinking, so I updated my comment above, in case that was what you were noticing. Sorry for adding more confusion! |
OK, then I will rename the This will allow me to use the gitflow model for my future development. |
@fdetro Sounds good to me. |
Done. |
Switch from module to package organization in python
I have almost completed a preliminary draft of the spec for motors and sensors. It can be found here: https://github.com/fdetro/ev3dev-lang/blob/language-binding-unification/wrapper-specification.md.
For this first version, I tried to mostly do direct mappings of sysfs properties to object properties. I am looking for feedback on what I have written so far, and I also have a few questions about finishing the feature set so that we can get to a version that we can implement.
Here are my questions:
Once we answer these questions and tidy up the spec, we should be able to start implementing this in code.
The text was updated successfully, but these errors were encountered: