I guess I never actually made a post about this before, whoops.

Anyways, srldrvce is a library for interacting with USB serial devices on the CE, and for using the CE as a virtual serial device for a computer. It's been sorta working for a while, and has a branch on the toolchain repo.

Recently, I decided to rewrite it, as that seemed easier than diagnosing and fixing the issues with the old version, which is a bit of a mess.

I'm looking for feedback on the API, before I get too far into implementing it. This is the old API, and this is the current (WIP) API.

I'm considering removing the srl_Available function after Mateo voiced concerns about it potentially leading to bug-prone user code. srl_Read returns the number of bytes transferred, so it's not hard to rewrite code that uses srl_Available to use that instead.

If you guys have any feedback about srl_Available and the rest of the API, I'd love to hear it.
I can't speak much to the backend stuff, but it seems within the forward facing stuff, the only forward facing change (with respect to actually *using* the thing) is that srl_Init() and setBaudRate() are now all done within srl_Open(). Makes things simpler which is nice. There also seems to be less error defines?

As for srl_Available, if that's redundant of a non-zero return from srl_Read(), then there's no need for it. 9 and a half times out of 10, if Mateo thinks something would be better served being removed, he's likely right. And the other half of a time, you're probably not effectively explaining to him what you're trying to do lmao.
The only issue I see with removing it, is you can no longer packetize... (reading out the number of bytes received without actually affecting the buffer state). For instance in my Trek code, iirc, you used srl_Available until srl_Available matched the expected data size and then did a Read(). Is a zero-size srl_Read() allowed, to just get the number of bytes on the received?
srl_Read doesn't return the number of bytes available, but the amount of bytes copied to the buffer. So, if you try to copy 0 bytes, and there are 3 in the buffer, it will return 0. You'd need to do something like this for an exact replacement:

for(i = 0; i < size;) {
    i += srl_Read(srl, ptr + i, size - i);

This is better since it allows you to receive stuff larger than the serial buffer.

also, woot, 750 posts
I decided to go ahead and remove srl_Available.

Calc <-> computer communication is now fully working in the rewrite, and calc <-> device communication should work as soon as I finish the descriptor parsing and srl_SetRate.

If anyone has any devices they'd like me to support, especially ones that use vendor-specific protocols rather than USB CDC, I would appreciate it if you could post the USB descriptors or the output of lsusb -v for that device here.
And I am stuck on reading 64 bytes for some reason :p
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum