-
Notifications
You must be signed in to change notification settings - Fork 7
Description
I'm trying to add YMODEM receive to my project using this library (my fork which allows for setting the Stream port instead of using hardcoded Serial). I can't use the existing streaming options in Commander directly, as the library depends on receiving data via a Stream. I don't really want to modify the library just to work with Commander. I imagine there are more libraries using Stream that could be included in future prefabs, so I'd rather find a good solution to this problem than hack together support for one library to solve my immediate problem.
I see two options here:
- Make a mode where Commander gives up control of
inPort
, and lets other code use it untilstopStreaming()
is called
- This wouldn't work with
!dataStreamMode
as the other code could read from the Stream before Commander gets a chance to look for 0x04
- Use
PairedPipedStream
from this library (my fork where I modified it to optionally output to a Stream on one end automatically). Commander can inspect each byte, and load it into one end of aPairedPipedStream
. The other code can read from the other end as if it were reading directly frominPort
(though Commander decides when to stop streaming data), and whatever it writes gets automatically written tooutPort
.
- This uses more memory as the
PairedPipedStream
has a fixed buffer, but with a little extra code we could dynamically resize the buffer.
- I guess there's a third option where there's no modification to Commander, and I just don't call cmd.update() to make option 1 work inside of my sketch, or I take care of option 2 inside a special handler in my sketch/prefab.
I only thought of the much simpler option 1 after doing all the work upgrading PairedPipedStream
and prototyping option 2 and getting YMODEM receive to work. At this point I think the remaining work for option 1 and 2 are about the same.
LMK if you have some thoughts on these options, or want more details on anything