Skip to content
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

IEP-1037: Fix for the confserver handling of the hex values #859

Merged
merged 2 commits into from
Dec 6, 2023

Conversation

alirana01
Copy link
Collaborator

@alirana01 alirana01 commented Nov 23, 2023

Description

Fixed the conf server so hex values are shown properly and are handled gracefully as hex values
Original reported issue that can be used for testing is here

Fixes # (IEP-1037)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How has this been tested?

Open the sdkconfig and try to see the hex value properties like Partition Table -> Offset of partition table. It should be shown in Hex format and any change must be saved and reflected once you close and open the sdkconfig editor.
Please see that other hex properties are also safely saved as well. You can verify the changed value in menuconfig via terminal to see that correct hex is stored

Test Configuration:

  • ESP-IDF Version: any
  • OS (Windows,Linux and macOS): any

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Verified on all platforms - Windows,Linux and macOS

Summary by CodeRabbit

  • New Features

    • Configuration values can now be displayed and entered as hexadecimal strings.
  • Enhancements

    • Labels for hexadecimal configuration items now include "(hex)" to indicate the expected value format.
    • Input fields automatically detect and parse hexadecimal values prefixed with "0x".
  • Bug Fixes

    • Fixed an issue where hexadecimal values were not correctly displayed in the configuration editor.

@alirana01 alirana01 self-assigned this Nov 23, 2023
Copy link

coderabbitai bot commented Nov 23, 2023

Walkthrough

The Java codebase for the SDK Configuration Editor has been updated to improve the handling of hexadecimal values. The changes include displaying long values as hexadecimal strings, modifying UI labels to indicate hexadecimal input, and parsing user input as hexadecimal where appropriate. This enhances the user experience for configurations that require hexadecimal notation.

Changes

File Path Change Summary
.../sdk/config/ui/SDKConfigurationEditor.java Updated UI labels to indicate "(hex)" for hexadecimal types, converted long values to hexadecimal strings for display, and modified input handling to parse hexadecimal values.

Poem

As autumn leaves 🍂 gently fall,
Our code now reads hex, one and all.
With "0x" prefixed, clear and bright,
The editor gleams in the coder's night. 🌙✨


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link
Collaborator Author

@alirana01 alirana01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self Review

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1e1cb7e and eba79ef.
Files selected for processing (1)
  • bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/SDKConfigurationEditor.java (2 hunks)
Additional comments: 1
bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/SDKConfigurationEditor.java (1)
  • 635-642: The code correctly formats the hexadecimal value with the "0x" prefix and converts it to uppercase. However, it assumes that newConfigValue and configValue are of type Long. If they are not, a ClassCastException could occur. Ensure that the values are indeed Long before casting, or handle the potential exception.

Copy link
Collaborator

@sigmaaa sigmaaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between eba79ef and 4ea5121.
Files selected for processing (1)
  • bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/SDKConfigurationEditor.java (3 hunks)
Additional comments: 1
bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/SDKConfigurationEditor.java (1)
  • 853-860: The previous comment about wrapping the Long.parseLong call in a try-catch block to handle NumberFormatException is still valid. The code should be updated to handle this exception gracefully.
- modifiedJsonMap.put(configKey, isHex ? Long.parseLong(text.substring(2), 16) : textControl.getText().trim());
+ try {
+     modifiedJsonMap.put(configKey, isHex ? Long.parseLong(text.substring(2), 16) : textControl.getText().trim());
+ } catch (NumberFormatException ex) {
+     // Handle invalid hex number input
+     // For example, show an error message to the user or log the error
+ }

Copy link
Collaborator

@kolipakakondal kolipakakondal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AndriiFilippov
Copy link
Collaborator

@alirana01 hi !

Tested under:
OS - Windows 10 / Linux Ubuntu 20.04
ESP-IDF: v5.1.2

After build I do I see a match in the sdk files

LGTM 👍
image
image

@kolipakakondal kolipakakondal merged commit b929cf1 into master Dec 6, 2023
4 of 6 checks passed
@kolipakakondal kolipakakondal deleted the IEP-1037 branch December 6, 2023 11:43
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.

4 participants