Skip to content
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

AvailableForWrite Limit #13

Closed
Timvrakas opened this issue May 13, 2018 · 1 comment
Closed

AvailableForWrite Limit #13

Timvrakas opened this issue May 13, 2018 · 1 comment

Comments

@Timvrakas
Copy link

I'm trying to send some frames, about 60bytes in length. My mcu was not sending, because the AvailableForWrite() non-blocking limit on the Teensy 3.2 is 39 bytes.

What is the correct way to overcome this? I just overrode the limit and returned 1000UL available for write.

Thanks for the help and the great algorithm!
Tim

@kentindell
Copy link
Collaborator

OK, so AvailableForWrite is an Arduino call that says how much space there is in its internal buffer. If your platform only has 39 bytes then a 60 byte frame isn't going to fit and if you lie to MIN and say there's space then the Arduino buffer will overflow. I'm not sure how Arduino will handle overflows, though. So what you could do is create your own buffering scheme on top.

How it could work is that you create your own FIFO code in software, with a static buffer, and then report back to MIN not the space in the Arduino buffer but the space in your software FIFO (there's code in MIN to do a simple FIFO you could base it on - a power-of-2 sized FIFO can be implemented quite easily). Then in periodic polling function you check to see how much space there is in the Arduino buffer (using AvailableForWrite and move up to that much out of your software FIFO into the Arduino software.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants