wpilibsuite / WPILibPi

WPILib Raspberry Pi images designed for FRC (formerly FRCVision)
Other
87 stars 40 forks source link

Troubles grabbing settings file #99

Closed schelcc closed 5 years ago

schelcc commented 5 years ago

I have the newest available image for frcvision

When I attempt to upload your code I get the following error:

Traceback (most recent call last):

  File "./uploaded.py", line 684, in <module>

    if not readConfig():

  File "./uploaded.py", line 631, in readConfig

    j = json.load(f)

  File "/usr/lib/python3.5/json/__init__.py", line 265, in load

    return loads(fp.read(),

  File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode

    return codecs.ascii_decode(input, self.errors)[0]

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 174: ordinal not in range(128)

Waiting 5 seconds...

I attempted to comment that section out, to no avail.

This error occurs anytime I try to execute anything via the web dashboard. The pi was re-imaged today, so I doubt it's that.

PeterJohnson commented 5 years ago

Can you grab the /boot/frc.json file from the Pi and upload it as an attachment here? That file is a text file and shouldn't have any binary data in it.

schelcc commented 5 years ago

Github won't let me upload a .json, so here is it pasted:

{
    "cameras": [
        {
            "name": "",
            "path": "/dev/v4l/by-id/usb-Microsoft_Microsoft®_LifeCam_HD-3000-video-index0",
            "pixel format": null,
            "stream": {
                "properties": []
            }
        }
    ],
    "ntmode": "client",
    "team": 3656
}

I just updated this with the proper boot/frc.json, I think the problem is the '®' but thats part of the url, and removing that makes the path useless.

schelcc commented 5 years ago

That is the root of the problem. My issue now is that I can't get the camera without that address.

PeterJohnson commented 5 years ago

Agreed there's a bug here but the workaround is straightforward. You can get the camera without that address. If you only have one camera, it will always be /dev/video0. The path you've set up is only necessary to disambiguate cameras when you have more than one.

PeterJohnson commented 5 years ago

Actually there's an easy fix that should let you keep doing what you're doing. See https://stackoverflow.com/questions/35051867/json-load-function-give-strange-unicodedecodeerror-ascii-codec-cant-decod Add a 3rd parameter to the open() line on line 94 or so, encoding='utf-8'. I'll PR a fix.

schelcc commented 5 years ago

That fixed it and it works perfectly now, I'm going to close it.