Closed
Conversation
ion098
requested changes
Feb 28, 2025
src/devices/vdml.cpp
Outdated
| using namespace zest::vdml; | ||
|
|
||
| // initialize the device mutex array | ||
| std::array<std::mutex, 32> device_mutexes; |
Contributor
There was a problem hiding this comment.
This can be constinit
Suggested change
| std::array<std::mutex, 32> device_mutexes; | |
| constinit std::array<std::mutex, 32> device_mutexes; |
src/devices/vdml.cpp
Outdated
| std::mutex& smart_port_mutex(int8_t port) { | ||
| port = abs(port); // prevent negative port | ||
|
|
||
| return device_mutexes[port]; |
Contributor
There was a problem hiding this comment.
Suggested change
| return device_mutexes[port]; | |
| return device_mutexes.at(port); |
In the future this should have error logging in the event of an out-of-range port.
src/devices/vdml.cpp
Outdated
|
|
||
| void initialize_vdml() { | ||
| // initialize the device (port) mutexes | ||
| for (int i = 0; i < MAX_DEVICE_PORTS; i++) |
Contributor
There was a problem hiding this comment.
This loop isn't needed with constinit (and the create_mutex function can be discarded as well)
| return device_mutexes[port]; | ||
| } | ||
|
|
||
| bool is_valid_port(uint8_t port) { |
Contributor
There was a problem hiding this comment.
Given that this function is so simple, it should be moved to the header and made an inline function.
|
|
||
| namespace zest { | ||
| namespace vdml { | ||
| enum class DeviceType { |
Contributor
There was a problem hiding this comment.
This enum should have a comment explaining that these values are based on VEXos (since they seem rather arbitrary right now)
This was referenced Mar 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Refactor the Current C VDML implementation, in favor of a much cleaner C++ implementation.
Motivation
Needed to create the hardware API for ZestCode, as the VDML ensures safe access of ports on a device between threads.
References (optional)
Closes #22
Blocked on #20
Implementation Details (optional)
Currently unknown
Test Plan:
@SizzinSeal should be able to hardware test the new VDML with the current device implementation from PROS.