Python API to find Free-WiLi devices
Project description
FreeWili Finder
A cross-platform C/C++ library for discovering and interfacing with FreeWili devices connected to a host system.
Overview
The FreeWili Finder library provides both modern C++ and C APIs to:
- Discover all connected FreeWili devices automatically
- Enumerate USB devices associated with each FreeWili
- Identify device types (Serial ports, Mass storage, FTDI/FPGA, etc.)
- Access device information (VID/PID, serial numbers, port paths)
Features
- Dual API Support: Modern C++23 API with
std::expectederror handling, plus C API for maximum compatibility - Cross-Platform: Supports Windows, macOS, and Linux
- Type Safety: Strongly-typed USB device classification system
- Error Handling: Comprehensive error reporting and handling
- Memory Safe: RAII in C++, explicit memory management in C API
- Testing: Full test suite with GoogleTest integration
Quick Start
C++ API Example
#include <fwfinder.hpp>
#include <iostream>
int main() {
if (auto devices = Fw::find_all(); devices.has_value()) {
for (const auto& device : devices.value()) {
std::cout << "Found: " << device.name
<< " (Serial: " << device.serial << ")\n";
// Get serial ports
auto serials = device.getUSBDevices(Fw::USBDeviceType::Serial);
for (const auto& serial : serials) {
std::cout << " Port: " << serial.port.value_or("Unknown") << "\n";
}
}
} else {
std::cerr << "Error: " << devices.error() << "\n";
}
return 0;
}
C API Example
#include <cfwfinder.h>
#include <stdio.h>
int main(void) {
fw_freewili_device_t* devices[16];
uint32_t device_count = 16;
char error_msg[256];
uint32_t error_size = sizeof(error_msg);
if (fw_device_find_all(devices, &device_count, error_msg, &error_size) == fw_error_success) {
printf("Found %u device(s)\n", device_count);
for (uint32_t i = 0; i < device_count; ++i) {
char name[64];
fw_device_get_str(devices[i], fw_stringtype_name, name, sizeof(name));
printf("Device: %s\n", name);
}
fw_device_free(devices, device_count);
}
return 0;
}
Building
Prerequisites
- CMake 3.20 or later
- C++23 compatible compiler (GCC 11+, Clang 14+, MSVC 2022+)
- Platform dependencies:
- Linux:
libudev-dev - macOS: Xcode command line tools
- Windows: Windows SDK (SetupAPI, Cfgmgr32)
- Linux:
Build Instructions
# Clone the repository
git clone https://github.com/your-org/freewili-finder.git
cd freewili-finder
# Create build directory
mkdir build && cd build
# Configure
cmake .. -DCMAKE_BUILD_TYPE=Release
# Build
cmake --build .
# Run tests
ctest --output-on-failure
CMake Options
FW_FINDER_BUILD_TESTS=ON/OFF- Build test suite (default: ON)FW_BUILD_C_API=ON/OFF- Build C API library (default: ON)FW_BUILD_STATIC=ON/OFF- Build static libraries (default: ON)FW_BUILD_EXAMPLES=ON/OFF- Build example applications (default: ON)
API Reference
C++ API (fwfinder.hpp)
Core Functions
namespace Fw {
// Find all connected FreeWili devices
auto find_all() noexcept -> std::expected<FreeWiliDevices, std::string>;
// USB device type detection
auto getUSBDeviceTypeFrom(uint16_t vid, uint16_t pid) -> USBDeviceType;
auto getUSBDeviceTypeName(USBDeviceType type) -> std::string;
}
Device Types
enum class USBDeviceType {
Hub, // USB Hub (parent device)
Serial, // Serial Port (general)
SerialMain, // MainCPU Serial Port
SerialDisplay, // DisplayCPU Serial Port
MassStorage, // Mass Storage Device
ESP32, // ESP32 USB (JTAG/RTT)
FTDI, // FTDI/FPGA Device
Other // Other USB device
};
C API (cfwfinder.h)
Core Functions
// Find all devices
fw_error_t fw_device_find_all(fw_freewili_device_t** devices, uint32_t* count,
char* error_msg, uint32_t* error_size);
// Device validation and info
bool fw_device_is_valid(fw_freewili_device_t* device);
fw_error_t fw_device_get_str(fw_freewili_device_t* device, fw_stringtype_t type,
char* buffer, uint32_t buffer_size);
// USB device enumeration
fw_error_t fw_usb_device_begin(fw_freewili_device_t* device);
fw_error_t fw_usb_device_count(fw_freewili_device_t* device, uint32_t* count);
fw_error_t fw_usb_device_next(fw_freewili_device_t* device);
fw_error_t fw_usb_device_get_str(fw_freewili_device_t* device, fw_stringtype_t type,
char* buffer, uint32_t buffer_size);
fw_error_t fw_usb_device_get_int(fw_freewili_device_t* device, fw_inttype_t type,
uint32_t* value);
// Memory management
fw_error_t fw_device_free(fw_freewili_device_t** devices, uint32_t count);
Examples
Complete example applications are provided in the examples/ directory:
basic_usage.cpp- Modern C++ API demonstrationc_api_basic_usage.cpp- C API demonstration (compiled as C++)c_api_basic_usage_pure_c.c- Pure C implementation
Build and run examples:
cd build
make basic_usage_cpp basic_usage_c
./examples/basic_usage_cpp
./examples/basic_usage_c
Project Structure
freewili-finder/
├── include/
│ ├── fwfinder.hpp # Main C++ API header
│ └── usbdef.hpp # USB device definitions
├── src/
│ ├── fwfinder.cpp # Core implementation
│ ├── fwfinder_linux.cpp # Linux-specific code
│ ├── fwfinder_mac.cpp # macOS-specific code
│ ├── fwfinder_windows.cpp # Windows-specific code
│ └── usbdef.cpp # USB device type mappings
├── c_api/
│ ├── include/cfwfinder.h # C API header
│ ├── src/cfwfinder.cpp # C API implementation
│ └── test/ # C API tests
├── test/ # C++ API tests
├── examples/ # Example applications
└── bindings/ # Language bindings (Python, etc.)
Testing
The library includes comprehensive tests using GoogleTest:
cd build
ctest --output-on-failure
Tests cover:
- Device discovery functionality
- USB device type detection
- C API functionality
- Cross-platform compatibility
- Error handling scenarios
Platform Support
| Platform | Status | Requirements |
|---|---|---|
| Linux | ✅ Supported | libudev |
| macOS | ✅ Supported | IOKit framework |
| Windows | ✅ Supported | Windows SDK (SetupAPI, Cfgmgr32) |
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please ensure all tests pass and add tests for new functionality.
License
Copyright Free-Wili
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyfwfinder-0.4.2-cp312-abi3-win_amd64.whl.
File metadata
- Download URL: pyfwfinder-0.4.2-cp312-abi3-win_amd64.whl
- Upload date:
- Size: 150.1 kB
- Tags: CPython 3.12+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e162b733db3b86b15e33f0cca2ae0b3f286ece800e85bf540fa0086d3280ee0
|
|
| MD5 |
c200ca8ec0ebf14acd03ab83bd3b5076
|
|
| BLAKE2b-256 |
fbafdf4c3501e57ac20dd14ca99cccc4dfa88ebe49027d29fcf33a3be3280867
|
File details
Details for the file pyfwfinder-0.4.2-cp312-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: pyfwfinder-0.4.2-cp312-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 246.5 kB
- Tags: CPython 3.12+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b740732b279cc97851c3a437a6d08ac5193cc9fb189686611ea66e29b33fd7e
|
|
| MD5 |
76d8ac8e7a9816abc4f5bcf93c17ac03
|
|
| BLAKE2b-256 |
4146e6e74e3ff2b13b2e4bb7aeafcde98d041534a285ea4166d25e5a5d796d6b
|
File details
Details for the file pyfwfinder-0.4.2-cp312-abi3-macosx_10_15_universal2.whl.
File metadata
- Download URL: pyfwfinder-0.4.2-cp312-abi3-macosx_10_15_universal2.whl
- Upload date:
- Size: 180.3 kB
- Tags: CPython 3.12+, macOS 10.15+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d68656cc9ea92b59322251b004772ba2d29444b06ccb2b01fcb9e6d042b40148
|
|
| MD5 |
91bdc80e76ed3a5482251964a2b0b903
|
|
| BLAKE2b-256 |
17547882d0f0ceb8be66a06220ea3e3ddd22ee0cdf69b49679ef264310d33f0d
|
File details
Details for the file pyfwfinder-0.4.2-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: pyfwfinder-0.4.2-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 151.4 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26f2ce1c6fea4b8202a7e5b9c26fb2a52b9b511b4c43cb16de80331113459bec
|
|
| MD5 |
32c5379671020d6189f5fd96290347ae
|
|
| BLAKE2b-256 |
9192582720aa9d8f5347640b1d3ac0af8b4bdf59b3feb4797aaed4dac1d0f5a8
|
File details
Details for the file pyfwfinder-0.4.2-cp311-cp311-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: pyfwfinder-0.4.2-cp311-cp311-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 250.8 kB
- Tags: CPython 3.11, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
271d51df2593b05e01342b15073c41c720b475d3e0b4e6bde21f6a54af90de8d
|
|
| MD5 |
fbb381aa08c4481acd407307a10b5aa9
|
|
| BLAKE2b-256 |
2cd351a4d3bcbaabd1ce234c07ac54267bd9556c0d01f87729ab8a3bcec06394
|
File details
Details for the file pyfwfinder-0.4.2-cp311-cp311-macosx_10_15_universal2.whl.
File metadata
- Download URL: pyfwfinder-0.4.2-cp311-cp311-macosx_10_15_universal2.whl
- Upload date:
- Size: 187.2 kB
- Tags: CPython 3.11, macOS 10.15+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
874dd65a1517ce08ff3de4cd844a9160dd4404ad8a6cd91378bb8dc836de4412
|
|
| MD5 |
6cee3bf9b8319c6559c0b3b5a4bfad45
|
|
| BLAKE2b-256 |
ea79a3feeafded27162378f89f36e7cda609f39623a704007b49eb7de7ce1a77
|
File details
Details for the file pyfwfinder-0.4.2-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: pyfwfinder-0.4.2-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 151.0 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62939ddbacd27267e0a95c68f4522d944b3effaae7f1728049b50464f8e89195
|
|
| MD5 |
855dc563b4399c8f509c9722d4c628f7
|
|
| BLAKE2b-256 |
4f75676a98d83d2b475bd29bf20be4319f0088755370eb505d10ed9adc2687df
|
File details
Details for the file pyfwfinder-0.4.2-cp310-cp310-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: pyfwfinder-0.4.2-cp310-cp310-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 250.5 kB
- Tags: CPython 3.10, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f442ffad74c57d41108ba65cc997de509dcabb700c717825b36c7dc8ab4ef810
|
|
| MD5 |
adb11705802fbed65174479468299620
|
|
| BLAKE2b-256 |
82556cbc187ed19c2f4e17baf6f54fc54fd76999119e19662fda44d7131e940e
|
File details
Details for the file pyfwfinder-0.4.2-cp310-cp310-macosx_10_15_universal2.whl.
File metadata
- Download URL: pyfwfinder-0.4.2-cp310-cp310-macosx_10_15_universal2.whl
- Upload date:
- Size: 186.3 kB
- Tags: CPython 3.10, macOS 10.15+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c8fdcb66ee281b658e1ac7a36e947e65bd639663e345dba69a61d64818aa911
|
|
| MD5 |
9234abc2a1dc57d4ac368e93b875617c
|
|
| BLAKE2b-256 |
fc07f65f3c7b97b8a04227991c1e392fe88dde8721949f71422eac13611635b8
|
File details
Details for the file pyfwfinder-0.4.2-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: pyfwfinder-0.4.2-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 151.4 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a10c0525645b62bcd1759c8f75872869e294a30f79fcb40a9c17d2270d1ab6c7
|
|
| MD5 |
2158b16737597b2637bca040d684b307
|
|
| BLAKE2b-256 |
9569d89c215b86b644422f0f72901e314b214f4c58e62e1c34769f297879e6c5
|
File details
Details for the file pyfwfinder-0.4.2-cp39-cp39-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: pyfwfinder-0.4.2-cp39-cp39-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 250.7 kB
- Tags: CPython 3.9, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a27040ecd1034a994a7c82f5808b465fb36dc89ad3851637df1c81c1a780f23
|
|
| MD5 |
f6d03608110c7c59767939656f8cd985
|
|
| BLAKE2b-256 |
84cc547284ae146010729d9615bacc46e6de6947fe7ab1093c340555e62d93c1
|
File details
Details for the file pyfwfinder-0.4.2-cp39-cp39-macosx_10_15_universal2.whl.
File metadata
- Download URL: pyfwfinder-0.4.2-cp39-cp39-macosx_10_15_universal2.whl
- Upload date:
- Size: 186.8 kB
- Tags: CPython 3.9, macOS 10.15+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89afe6f163181063138a35b09ca9179a27d0c1f9e6259fe719da6d3aa3c988ba
|
|
| MD5 |
8693f5a1fd5786787b8eb8b1ed25c99a
|
|
| BLAKE2b-256 |
110f70d5d7d1d48b62467c5b1967b3fc2f9a90861a0a1a470c07b263e6469610
|
File details
Details for the file pyfwfinder-0.4.2-cp38-cp38-win_amd64.whl.
File metadata
- Download URL: pyfwfinder-0.4.2-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 150.7 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcff8952d5a29d4fec688234d6be4202dc5c589204a121d48b147bf28fb8fd4b
|
|
| MD5 |
a7a8d3b7fb68d0a286a58f2f2c3b0c01
|
|
| BLAKE2b-256 |
2052c550ff81fb9651fc30d5507c906ca62535443ab532800bc713fd2d8471df
|
File details
Details for the file pyfwfinder-0.4.2-cp38-cp38-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: pyfwfinder-0.4.2-cp38-cp38-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 249.5 kB
- Tags: CPython 3.8, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ad08ae50ddbef74a10325901a667d08989e8dbf9ba37cbd2d21e48dbd42c186
|
|
| MD5 |
ec37bf898eeffd7ac59b25964c8c466b
|
|
| BLAKE2b-256 |
9e09c302e140b8e1a5c9aa58829a7965daac771afe11e7a226c8a634f4c70e2e
|
File details
Details for the file pyfwfinder-0.4.2-cp38-cp38-macosx_10_15_universal2.whl.
File metadata
- Download URL: pyfwfinder-0.4.2-cp38-cp38-macosx_10_15_universal2.whl
- Upload date:
- Size: 184.4 kB
- Tags: CPython 3.8, macOS 10.15+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50ab121fd21b1b5588ef3a446a7dd19d7e597b21b23736beb562015e4f708e0d
|
|
| MD5 |
706c2a6f50849b41006cfde84ebd80fa
|
|
| BLAKE2b-256 |
cd31f5ac880455c3cc8bf53271efcfe1284c5a2ded9b74e91e2b010cff4851a7
|