On the ModularPi, add the following to /boot/firmware/config.txt and reboot:
[pi5] pciex1=on dtoverlay=uart0-pi5 dtoverlay=uart4-pi5 dtoverlay=i2c0-pi5,pins_8_9,baudrate=100000 dtoverlay=i2c1-pi5,pins_2_3,baudrate=1000000 dtoverlay=i2c3-pi5,pins_22_23,baudrate=1000000
NOTE: I²C port 0 can also be configured for 1MHz, if you are only using CFADC-A4L and CFDAC-2V modules on that port.
sudo apt update sudo apt install libfuse3-4 fuse3
Download cfnet-fs now.
Or, download directly to your target device using a terminal program like wget or curl.
wget https://downloads.comfiletech.com/CFNET/cfnet-fs/release/1.0.0/linux-arm64/cfnet-fs chmod +x cfnet-fs
Once downloaded, run the executable as illustrated below to create the virtual file system.
cfnet-fs {mount-point} {i2c1-device} {i2c2-device} {i2c3-device}
For the ModularPi, use
cfnet-fs /tmp/cfnet-fs /dev/i2c-0 /dev/i2c-1 /dev/i2c-3
mount-point can be any directory the user running the program has access to./dev/i2c-0 is the I²C port for analog modules/dev/i2c-1 is the I²C port digital input modules/dev/i2c-3 is the I²C port digital output modules
While cfnet-fs is running, use ordinary file system utilities like ls or tree to navigate the file system at the mount point (e.g. /tmp/cfnet-fs).
$ tree /tmp/cfnet-fs/
├── analog-input
│ └── 0
│ └── channel
│ ├── 0
│ │ ├── amps.txt
│ │ ├── amps.bin
│ │ ├── volts.txt
│ │ └── volts.bin
│ ├── 1
│ │ ├── amps.txt
│ │ ├── amps.bin
│ │ ├── volts.txt
│ │ └── volts.bin
│ ...
├── analog-input
│ └── 1
│ └── channel
│ ├── 0
│ │ ├── amps.txt
│ │ ├── amps.bin
│ │ ├── volts.txt
│ │ └── volts.bin
│ ...
├── analog-output
│ └── 0
│ └── channel
│ ├── 0
│ │ ├── raw.txt
│ │ └── volts.txt
│ └── 1
│ ├── raw.txt
│ └── volts.txt
├── analog-output
│ └── 1
│ └── channel
│ ├── 0
│ │ ├── raw.txt
│ │ └── volts.txt
│ ...
├── digital-input
│ └── 0
│ ├── channel
│ │ ├── 0
│ │ │ ├── state.txt
│ │ │ └── state.bin
│ │ ├── 1
│ │ │ ├── state.txt
│ │ │ └── state.bin
│ │ ...
│ ├── state.txt
│ └── state.bin
├── digital-input
│ └── 1
│ ├── channel
│ │ ├── 0
│ │ │ ├── state.txt
│ │ │ └── state.bin
│ ...
└── digital-output
├── 0
│ ├── channel
│ │ ├── 0
│ │ │ ├── state.txt
│ │ │ └── state.bin
│ │ ├── 1
│ │ │ ├── state.txt
│ │ │ └── state.bin
│ │ ...
│ ├── state.txt
│ └── state.bin
└── 1
├── channel
│ ├── 0
│ │ ├── state.txt
│ │ └── state.bin
...
Automate the modules by simply reading from and writing to the files in the mount point.
echo 1 > /tmp/cfnet-fs/digital-output/0/channel/3/state.txt
File.WriteAllText("/tmp/cfnet-fs/digital-output/0/channel/3/state.txt", "1");
with open("/tmp/cfnet-fs/digital-output/0/channel/3/state.txt", "w") as f: f.write("1")