This module provides the C implementation of USB log upload functionality, migrated from the original usbLogUpload.sh shell script. It enables transfer of system logs from embedded devices to external USB storage with compression and proper naming conventions.
The module follows a layered modular architecture:
-
Main Control Module (
usb_log_main.c/.h)- Application entry point and argument parsing
- High-level workflow orchestration
- Exit code management
-
Validation Module (
usb_log_validation.c/.h)- Device compatibility verification
- USB mount point validation
- Input parameter validation
-
File Manager Module (
usb_log_file_manager.c/.h)- Log file discovery and management
- Directory operations
- File movement and copying
-
Archive Manager Module (
usb_log_archive.c/.h)- Log file compression and archiving
- Archive naming convention implementation
- Compression error handling
-
Utility Module (
usb_log_utils.c/.h)- Common utility functions
- Logging and configuration management
- Error handling
- GCC compiler
- Autotools (autoconf, automake)
- Standard C library
# Using configure script
./configure
make
make install
# Or using direct Makefile
make all./configure --enable-debug
makeusblogupload <USB_mount_point>usblogupload /mnt/usb0: Success2: USB not mounted3: Writing error to USB4: Invalid usage or unsupported device
The module reads configuration from:
/etc/include.properties/etc/device.properties
DEVICE_NAME: Device type identifier (must be "TV")RDK_PATH: RDK library path (default:/lib/rdk)LOG_PATH: System log directory pathSYSLOG_NG_ENABLED: Syslog-ng service status
- Device Validation: Supports TV devices only
- Log Archival: Creates compressed
.tgzarchives - Naming Convention:
<MAC>_Logs_<timestamp>.tgz - Service Management: Reloads syslog-ng after log transfer
- Error Handling: Comprehensive error checking and reporting
# Build and run unit tests
make test
./bin/test_usbloguploadUnit tests use Google Test and Google Mock frameworks:
# Run GTest unit tests
cd unittest
make && ./run_testsusbLogUpload/
├── include/ # Header files
│ ├── usb_log_main.h
│ ├── usb_log_validation.h
│ ├── usb_log_file_manager.h
│ ├── usb_log_archive.h
│ └── usb_log_utils.h
├── src/ # Source files
│ ├── usb_log_main.c
│ ├── usb_log_validation.c
│ ├── usb_log_file_manager.c
│ ├── usb_log_archive.c
│ ├── usb_log_utils.c
│ └── test/ # Integration tests
│ └── test_main.c
├── unittest/ # Unit tests (GTest)
│ ├── usb_log_main_gtest.cpp
│ ├── usb_log_validation_gtest.cpp
│ └── usb_log_file_manager_gtest.cpp
├── docs/ # Documentation
│ ├── usb-log-upload-requirements.md
│ ├── usb-log-upload-hld.md
│ └── usb-log-upload-flowcharts.md
├── Makefile # Build configuration
├── Makefile.am # Automake configuration
├── configure.ac # Autoconf configuration
└── README.md # This file
- Follow embedded C coding standards
- Use static memory allocation where possible
- Minimize resource usage for embedded systems
- Include comprehensive error handling
- Document all public APIs
Licensed under the Apache License, Version 2.0. See the LICENSE file for details.
For issues and support, contact: support@rdkcentral.com