-
Notifications
You must be signed in to change notification settings - Fork 405
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
Adds padded waves to the API #329
Conversation
@Jul3k , I have other non-GitHub priorities that have come up. I plan to review this in more detail on Tuesday, 3/10. |
Added Task list for releasing this feature. See top comment. |
I would like to add:
|
Moved release task list to the top so we can all make edits. Feel free to self assign tasks you want to contribute to. |
47% appears to be the maximum pad size from my testing. I'll continue to investigate but I would say specifying PPM make little sense with a 3% uncertainty. |
Fails with "No more CBs for waveform" when creating two waves of 48 percent each or 96% of total resource. On further inspection, it appears that 1180 CBs are unavailable for wave consumption or 4.7%. Total CBs: NUM_WAVE_CBS = 25016 Update: Adjusting total CBs to total available CBs (25016-1180) now allows two waves of 50% each. |
- gpioWaveCreatePad takes three arguments: %CB, %BOOL, %TOOL - gpioWaveCreatePad checks range of arguments - gpioWaveCreatePad checks dimension of wave fits inside padding - wave2Cbs takes three arguments: numCB, numBOOL, numTOOL - socket command PI_CMD_WVCAP is variadic
@Jul3k , I pushed changes to the 'wavesize' branch on this repo. I tried to push onto your fork but got error messages. Hopefully you can sync these changes in your fork to update the PR. Let me know. |
@guymcswain I was able to merge with |
@Jul3k , Can you present a case that supports making padded wave consistent with PWM? |
If one would like to have 3 buffers of the same size, each buffer would be assigned 33 percent. This would leave 1 percent unassigned. Specifing this out of a million, would only waste one part of a million. As padded waves are likely not filled to the max, this is maybe more an aesthetic issue, but a decission should be made. |
238 control blocks or about 119 pulses under that scenario. I see your point. Maybe per thousand makes more sense in this case. |
The maximum size wave that can be added using |
Unfortunately, increasing
|
@guymcswain are you talking about the maximum of around 5000 pulses that can be added by a single gpioWaveAdd call? I experienced a similar issue and I believe the error message was something like |
Yes, exactly. But I think the logical workaround is to break the pulse train into smaller chunks with a delay at the beginning to align the chunks.. |
Yes, I agree if this limitation is useful in terms of an appropriate resource usage or performance wise. Maybe the error message could be more verbose? And also in my case it crashed the pigpio python client which should not happen. As It is not directly related to the padded waves, should we open a new issue on that? |
Can a handler be set up in Python to prevent the crash? If not, I would agree it is an issue. If a simple patch is needed then let's handle it here in this PR. |
I believe this should be possible on the python side and maybe the handler can also split a longer pulse table into smaller chunks with a delay at the beginning as you said. This would completely lift that limitation from the user perspective. Should I look into this and do you see any other areas where this might pop up? |
Interesting. I was thinking this would just be left to the application. However the Python client is by far the highest usage (>90% I would guess). I could build this into the nodeJs As far as catching the exception, can this not be done easily in the Python application script? In nodeJs for example, I would just add an 'uncaught exception' handler. I'm not fluent in Python. |
Arguing with myself, 😄 , the Python client should range check the P3 argument so the daemon doesn't disconnect. I now think this is the patch that is needed. I think anything more should be considered an 'enhancement' and be separate from this PR. |
@Jul3k , if you could implement the Python module patch discussed above that would be great. I am in the process of making a rather significant commit that will reduce the number of resources required when generating "differential waves". I'll be pushing this commit later today. Cheers. |
It may be better to trap too large messages in the daemon rather than the client. There should be a central receive point for pipe and socket messages where the length can be checked and an error returned straightaway if too large (I thought I had added such a check, faulty memory syndrome). |
Lines 6980 to 7009 in bab05ce
So are you suggesting the |
It may be non trivial for the daemon to handle what are essentially bad packets. By disconnecting, it forces compliance on the client. |
Let me have a look and try to remember why i did what I did. |
I had a look if this could be implemented on the client side. Passing a longer list sliced into chunks would not be a big deal and could be done similar like so:
I see however one Problem. If a, in terms of microseconds, long wave form was initially added and should be merged with a waveform bigger than 5000 pulses, sequentially building up the waveform by adding an initial delay with The number of pulses that fits in the wave is limited by the CBs and OOLs right? So could this buffer just be extended to the size that max CBs and OOLs can be fully used? Any larger number of pulses does not make sense anyway and the numbers don't seem to be that far off. @guymcswain catching the exception is not the problem in Python, the problem is that the socket is closed |
@Jul3k , There is a hard limit on time also:
I tried to increase the buffer size to allow 12000 pulses (max resources of CBs and OOLs) but it broke something. But in any case, the library as written describes how to place waves 'end-to-end' so I don't think a helper function built into the client is needed. We do need to prevent the socket disconnect from occurring; just need to work out where this is best handled. |
About the socket message size limit I stumbled upon this quote from @joan2937 from this thread
I can confirm setting Is this helpful? linux max socket buffer size |
Probably not. These buffers are primarily to decouple timing dependencies of the network from the os/application. Ie, you could transfer GBs of data and not fill these buffers. |
By curiosity I changed the Makefile to include debug symbols and hooked pigpiod with |
I have pushed two additional commits to the wavesize branch. Commit The other commit, |
The sentinel is fine. |
I plan to leave the APIs as proposed - using percentages. |
@joan2937 , |
It would be useful if you can check that the documentation builds cleanly. That would show up any formatting errors in the source. I'm assuming you have a local copy. Go to the DOC directory and run makedoc. It should result in the following.
The man pages can then be copied to the main directory.
|
Thank you for pointing this out. For some reason my local clone is missing the |
I only added it recently. It should make it easier for others to sensibly improve the documentation. |
The |
You can make the following changes to remove the documentation warnings. pigpio.h
pigpiod_if2.h
[after param::]
pigpio.py
[after params: 32 bit number]
|
Merged into master as version 76. @Jul3k , thank you for your contributions! |
Task list for releasing this feature:
3.6 usec after 10 minutes (10 KHz square wave)
https://github.com/Jul3k/pigpio/blob/c660e3fc8e23c80bbc2f025ac659e07d9f3045e1/pigpio.c#L3147-L3155