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

UnicodeDecodeError when running in controller mode #70

Closed
jwacalex opened this issue Nov 20, 2024 · 5 comments
Closed

UnicodeDecodeError when running in controller mode #70

jwacalex opened this issue Nov 20, 2024 · 5 comments

Comments

@jwacalex
Copy link

Error

When I'm trying to use the integration to run in controller mode and broadcast values to more than one ArtNet Interface, an UnicodeDecodeError appears: UnicodeDecodeError: 'ascii' codec can't decode byte 0x8e in position 37: ordinal not in range(128)

Configuration

The relevant configuration

- platform: artnet_led
  host: 10.11.12.200
  max_fps: 30
  refresh_every: 1
  node_type: artnet-controller

OS Version: Home Assistant OS 13.2
Home Assistant Core: 2024.11.2

Logs

DEBUG (MainThread) [custom_components.artnet_led.client.artnet_server] Sending ArtPoll
DEBUG (MainThread) [custom_components.artnet_led.client.artnet_server] Sleeping a few seconds before polling again...
DEBUG (MainThread) [custom_components.artnet_led.client.artnet_server] Received ArtPoll from 192.168.3.5
DEBUG (MainThread) [custom_components.artnet_led.client.artnet_server] Ignoring ArtPoll as it came from ourselves
DEBUG (MainThread) [custom_components.artnet_led.client.artnet_server] Received ArtPollReply from LedPixelStrip140
DEBUG (MainThread) [custom_components.artnet_led.client.artnet_server]   0001 [0001] -artnet
DEBUG (MainThread) [custom_components.artnet_led.client.artnet_server] Existing node checking in 10.11.12.80@0 with 0:1:[10,11,12,13,14,15]
DEBUG (MainThread) [custom_components.artnet_led.client.artnet_server] Addresses of the node at 10.11.12.80@0:
 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _SelectorDatagramTransport._read_ready() (None)
    self.handle_datagram(addr, data)
  File "/config/custom_components/artnet_led/client/artnet_server.py", line 389, in handle_datagram
    reply.deserialize(data)
  File "/config/custom_components/artnet_led/client/__init__.py", line 773, in deserialize
    self.long_name, index = self._consume_str(packet, index, 64)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/artnet_led/client/__init__.py", line 453, in _consume_str
    str_bytes = str(packet[index:index + length - 1], "ASCII")
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8e in position 37: ordinal not in range(128)
@Breina
Copy link
Owner

Breina commented Nov 20, 2024

Interesting!

So the integration shouts around to find anyone, and your controller replies. One of the fields of this reply is this field:

image

The spec didn't specify which encoding it uses, so I assumed ASCII, since that was used elsewhere as well. But your device name has a byte (0x8E) that is outside the range of ASCII (max 0x7F).

This can mean two things.

  • Your device uses one of the many extended-ASCII codetables
  • Your device uses UTF-8

It might be that there's an unwritten standard in the ArtNet community. Can you please use The Artnetnominator to figure out the full name of your device? From the 37th character, I can deduce the encoding.

https://www.lightjams.com/artnetominator/

Might also be interesting if you can post the device model and manufacturer, so that I can ask them what encoding they're using.

@jwacalex
Copy link
Author

I'll dump the ArtNet names later, maybe there should be some try/catch statements to prevent an exception.

the affected device: Stairville Pixel Rail Drive 640R

@Breina
Copy link
Owner

Breina commented Nov 20, 2024

Yeah it's definitely an oversight on my end. Try/except (= python equivalent) would have prevented this. If it's going to be Unicode, then I'll add exception handling.

I've sent an email to Artistic license and Stairville to shed some light on this.

@jwacalex
Copy link
Author

I'll prepare a pull request for the exception handling. if you need any further information/data let me know

@jwacalex jwacalex changed the title UnicodeDecodeError when running in controller Mode UnicodeDecodeError when running in controller mode Nov 20, 2024
@jwacalex
Copy link
Author

jwacalex commented Nov 20, 2024

The interesting part is, that the string should be the following ascii output NetWork Node 2(42:4C:84:66:EE:F8). this is shown while scanning the universes via dmxworkshop

I've extracted the offending string in hexadecimal representation from the warning message introduced in #71: 4e6574576f726b204e6f646520322834323a34433a38343a36363a45453a463829002e00708eb00201002300426f6f74204d6f64653a20426f6f746564206600

this string contains the same output but also some control characters leaking from a boot sequence?: NetWork Node 2(42:4C:84:66:EE:F8) NUL *. NUL p?? SYN LF NUL # NUL Boot Mode: Booted f

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

No branches or pull requests

2 participants