====== Get Started Using cfnet-fs ====== ==== Configure the I²C Ports ==== 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. ==== Install the Prerequisites ==== sudo apt update sudo apt install libfuse3-4 fuse3 ==== Download the cfnet-fs Executable Program ==== [[cfnet-fs:download:index|Download cfnet-fs]] now. Or, download directly to your target device using a terminal program like [[https://manpages.debian.org/trixie/wget/wget.1.en.html|wget]] or [[https://manpages.debian.org/trixie/curl/curl.1.en.html|curl]]. wget https://downloads.comfiletech.com/CFNET/cfnet-fs/release/1.0.0/linux-arm64/cfnet-fs chmod +x cfnet-fs ==== Execute 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. ==== Example: Turning On Channel 3 of Digital Output Module 0 ==== === Bash Script=== echo 1 > /tmp/cfnet-fs/digital-output/0/channel/3/state.txt === C# === File.WriteAllText("/tmp/cfnet-fs/digital-output/0/channel/3/state.txt", "1"); === Python === with open("/tmp/cfnet-fs/digital-output/0/channel/3/state.txt", "w") as f: f.write("1") === C/C++ === FILE *f = fopen("/tmp/cfnet-fs/digital-output/0/channel/3/state.txt", "w"); fputs("1", f); fclose(f);