Skip to content

Conversation

LDaVeM
Copy link
Contributor

@LDaVeM LDaVeM commented Mar 10, 2025

Hi,

I added the ability to change the port (which remains 6454 by default) to something else on the server and the client.

I was able to test it on the client and it works well, but I haven't tested the server yet.

Summary by CodeRabbit

  • New Features
    • Enhanced network communication flexibility: Users can now specify a custom port during initialization, allowing for dynamic control over network configurations across client and server components.

Copy link
Contributor

coderabbitai bot commented Mar 10, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request refactors how network ports are handled in both the StupidArtnet client and server classes. The class-level constant UDP_PORT is removed and replaced with an instance variable port initialized via the constructor (default value 6454). All internal references, including string representations, socket communications, and socket bindings, now use this dynamic port value.

Changes

File(s) Change Summary
stupidArtnet/StupidArtnet.py
stupidArtnet/StupidArtnetServer.py
Removed class-level UDP_PORT constant. Added an instance variable port (default 6454) in the constructors. Updated method signatures (including __init__ and __str__) and modified all socket communication and binding to use the instance variable port instead of the constant.

Sequence Diagram(s)

sequenceDiagram
    participant User as Client/User
    participant Artnet as StupidArtnet
    participant Sock as Socket

    User->>Artnet: Instantiate with port (default=6454)
    Artnet->>Sock: Initialize socket using self.port
    Artnet->>Artnet: Use self.port in __str__, send_artsync, and show
Loading
sequenceDiagram
    participant Admin as Server Admin
    participant Server as StupidArtnetServer
    participant Sock as Socket

    Admin->>Server: Instantiate with port (default=6454)
    Server->>Sock: Bind socket using self.port
Loading

Poem

I'm a bunny in the code garden, so free,
Hopping through refactors with great agility.
No more fixed ports, they now dance anew,
With a dynamic port that flexibly grew.
I nibble on bytes with a joyful decree.
Carrots and code — a delicious harmony!


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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.

Actionable comments posted: 0

🧹 Nitpick comments (4)
stupidArtnet/StupidArtnetServer.py (2)

223-224: Consider adding port validation.

While the implementation is correct, there's no validation to ensure the port value is within the valid range (1-65535).

 def __init__(self, port=6454):
     """Initializes Art-Net server."""
+    if not 1 <= port <= 65535:
+        raise ValueError(f"Port must be between 1 and 65535, got {port}")
     self.port = port  # Use provided port or default
     # server active flag
     self.listen = True

223-224: Update the test example with the port parameter.

The test code at the bottom of the file doesn't demonstrate how to use the new port parameter.

 # Initilize server, this starts a server in the Art-Net port
-a = StupidArtnetServer()
+# Using default port 6454
+a = StupidArtnetServer()
+
+# Or using a custom port
+# custom_port = 7000
+# a = StupidArtnetServer(port=custom_port)
stupidArtnet/StupidArtnet.py (2)

375-375: Update the example usage with the port parameter.

The example usage at the bottom of the file doesn't demonstrate how to use the new port parameter.

-a = StupidArtnet(TARGET_IP, UNIVERSE_TO_SEND, PACKET_SIZE, artsync=True)
+# Using default port 6454
+a = StupidArtnet(TARGET_IP, UNIVERSE_TO_SEND, PACKET_SIZE, artsync=True)
+
+# Or using a custom port
+# custom_port = 7000
+# a = StupidArtnet(TARGET_IP, UNIVERSE_TO_SEND, PACKET_SIZE, artsync=True, port=custom_port)

21-21: Consider adding port validation.

While the implementation is correct, there's no validation to ensure the port value is within the valid range (1-65535).

 def __init__(self, target_ip='127.0.0.1', universe=0, packet_size=512, fps=30,
               even_packet_size=True, broadcast=False, source_address=None, artsync=False, port=6454):
     """Initializes Art-Net Client.
+    if not 1 <= port <= 65535:
+        raise ValueError(f"Port must be between 1 and 65535, got {port}")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ccb89de and 0bb08a3.

📒 Files selected for processing (2)
  • stupidArtnet/StupidArtnet.py (6 hunks)
  • stupidArtnet/StupidArtnetServer.py (2 hunks)
🔇 Additional comments (9)
stupidArtnet/StupidArtnetServer.py (2)

24-26: Function signature and property initialization look good.

The addition of an optional port parameter with default value 6454 is a good approach that maintains backward compatibility while offering flexibility for users who need to use alternative ports.


38-38: Socket binding updated correctly.

The socket binding now uses the instance-specific port value which aligns with the constructor changes.

stupidArtnet/StupidArtnet.py (7)

21-21: Function signature updated correctly.

The addition of the port parameter to the constructor with a default value of 6454 maintains backward compatibility.


32-32: Parameter documentation added.

Documentation for the new port parameter is properly added to the docstring.


49-49: Property initialization looks good.

The port property is properly initialized with the provided parameter value.


89-89: String representation updated correctly.

The string representation now uses the instance-specific port property.


166-166: Network operation updated correctly.

The send_artsync method now uses the instance-specific port value which aligns with the constructor changes.


177-177: Network operation updated correctly.

The show method now uses the instance-specific port value which aligns with the constructor changes.


21-33:

❓ Verification inconclusive

Verify that this works with existing Art-Net devices.

While the implementation allows for flexibility, it's important to verify that custom ports actually work with standard Art-Net equipment, as some might be hardcoded to only use port 6454.

Consider verifying this implementation against Art-Net specifications or testing with actual devices. You may also want to add a documentation note that standard Art-Net devices typically operate on port 6454, and changing this value may limit compatibility with certain hardware.


🌐 Web query:

Does Art-Net protocol allow using ports other than 6454?

💡 Result:

The Art-Net protocol primarily uses UDP port 6454 as its default for communication[1][3][5][6][8][12][16][18]. However, flexibility exists in some implementations:

Key Findings:

  1. Default Port:
    Art-Net's standard port is 6454 (hex 0x1936), widely adopted across controllers, nodes, and software (e.g., QLC+, ETC Eos, Tasmota)[1][2][6][12].

  2. Configurability:

    • Software Flexibility: Certain software tools like QLC+ and Lightjams allow users to override the default port in configuration settings[6][18]. For example, QLC+ enables custom port selection for Art-Net outputs via its plugin interface[6][8].
    • Unicast/Broadcast Modes: While the protocol itself specifies port 6454, network configurations (e.g., directed broadcast addresses like 2.255.255.255 or 10.255.255.255) can influence packet routing without altering the port[1][5][10].
  3. Hardware Limitations:
    Many Art-Net nodes and devices expect data on port 6454 by default. Deviating from this may require explicit configuration on both transmitter and receiver ends[11][16]. For instance, TouchDesigner users encountered issues until forcing the port to 6454 via workarounds[16].

  4. Protocol Specifications:
    Art-Net 3/4 documentation does not explicitly restrict port usage, implying the port is implementation-dependent. However, adherence to port 6454 ensures compatibility across devices[1][5][10][15].

Summary Table:

Aspect Details
Default Port 6454 (UDP)
Configurable Yes (in some software, e.g., QLC+, Lightjams)[6][18]
Node Compatibility Most devices expect port 6454 unless reconfigured[11][16]
Protocol Support Port flexibility depends on implementation, not protocol restrictions[5][10]

In practice, while the default port is strongly recommended for interoperability, some software implementations permit alternative ports, provided all network components (controllers, nodes) are reconfigured accordingly.

Citations:


Action: Confirm compatibility of custom port support with Art-Net devices

The code sets the port to 6454 by default, which is the recommended standard. However, as your implementation allows overriding the port, keep in mind that many Art-Net devices are configured to use port 6454. Please verify with your target hardware that non-default port configurations still work reliably. Additionally, consider updating the documentation to note that while custom ports are supported in some software, deviating from the default may limit interoperability with devices expecting port 6454.

  • The code snippet correctly defaults to port 6454.
  • Web references confirm that most Art-Net devices expect port 6454, although configurable alternatives exist.
  • It is advisable to test any non-default configurations and update the documentation accordingly.

@cpvalente cpvalente changed the base branch from master to release-preparations March 11, 2025 12:13
@cpvalente cpvalente merged commit eb399d1 into cpvalente:release-preparations Mar 12, 2025
3 checks passed
cpvalente pushed a commit that referenced this pull request Mar 12, 2025
…36)

* Modify UDP port

* added annotation and updated example
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