-
-
Notifications
You must be signed in to change notification settings - Fork 627
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
Separate drivers and stack #108
Comments
Do you wish to also erase the currently available drivers? That would imply having all demo apps updated. If so we could also go ahead and delete the driver directories from this repo. |
For it to be clean, this would be the way to go. However, I can't do more than just erase them. I neither have the time nor the hardware/compilers to move them out and get them working again... I also have no idea if all drivers are up to date with their manufacturers environment (except the ST one which is really outdated). |
That would be nice to get a repository CANopenDriver created by CANopenNode with multiple maintainers instead of drivers everywhere. I may help with PIC drivers. |
Well, there are a lot of question that come to my mind here. Typically we see that someone enables the driver for one kind of MCU, and afterwards there are no updates on that driver, or just very few. The reason could be different kind of things:
Would you allow these drivers to be merged, knowing they'll not be updated? Furthermore, it doesn't happen too much that we have 2 projects using the exact same MCU, while drivers are actually tightly bounded to the MCU. Will a maintainer work on updating the driver? For example: mbed-os is updated once each few months, I don't want to be the guy to updating/testing that driver :) On the other side, I recon having one repo to rule them all is a good way to not spread the implementations over the entire internet. Links get broken for example (= code rot?)... How can we handle that? What about having mainline drivers, which have proven their usage (through compliance tests)? |
In my opinion the drivers provided with the stack should be considered as examples for a family of microcontrollers. I am not sure outdated drivers are a problem if someone want to use an 'outdated driver' it is easier to start from something existing and update/compare it based on the driver template than starting from zero. |
FYI: I just pulled in latest master and I was able to use the stack perfectly using the drivers I made for CANOpen node v1.0. So maybe we can take out the current drivers and put them in a separate repo that has only these legacy drivers: CANOpenLegacyDriver. That repo should be read only. What do you think? |
It seems to me that separating the drivers from the stack into a CANopenNodeDriver repo like @JuPrgn mentioned and having folders for each of the versioned releases of the stack would make driver management a lot easier. This would have a number of benefits:
Whenever someone submits a driver for a version of the stack it can be placed under the appropriate folder in the repo and there can be a list describing what level of compliance/validation testing has been performed for that driver (self-reported and officially recognized testing). I don't see a need to enforce strict criteria about driver submission as long as the status is tracked. |
Using folders for versioning your drivers... so why use git altogether? I'm curious on how you'd do the compliance/validation. Basically the repo maintainer(s) could easily pull in new drivers based upon that report. Maybe you could further elaborate how the validation process looks like? |
@geoffrey-vl I think that sounds like a fine way to could achieve the goals I mentioned above. A link in the CANopenNode release notes to the appropriate driver branch to make it easy to locate would be nice. For compliance and validation, the official test plan is specified in CiA DSP 310-1. Anyone who's working for a company that's a CiA member can also get a free copy of the official compliance test tool (that's what I'm using). If we can write out a list of what functions the stack relies on the drivers/application for, I suspect that a small subset of the tests could be used to test the drivers for compliance (most of the compliance tests aren't going to be driver specific). Maybe someone can put together an open source tool for this? |
I'm attempting to tackle one of the obstacles to properly splitting the code: the redefinition of Most of the functions are common to all drivers and must have the same API since they are used in target-independent code. What remains are the definitions of synchronisation primitives. These should probably be defined as functions rather than macros as to avoid having to include target-dependent header files. Furthermore, synchronisation primitives feel awkward, I need to investigate but I'm 99% sure they could be replaced by atomic variables. Same for the various uses of I suggest to:
The last remaining bit is the macros to define endianness ( EDIT: I missed the custom fields in EDIT 2: Could we list the drivers that are used by at least someone? What do you think? |
Hi, Syncing took me quite a while to find a solution back then.
So, yes, I think C11 "atomic" is the best solution. But unfortunately not available here. I didn't find any other solutions, so going "you have to do that yourselve" was my best idea. I'm open to better solutions. I think the current driver design isn't that bad. It's mostly that drivers bring code to the stack that can't really be maintained properly. regards, |
I understand your point. We can definitely keep the synchronisation primitives as macros. My idea was that they are more of a compiler-specific issue than a target-specific issue. We could for example have a My second point is that a lot of functions currently declared in each |
I would like to separate the drivers, because it is not possible to maintain the code, for which the maintainer does not have a hardware, software tools, supplementary files, etc. I can currently maintain only PIC and Linux. I want keep CANopenNode clean, but there are many different implementations on many different hardware, by many different developers. I want to put the responsibility for the specific (group of) hardware to the specific (group of) people. If someone implements some exotic device and want to share it or collaborate to others, then it's best to host it on his place. CANopenNode/wiki is public editable and he can put a link there. If device is more widely used, like PIC or Linux or STM or LPC, etc, then I recommend to put the project on this place. CANopenPIC and CANopenSocket are already here, I can add repository for other devices (or better, group of devices, or for specific tool like MBED) and specify collaborator(s). I don't expect much, basically project should contain driver files, optionally very short demo, some description and link to CANopenNode. I recommend adding CANopenNode as a git submodule, it automatically keeps track on version used. I moved 'Microcontroller support' section from README file into wiki and add some text into README. For now, just to be on one place. CO_driver.h is already extracted, thanks to @odesenfans. I will try to copy driver files into CANopenPIC and do some tests. I can also add @JuPrgn as a second maintainer. I lost track on CANopenSocket a little since my last commit. I would like to leave the transfer of driver files to @martinwag. Or at least I need some advice. For other devices I have no fresh information (except @WillyKaze contributed LPC1768 with MBED). If someone is using driver files, please make simple demo project with driver files included. I don't know, how it is with MBED. Mbed-os RTOS + STM32 F091RC by @geoffrey-vl is already available from wiki. Could other devices be used too? |
Hi, I like the idea that CANopenNode is really just being a library that contains logic. I just want to point out one thing. Those driver repo's will still have the same problems that we have now: we will have people adding device specific code for a specific mbed-os release, over time API's change, drivers will not be maintained and code will rot. So in the end we've just moved our problems (and responsibilities) out of CANopenNode into CANopenNode-driver-**** . I think that this problem is very hard to cover, the platforms are too divers and there is way too little people involved. I think we should start as you suggested and act. We can review these changes over time and see where it leads us, but I think it in the end we will gain portability and acceptance. One other thing, it would be nice if the EDS editor became an official part CANopenNode. I have no idea if that is somehow legally possible, or even wanted by all parties. |
I started using Linux when I started developing CANopenSocket and now I just like its philosophy. It says: 'Small is Beautiful', 'Each Program Does One Thing Well', etc. Maybe that's the reason, why I like splitting the project into smaller parts and make a good interface between them. Similar is with CANopen: many smaller "smart" devices, than single big central controller. I do not worry about the problems, split repositories may have. Good implementations will live on, people will easier maintain them, they won't always have to wait for the 'CANopenNode maintainer' to move. I think, the most important is, to keep a good track to available implementations. I think, public editable CANopenNode/wiki is perfect for this. Maybe we can make things more clear there. We can make a table. Also supported features can be specified more precisely, CANopenNode version can be noted, maybe links to some interesting examples or forks can be added, etc. Second thing, I already edited CANopenNode/README.md and recommended libedssharp as OD editor. But for the reasons, I described above, I prefer to keep it as a separate project. However, we can move the project here, besides CANopenNode, but currently this doesn't make a big difference. And third thing, I have some more time now and I will try to make new OD interface in next few months + some other things. |
I pushed new branch: split-driver.
Code compiles well. CO_driver.h is much better organized, documentation is much updated. Some code in other files in 'stack' directory is updated. CANopen.h is excluded from doxygen documentation. |
Next will you move all drivers away from this repo? |
I do not need to hurry with removing them. Now I'm going to update the PIC microcontrollers (copy drivers to CANopenPic project). Then CANopenSocket (I would like to hear some advice from users, because I haven't been here for some time). After that I plan to:
So basically, they will always remain in the repo, they will just be removed from the master branch. The fact is, I have no information, if and where other drivers from this repo are used. Except those listed in Wiki. And also, CO_driver.h is now more or less the same as before, except it is more clear. So it shouldn't be hard to make simple repo(s) with example for still relevant drivers. I'm also ready to open project for specific (family of) drivers here and specify the collaborators. |
One thing: most likely changing the OD is a big change that will break libedssharp. I'm not sure if you agree but I'd call that a mayor change. I assume we don't take too many steps at once and call that V3.0? |
Yes, changing the OD will be a mayor change. libedssharp will probably follow the change. Until new OD won't be stable, it will be in separate branch. |
On Tue, 21 Jan 2020 at 11:13, Janez ***@***.***> wrote:
Yes, changing the OD will be a mayor change. libedssharp will probably
follow the change. Until new OD won't be stable, it will be in separate
branch.
It will be another exporter added to the export options, I'll leave the
existing exporter alone. It will be interesting to see what needs changing
as my goal is to use the native XDD and EDS fileformats for saving the OD.
Currently there are a couple of "extensions" i have added in the XDD the
main one is the COS Notify flag, there does not appear to be anything in
the XDD format to permit such a field. And i'm sure there will be other
interesting problems to solve. Time permitting once an idea for the new OD
is in git i'll try to make a start on the new exporter as well.
Robin
|
CANopenPIC is now completely updated. |
Just a note: Branch split-driver should be used for updating own drivers. |
Before I continue with CANopenSocket I have a question (for @martinwag) about two drivers for it: original socketCAN and neuberger-socketCAN. I didn't check the latter yet. I suppose, socketCAN is now outdated (my fault, I wasn't reading the messages). So neuberger-socketCAN can be a replacement for socketCAN, and old socketCAN has no advantages over newer neuberger-socketCAN. If that is so, I would like to drop old socketCAN driver. Is it OK? Are there any other suggestions about CANopenSocket? |
I'm still relying on CANopenNode's CANopenSocket for testing CANopen modules. So I'd like to know if it gets removed that the replacement works as a drop-in replacement? |
One more thought: CANopenSocket is quite wide project. There may be other projects based on Linux driver. Does it make sense to make an exception and keep the Linux driver part of the CANopenNode? In that case I would move |
The old socketCAN driver has some bugs/undefined behaviour compared to my one, so I would recommend replacing it. |
I've had a short look at the differences between the two socketCAN drivers
|
Yes, I already copied OD storage. |
I have a question about neuberger-socketCAN:
I would like to add at least |
Yes, they are custom. Our product uses the linux syslog for storing errors, as we don't have a terminal open at runtime. I did not put much thought into how to make this universal at the time that I wrote it, except for someone else not to get compile errors.
Do you have a good idea? For reference, those are the macros:
and log_printf is a wrapper for syslog() https://www.gnu.org/software/libc/manual/html_node/Syslog-Example.html Edit: erros in macros |
Of course, we can just add the necessary files to the driver and I keep a changed version in my local repo. I don't really want the driver to be more complex than necessary because of company internals... |
I think, log_printf() functions are just fine as they are. And there should be an option for custom log principle and custom message contents. I will just add your defines so they could be optionally selected. Do you also have defines starting with |
I'm going to have a look at this as some of the multi interface stuff is broken since changing driver API anyway. |
If you wait a few days. I will write main.c based on neuberger-socketCAN driver and make some minor changes in the driver to suit the API. Then I will also move files from project CANopenSocket/canopend (master / DS309 files) into CANopenNode/309. And make it universal, better organized on one place. I think, there will be only simple changes, so there should not be much job to fix broken things in custom project. If you will take a look into reorganized code and make it suitable to your needs, you can also reorganize if you like. I think, code is universal enough and it should also be easy to include custom stuff. I prefer, if we all use the same base code, even if it is a little more complex. People often verify the code and warn if find something strange. |
I've pushed the current version to master branch. This includes all log messages and various fixes to be compatible with master. I'm not going to merge into split-driver currently. Feel free to remove the "neuberger-" prefix, it's only there because at the point I started socketCAN was already taken :-) I would prefer to keep the CANopenSocket / canopend stuff in it's own repo. As it's currently implemented, it's more like a debugging tool and a demo application for how to use CANopenNode than production-ready code. |
Thank you. I will merge master into split-driver. I will also try to document changes in doc/changelog.md. "neuberger-socketCAN" allready steal the name "socketCAN" :-) I would like to move CANopenSocket / canopend, because all files except main.c are actually implementation of the DS-309-3 standard (CANopen access - ASCII mapping). And those files could be used also on microcontroller via serial interface. |
I don't think the canopend/309 stuff will run on a simple microcontroller. We have dependencies for half a POSIX system in there, so you need at least one of the more advanced RTOS. You also can't use POSIX stuff on Windows, if anyone cares... |
I will check again, how complicated it is. I intended to separate socket and thread stuff, which is specific for Linux. Then there only is a blocking function with input as a command string which writes out the answer string. |
Between the v1.2 and master there were some commits, which changed the driver (Single project-wide header and void pointer for the CAN device address). But they were not systematic enough and there were some bugs. When I started with split-driver branch, I first reverted messy commits and used original driver code. Then I made own "Single project-wide header". I leaved "void pointer for the CAN device address" but made a full check and comparison with the original code. I think, some parts of current master branch is quite messy, especially drivers, I'm more focused on split-drive now. I will verify your fixes in current master and will also update the split-driver. Please also note some bugs found in original code, which were fixed in split-driver, but not in master:
|
I must change my opinion: I think, current master branch from v1.2 is not so messy, there were some very good contributions. Also O. had had some good ideas, just his contributions were not fully thorough. However, I think stack is OK now. |
I'm slowly advancing with the stack. Most updates are in the branch split-diver. It is rearranged now (see #161), but fundamental code remained more or less the same. I Allowed myself some more freedom for changes (according to my taste). I hope, code is better organized and documented and will be usable. It is tested to some extent and it seems to work fine on Linux and PIC microcontrollers. Please take a (quick) look into a new code. Some changelog info is here: https://github.com /CANopenNode/CANopenNode/blob/split-driver/doc/CHANGELOG.md. If there are some ideas or proposals, please share it. Even if some existing principle will be broken, if there is improvement, now it is the time for changes. I just don't want to change some taste specific things, like reformatting all the code. Linux socketCAN driver: it is now part of the stack and is copy of "stack/neuberger-socketCAN". There are some minor updates and notifyPipe is replaced with simpler and more suitable eventfd. Added are threadMainWait_xxx() functions as alternative to threadMain_xxx(). They include some additional posix interface. |
I see that you have removed the option for not using dynamic memory allocation. Any chance of bringing that back? |
I tried to simplify CANopen.c. But no problem, I will bring it back. |
Globals are now enabled from CANopen.c as before. split-driver branch is now merged into master. Directory structure is rearranged as explained in #161. Other driver files are removed from master, see deviceSupport.md for details. Old layout is still in git history. There is also I'm closing this now, discussion of source code organization may continue in #177. |
any reason why the old-master branch shouldn't be called "v1" or something alike? |
You are right. I renamed it to There is also tag |
Separating drivers and the stack is a good solution to get consistent working builds
see #105 (comment)
With the stuff I merged in commit 8b01062 I think I broke all drivers except driver template anyway...
The text was updated successfully, but these errors were encountered: