So this took many hours and much frustration, but I've got an updated libdivecomputer tree at
https://github.com/torvalds/libdc-for-dirk
which has the iostream code from Jef's upstream libdivecomputer.
I tried very hard to actually make use of the new iostream code, and in fact it does help get rid of one particularly ugly hack of ours: we used to hook into the serial code with a particularly ugly little hack using the RETURN_IF_CUSTOM_SERIAL() macro.
We now avoid that, and actually create our own custom iostream for that case, and then the new iostream code does things right.
HOWEVER.
We don't actually use Jef's "custom" iostream layer for it, and most particularly, we don't actually expose that to the outside. The actual outside interface remains our trusty old "dc_custom_io_t", and the special custom serial case is actually just a trivial wrapper inside libdivecomputer for that. It's only used for the legacy serial emulation (ie notably Shearwater and OSTC). The Scubapro G2 and EON Steel end up using the subsurface dc_custom_io_t model directly, since for them it's not just a serial stream.
End result: it all looks ok. I've tested it here with my EON Steel (both BLE and USB), my Scubapro G2 (also BLE and USB) and my Shearwater Perdix AI (BLE only, obviously).
But I only pushed to my own "libdc-for-disk" repository, because this is a *big* change, and I'd like at least Dirk to check that it works for his cases too.
Jef: I basically ended up using the "custom" approach for just the internal serial emulation. I *considered* just changing your "custom.c" file to make that work for me, but ended up just instead adding a "src/custom_io.c" file instead. It's pretty close to your custom.c file, but it is explicitly designed to interface with our "dc_custom_io_t". As mentioned elsewhere, I don't think your custom implementation actually is usable for outsiders.
Dirk - caveat emptor. I think it's all good. It looks sane. It passes my tests. But the diffs to both of the parents in that merge is complicated, and the merge does a fair amount of things that were not in either parent since it only made sense as part of the merged state.
I'm actually fairly happy with the end result, but the merge itself was painful enough that you really should check it out.
Linus
Linus,
Thanks for the effort you put into this - I am happy to see us not stranded at 0.6.0!
On Dec 12, 2017, at 2:24 PM, Linus Torvalds torvalds@linux-foundation.org wrote:
So this took many hours and much frustration, but I've got an updated libdivecomputer tree at
https://github.com/torvalds/libdc-for-dirk
which has the iostream code from Jef's upstream libdivecomputer.
I owe you dinner.
Dirk - caveat emptor. I think it's all good. It looks sane. It passes my tests. But the diffs to both of the parents in that merge is complicated, and the merge does a fair amount of things that were not in either parent since it only made sense as part of the merged state.
I'm actually fairly happy with the end result, but the merge itself was painful enough that you really should check it out.
I am traveling but decided to take a couple of dive computers with me. Not because I expected opportunities to dive in Palo Alto, but because I was hoping that I might get to use them. Looks like I might get lucky.
I think we should be able to take advantage of our git submodule to make some of this easier - correct me if I'm wrong. But if I merge this into a different branch (let's say Subsurface-experimental) of libdc then I should be able to create a pull request for Subsurface that references that git SHA for the submodule and that should give us test builds and installable binaries for all but iOS "for free", correct?
/D
On Dec 12, 2017, at 4:07 PM, Dirk Hohndel dirk@hohndel.org wrote:
I think we should be able to take advantage of our git submodule to make some of this easier - correct me if I'm wrong. But if I merge this into a different branch (let's say Subsurface-experimental) of libdc then I should be able to create a pull request for Subsurface that references that git SHA for the submodule and that should give us test builds and installable binaries for all but iOS "for free", correct?
That did indeed work really well. I fixed a compile problem on Android, I reviewed the merge itself, I tested Android and Mac... it all looks good.
I think the only way to get broad test coverage against many dive computers will be to push this to Subsurface-branch and master, so I just did that (and I also included the one commit that had been sitting as a PR on GitHub for a week or so - simply ignoring the build directory under libdivecomputer).
Thanks again, Linus
/D