Skip to content

added gitignore, encoder command functionality and enhanced error handling #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 18, 2025

Conversation

hastgt
Copy link
Contributor

@hastgt hastgt commented Oct 30, 2024

  • Implemented encoder (knob) command functionality, as outlined in original comments:
    • Switched to encoder bank (IEN) before sending command, and back to key bank (ISW) after
    • Added prompt for user input with validation for difference values (range -32 to 31), converting input to two's complement byte
    • Constructed byte array in the required format <0x44, 'encoder id', 'ticks'> and added delay for reliable command processing.
    • Enhanced error handling for input errors and exceptions

- NOTE: Implementation is untested on actual BKM-10r hardware

Additional Improvements:

  • Consistent Indentation: Adjusted indentation style to 4 spaces across the main script
  • Exception Handling in connect Method: Added specific handling with Exception as e to provide detailed error messages on connection failure
  • Channel Name Update: Validated channel number input in updateChannelName, ensuring values are between 0-9 to improve error handling
  • Error Handling for Unsupported Characters in writeText: Added try-except to catch unsupported characters in writeText, notifying the user accordingly
  • Enhanced User Prompts in sendCommand: Included range validation and detailed error messages for encoder inputs in sendCommand
  • Command Output Logging: Logs the current command list for debugging purposes in sendCommand
  • Command Listing in Main Loop: Main loop now includes a help command listing all available commands, a feature missing in EmuBKM-10r.py
  • Default COM Port Handling in Main: Improved default COM port handling with bkm = EmuBKM10r('COM9'), whereas EmuBKM-10r.py lacked explicit handling

…dling

- Implemented encoder (knob) command functionality, as outlined in original comments:
    - Switched to encoder bank (IEN) before sending command, and back to key bank (ISW) after
    - Added prompt for user input with validation for difference values (range -32 to 31), converting input to two's complement byte
    - Constructed byte array in the required format <0x44, 'encoder id', 'ticks'> and added delay for reliable command processing.
    - Enhanced error handling for input errors and exceptions

- NOTE: Implementation is untested on actual BKM-10r hardware

Additional Improvements:
- **Consistent Indentation**: Adjusted indentation style to 4 spaces across the main script
- **Exception Handling in `connect` Method**: Added specific handling with `Exception as e` to provide detailed error messages on connection failure
- **Channel Name Update**: Validated channel number input in `updateChannelName`, ensuring values are between 0-9 to improve error handling
- **Error Handling for Unsupported Characters in `writeText`**: Added `try-except` to catch unsupported characters in `writeText`, notifying the user accordingly
- **Enhanced User Prompts in `sendCommand`**: Included range validation and detailed error messages for encoder inputs in `sendCommand`
- **Command Output Logging**: Logs the current command list for debugging purposes in `sendCommand`
- **Command Listing in Main Loop**: Main loop now includes a `help` command listing all available commands, a feature missing in `EmuBKM-10r.py`
- **Default COM Port Handling in Main**: Improved default COM port handling with `bkm = EmuBKM10r('COM9')`, whereas `EmuBKM-10r.py` lacked explicit handling
@hastgt
Copy link
Contributor Author

hastgt commented Oct 30, 2024

I'm not sure when I'll be able to test the knobs, but it would be extremely helpful if you could check whether they're working correctly and merge it into the main branch

@144a
Copy link
Owner

144a commented Oct 30, 2024

I'm not sure when I'll be able to test the knobs, but it would be extremely helpful if you could check whether they're working correctly and merge it into the main branch

I can definitely check functionality to ensure it works as intended! Thanks again for taking a look at this and improving it! Ill update here with the results before I merge this.

@144a 144a closed this Oct 30, 2024
@144a 144a reopened this Oct 30, 2024
+ added overflow check for tick_value to ensure it stays within the allowed range
+ converted tick_value to a signed byte format for correct protocol compliance
+ added debug logs to show the tick_value and final command bytes being sent
@144a 144a merged commit e722e02 into 144a:main Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants