haklein / certabo-playground

Scripts, tools, and helpers for the CERTABO usb chess boards
10 stars 5 forks source link

Error message in ubunto #3

Open as0770 opened 4 years ago

as0770 commented 4 years ago

Just found your Python adapter, many thanks for this! Unfortunately I didn't get it to work:

~/Programme/ChessEngines/CertaboUCI/certabo-uci$ python certabo-uci.py File "certabo-uci.py", line 115 logging.info(f'Auto-detecting serial port') ^ SyntaxError: invalid syntax

Any idea?

haklein commented 4 years ago

You need to run it with python3.

as0770 commented 4 years ago

Is there any description about how to use the adapter I missed?

~/Programme/ChessEngines/CertaboUCI/certabo-uci$ python3 certabo-uci.py
Traceback (most recent call last):
  File "certabo-uci.py", line 22, in <module>
    import serial
ModuleNotFoundError: No module named 'serial'
~/Programme/ChessEngines/CertaboUCI/certabo-uci$ python3 constants.py
Traceback (most recent call last):
  File "constants.py", line 3, in <module>
    import appdirs
ModuleNotFoundError: No module named 'appdirs'
~/Programme/ChessEngines/CertaboUCI/certabo-uci$ python3 utils.py
Traceback (most recent call last):
  File "utils.py", line 4, in <module>
    import serial
ModuleNotFoundError: No module named 'serial'
~/Programme/ChessEngines/CertaboUCI/certabo-uci$ python3 codes.py
Traceback (most recent call last):
  File "codes.py", line 4, in <module>
    import chess
ModuleNotFoundError: No module named 'chess'
haklein commented 4 years ago

It has the same python requirements as the original CERTABO software. You might need to install:

pyserial>=3.4
python-chess==0.24.1
appdirs
haklein commented 4 years ago

After I've polished up certabo-lichess, I'll rework this UCI script to use my new certabo module, also add a requirements.txt for easier installation, and improve the docs

as0770 commented 4 years ago

Now the software is running, but still I can't get it to work.

I tried the calibration process with Arena, Cute Chess and in console. The software creates a folder called __pycache__, but after "setoption name Calibrate value true" there is no response from the software or the board. Here is what I get with the console.

