-
Notifications
You must be signed in to change notification settings - Fork 22
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
libticables: Introduce a cable for using GPIO pins on RPi SBCs #63
base: master
Are you sure you want to change the base?
Conversation
The port from strcpy to strncpy errorneously used sizeof on a heap allocated array, which doesn't have the expected result. This broke e.g. saving variables to files, which were empty beyond the header.
The constness needs to be identical.
With this cable, a calculator can be connected to pins 16 (Tip/Red) and 18 (Ring/White) ideally through a ~1k resistor. Transmission happens by switching the lines between tristate input and 0V output states. In case the voltage of the calculator exceeds 3.3V, diodes should be used in addition to the resistors to limit the line voltage to 3V3 to avoid damage.
9563bec
to
df23c90
Compare
For completeness, here's a branch which replaces use of libgpiod with direct mapped access to the GPIO controller: https://github.com/Vogtinator/tilibs/tree/gpiommap. With that I get transfer speeds of 8.4kB/s, still using the simple setup with just two 1k resistors. |
Thanks :) Several notes:
For item 2 (and 3, if you want to provide the ability to use other GPIO pins ?), bonus points for implementing, say, a struct containing a version number + extra parameters to be passed by a new API similar to How does that sound ? It shouldn't be too much of a burden in terms of development time, plus you don't have to do it entirely alone. |
Yep.
Can be done, but it's hardcoded in only a single place, so moving that elsewhere wouldn't really help much.
Yep. One issue is that the addresses are different depending on which RPi it is, so that would need some extra code and testing. It also needs root privs more than the libgpiod cable and a special kernel parameter (depending on kernel config).
Ok.
One issue is that all of those parameters are highly cable specific and basically need hardcoded integration on the library user side as well, which means that it can't really be abstracted easily. Maybe the best way is to just not abstract it at all and have some cable specific structs...
Once we have an idea of how the API could look like that's probably worth a try. |
FWIW, I got around ~9.2kB/s by optimizing the algorithm a bit. The bottleneck appears to be the calculator (V200 in this case) which needs ~10µS between receiving bits. So it's unfortunately not possible to go beyond 10kB/s. The speed calculation also slows transfers down a bit, as it forces transfers to happen with a maximum block size of total/20: tilibs/libticalcs/trunk/src/dbus_pkt.cc Line 241 in 8ffa244
This only really affects smaller files though, particularly screenshots.
Question is how to share common code between those cables. It's essentially just the open/close and set_line/get_raw_masked functions which differ. It might even be possible to deduplicate code with the serial/parallel cables that way... |
Thanks.
And infrastructure for advanced cable parameters makes it moot anyway.
Good points, I didn't think about that.
In fact, libticables already has a
An early proposal for the new CableOptions struct, and a setter + getter for it, at https://github.com/debrouxl/tilibs/tree/ticables_cable_options . I developed it against master, but it applies equally well to experimental2: most of the action in libti* happens in libticalcs.
Good point. If only this were the only issue with speed calculation, though :)
There's already some code sharing for e.g. the USB cables, so go ahead for the GPIO cables :) |
RFS: https://gist.github.com/rvalles/f937889712d24ac6824f1358c936b3e2 is the patch to deal with one of the "weird GrayLink" implementations, this one needs all three of speed, device and RTS / CTS enablement quirks. |
With this cable, a calculator can be connected to pins 16 (Tip/Red) and 18
(Ring/White) ideally through a ~1k resistor. Transmission happens by switching
the lines between tristate input and 0V output states.
In case the voltage of the calculator exceeds 3.3V, diodes should be used
in addition to the resistors to limit the line voltage to 3V3 to avoid
damage.
With this cable I can receive files with speeds up to 4.0kB/s on a RPi2. The bottleneck is the slow mechanism to read and write GPIO values.
Depends on #62
TODO: