# eDNC Special Character Fix Real-time file watcher that automatically removes invalid special characters from DNC (Direct Numerical Control) program files. ## Problem Some legacy DNC systems and communication protocols add padding or termination bytes that modern CNC controllers cannot process correctly. Common problematic characters include: | Byte | Hex | Name | Description | |------|-----|------|-------------| | 255 | 0xFF | Fill | Padding/fill character | | 0 | 0x00 | NULL | Null character | | 26 | 0x1A | SUB | Ctrl+Z / EOF marker | | 127 | 0x7F | DEL | Delete character | ## Solution This utility monitors a folder for DNC files and automatically strips specified characters as soon as files are created or modified. ## Installation 1. Copy the project folder to `C:\eDNC-Fix\` on the DNC workstation 2. Run `Install-ScheduledTask.ps1` as Administrator ``` C:\eDNC-Fix\ ├── eDNC-SpecialCharFix.ps1 ├── Run-eDNCFix.bat ├── Install-ScheduledTask.ps1 └── README.md ``` ### Install as Scheduled Task (Recommended) ```powershell # Run as Administrator C:\eDNC-Fix\Install-ScheduledTask.ps1 # To remove C:\eDNC-Fix\Install-ScheduledTask.ps1 -Uninstall ``` The scheduled task: - Starts at system boot (before any user logs in) - Runs as SYSTEM with highest privileges - Auto-restarts if it crashes - Watches `C:\Dnc_Files\Q` for `*.pun` files ### Run Manually (Alternative) Double-click `Run-eDNCFix.bat` - it will auto-elevate to Administrator via UAC. ## Configuration Default settings (edit `eDNC-SpecialCharFix.ps1` to change): | Setting | Default | Description | |---------|---------|-------------| | WatchFolder | `C:\Dnc_Files\Q` | Folder to monitor | | FileFilter | `*.pun` | File pattern to watch | | IncludeSubfolders | `$true` | Watch subdirectories | | CharactersToRemove | `@(255)` | Byte values to strip (0xFF) | ## Output The script displays real-time activity: ``` ======================================== eDNC Special Character Fix v1.0.0 ======================================== Configuration: Watch Folder: C:\Dnc_Files\Q File Filter: *.pun Subfolders: True Removing bytes: 255 (0xFF) Watching for files... Press Ctrl+C to stop 2025-12-12 08:30:15 | Created | PART001.pun [CLEANED] Removed 3 byte(s) 2025-12-12 08:30:22 | Changed | PART002.pun [OK] No special characters found ``` ## Requirements - Windows PowerShell 5.1 or later - Read/Write access to the watch folder ## Troubleshooting ### "Watch folder does not exist" Create the folder or specify a different path with `-WatchFolder`. ### "File locked" errors (v1.0.0) If using v1.0.0, update to v1.1.0 for improved file locking handling with exponential backoff and stability checks. ### Script doesn't detect files - Verify the file extension matches `-FileFilter` - Check that `-IncludeSubfolders` is set correctly - Ensure the script has permissions to the folder ### "[WAIT] File still being written..." This is normal behavior. The script waits for the file size to stabilize before processing, which means eDNC is still transferring the file. The script will automatically process it once the transfer completes. ### "[RETRY] File locked..." The script uses exponential backoff (500ms → 1s → 2s → 4s → up to 16s) for up to 10 attempts. If you see `[FAILED]` messages, eDNC may be holding the file longer than expected. ## Version History | Version | Date | Changes | |---------|------|---------| | 1.3.1 | 2025-12-12 | Added Install-ScheduledTask.ps1 for running as SYSTEM service | | 1.3.0 | 2025-12-12 | Fixed header UI, live status/stats, auto-elevate to Administrator | | 1.2.1 | 2025-12-12 | Added GE Aerospace ASCII banner | | 1.2.0 | 2025-12-12 | Immediate processing: 50ms delay, aggressive retry (100ms+), 15 attempts | | 1.1.0 | 2025-12-12 | Improved file locking: stability check, exponential backoff, debouncing | | 1.0.0 | 2025-12-12 | Initial release | ## Author GE Aerospace - Rutland