mbusd icon indicating copy to clipboard operation
mbusd copied to clipboard

Using IOCTL for GPIO control

Open falcon35180 opened this issue 9 months ago • 4 comments

I have built modbusd for an embedded NVR with an ARM CPU (HiSilicon Hi3520D V300) and am using it to communicate with a PV inverter.

The kernel module for GPIO control exposes an IOCTL interface to set pin state and direction - no sysfs file interface, unfortunately.

I figured out the correct commands to control the appropriate pin through reverse engineering (disassembling, decompiling, writing test programs).

This particular driver takes a structure pointer as an IOCTL argument; there may be others out there that take int/long arguments.

I made a slight modification to tty.c for this purpose and it works well for my case. It would be great to find a way to implement this in a more generic way.

I haven't forked the repo to publish the code since it's not really ready yet. I may work on it some more when I get a chance, but I'm mentioning it in case someone else wants to take it on.

Happy to assist in any way I can in the meantime.

falcon35180 avatar Sep 17 '23 07:09 falcon35180