~/Programme/ChessEngines/CertaboUCI/certabo-uci$ python3 certabo-uci.py uci id name CERTABO physical board id author Harald Klein (based on work from Thomas Ahle & Contributors) option name Calibrate type check default false option name AddPiece type check default false option name Rotate type check default false option name Port type string default auto uciok setoption name Calibrate value true isready quit ~/Programme/ChessEngines/CertaboUCI/certabo-uci$ python3 certabo-uci.py uci id name CERTABO physical board id author Harald Klein (based on work from Thomas Ahle & Contributors) option name Calibrate type check default false option name AddPiece type check default false option name Rotate type check default false option name Port type string default auto uciok isready readyok setoption name Calibrate value true isready`

And in Arena:

2020-03-22 15:37:59.253<--1:-- starting engine[slotnr].EngineProcess -- 2020-03-22 15:37:59.254<--1:-- engine[slotnr].EngineProcess.Running ---1 2020-03-22 15:37:59.258-->1:uci 2020-03-22 15:37:59.408<--1:id name CERTABO physical board 2020-03-22 15:37:59.408<--1:id author Harald Klein (based on work from Thomas Ahle & Contributors) 2020-03-22 15:37:59.408<--1:option name Calibrate type check default false 2020-03-22 15:37:59.408<--1:option name AddPiece type check default false 2020-03-22 15:37:59.408<--1:option name Rotate type check default false 2020-03-22 15:37:59.408<--1:option name Port type string default auto 2020-03-22 15:37:59.408<--1:uciok 2020-03-22 15:37:59.415-->1:isready 2020-03-22 15:38:01.425<--1:readyok 2020-03-22 15:38:01.528-->1:isready 2020-03-22 15:38:01.530<--1:readyok 2020-03-22 15:38:01.538-->1:ucinewgame 2020-03-22 15:38:01.538-->1:isready 2020-03-22 15:38:01.540<--1:readyok 2020-03-22 15:38:01.545-->1:position startpos 2020-03-22 15:38:01.545-->1:go infinite 2020-03-22 15:38:06.115-->1:stop 2020-03-22 15:38:07.507-->1:setoption name Port value auto 2020-03-22 15:38:07.508-->1:setoption name Rotate value false 2020-03-22 15:38:07.508-->1:setoption name AddPiece value false 2020-03-22 15:38:07.508-->1:setoption name Calibrate value true 2020-03-22 15:38:20.939-->1:isready 2020-03-22 15:38:30.438-->1:stop

When I run it without "setoption name Calibrate value true" the software answers isready with readyok.

haklein commented 4 years ago

It should write a log file in your home directory, under ~/.local/share/GUI. Please attach that.

as0770 commented 4 years ago

I found the log file. Seems there is a problem finding the device path:

2020-03-22 14:35:30,285 INFO certabo-uci Auto-detecting serial port
2020-03-22 14:35:30,286 DEBUG utils Searching for port...
2020-03-22 14:35:30,301 DEBUG utils Trying /dev/ttyUSB0
2020-03-22 14:35:30,301 DEBUG utils Port is busy, continuing...
2020-03-22 14:35:30,301 DEBUG utils Port not found
2020-03-22 14:35:30,301 INFO certabo-uci No port found, retrying

I'll check that later when I got some time.

haklein commented 4 years ago

something apparently keeps /dev/ttyUSB0 busy..

as0770 commented 4 years ago

I can't see a problem:

lsusb

Bus 002 Device 002: ID 8087:8000 Intel Corp. 
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 005: ID 04f2:b474 Chicony Electronics Co., Ltd HD WebCam
Bus 003 Device 004: ID 06cb:2970 Synaptics, Inc. touchpad
Bus 003 Device 003: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Bus 003 Device 006: ID 0489:e092 Foxconn / Hon Hai 
Bus 003 Device 021: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP2102/CP2109 UART Bridge Controller [CP210x family]
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

lsusb -t

/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/14p, 480M
    |__ Port 1: Dev 21, If 0, Class=Vendor Specific Class, Driver=cp210x, 12M
    |__ Port 4: Dev 3, If 0, Class=Vendor Specific Class, Driver=rtsx_usb, 480M
    |__ Port 7: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 9: Dev 5, If 1, Class=Video, Driver=uvcvideo, 480M
    |__ Port 9: Dev 5, If 0, Class=Video, Driver=uvcvideo, 480M
    |__ Port 10: Dev 6, If 0, Class=Wireless, Driver=btusb, 12M
    |__ Port 10: Dev 6, If 1, Class=Wireless, Driver=btusb, 12M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M

udevadm monitor -u

monitor will print the received events for:
UDEV - the event which udev sends out after rule processing

UDEV  [3412.002646] add      /devices/pci0000:00/0000:00:14.0/usb3/3-1 (usb)
UDEV  [3412.008966] add      /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0 (usb)
UDEV  [3412.010388] add      /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/ttyUSB0 (usb-serial)
UDEV  [3412.015924] add      /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/ttyUSB0/tty/ttyUSB0 (tty)
UDEV  [3412.021767] bind     /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/ttyUSB0 (usb-serial)
UDEV  [3412.024289] bind     /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0 (usb)
UDEV  [3412.031162] bind     /devices/pci0000:00/0000:00:14.0/usb3/3-1 (usb)
UDEV  [3437.038896] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/ttyUSB0/tty/ttyUSB0 (tty)
UDEV  [3437.042807] unbind   /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/ttyUSB0 (usb-serial)
UDEV  [3437.043142] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/ttyUSB0 (usb-serial)
UDEV  [3437.044106] unbind   /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0 (usb)
UDEV  [3437.044853] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0 (usb)
UDEV  [3437.045925] unbind   /devices/pci0000:00/0000:00:14.0/usb3/3-1 (usb)
UDEV  [3437.046890] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-1 (usb)
haklein commented 4 years ago

Could you run fuser -a /dev/ttyUSB0, that would print any PIDs for processes accessing the device. You do have proper permissions, right? (probably the dialout group)

as0770 commented 4 years ago

Permissions... I got it to work by putting the files to the python directory. It didn't work from my home directory.

Thanks for your help and patience :-)

haklein commented 4 years ago

You're more than welcome!

as0770 commented 4 years ago

Suddenly the board didn't work again, /dev/ttyUSB diasppeared.

2020-05-13 08:59:39,405 DEBUG certabo-uci >>> isready 2020-05-13 08:59:39,405 INFO certabo-uci Auto-detecting serial port 2020-05-13 08:59:39,406 DEBUG utils Searching for port... 2020-05-13 08:59:39,406 INFO codes codes.py - loading calibration 2020-05-13 08:59:39,412 DEBUG utils Port not found

Then I had the clever idea to upgrade to ubuntu 20.04 LTS, and hoped the port will be visible again. The port is still missing and certabouci crashing:

Bildschirmfoto vom 2020-05-13 12-02-18

Is it a problem with python 3.8?

haklein commented 4 years ago

"No module named 'serial'" - that means that you don't have the python serial module installed for python3.

as0770 commented 4 years ago

I fixed the python requirements, cerabo-uci is running. But still /dev/ttyUSB is missing. $ fuser -a /dev/ttyUSB0 Angegebener Dateiname /dev/ttyUSB0 existiert nicht. /dev/ttyUSB0: I think it is a board issue, I will contact Certabo.

haklein commented 4 years ago

did you plug the magnetic usb connector in the right direction? The LED needs to be on the upper side. You can also remove the magnetic plug, and try a regular USB cable.

as0770 commented 4 years ago

It is working now, indeed a connection problem with the cable. Thanks again :-)

haklein commented 4 years ago

perfect! Enjoy!