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

Add support for CAN devices. #34

Merged
merged 8 commits into from
May 23, 2024
Merged

Add support for CAN devices. #34

merged 8 commits into from
May 23, 2024

Conversation

brettle
Copy link
Member

@brettle brettle commented May 22, 2024

No description provided.

@brettle brettle requested a review from CoolSpy3 May 22, 2024 05:19
@brettle
Copy link
Member Author

brettle commented May 22, 2024

Fyi, I'm already working on the making DeepBlueSim compatible with these changes, but this can be merged before that is finished because DeepBlueSim will continue to reference the current commit of WPIWebSockets until it is made compatible.


// Define the command line that npx should use
workingDir = buildDir // Because templateDir can't be under it
command = '@asyncapi/generator@1.17.25'
args = ['--force-write',
'-o', "${outputDir}/org/team199/wpiws/devices",
"https://raw.githubusercontent.com/wpilibsuite/allwpilib/master/simulation/halsim_ws_core/doc/wpilib-ws.yaml",
Copy link
Member

Choose a reason for hiding this comment

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

If we do go back to directly referencing the WPILib spec rather than the one here (see other comment), we should change this to point at a specific tag rather than master.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. Per my other comment, I'd like to do that as a separate PR.

wpilib-ws.yaml Outdated
Copy link
Member

@CoolSpy3 CoolSpy3 May 23, 2024

Choose a reason for hiding this comment

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

The original reason we PRed wpilib-ws.yaml to WPILib was so that it could be kept up-to-date with their project. Thus, if we wanted to add this support, it would probably make more sense to open a new PR to allwpilib to add the necessary info to the machine-readable spec. In order to do the aliasing, we could then (for example) do:

simDevice:
  type: object
    required:
    - type
    - device
    properties:
      type:
        const: SimDevice
      oneOf:
        - device:
            type: string
          data:
            type: object
            additionalProperties:
               type: string
         - device:
             type: string
             format: "CANMotor:.+" # If we actually do this we can make a better regex
           data:
                $ref: "#/schemas/aiData/properties/data"
         - ...etc

(I threw this together quickly, so we'd also have to validate the syntax)
We could then try to delete the extra SimDevice object with a generator hook. (I tried and failed to do this before, but hopefully, we can make it work :D )

Copy link
Member Author

Choose a reason for hiding this comment

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

With my latest commit, I've updated the local wpilib-ws.yaml to better address the aliasing. I'll open a wpilib PR to get the changes included there, but I don't see a good reason to wait. Even once the wpilib copy is updated, we should refer to a fixed version (as you mentioned above). But doing that won't change the actual contents of the yaml file that is used. It will just change it's source to better document intent. That can be as a future PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've created the wpilib PR.

brettle and others added 4 commits May 23, 2024 08:23
@brettle brettle merged commit 7e0a079 into master May 23, 2024
3 checks passed
@brettle brettle deleted the add-support-for-can-devices branch May 23, 2024 21:50
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