LinusCDE / chessmarkable

Chess for the reMarkable using the rust pleco lib
MIT License
104 stars 8 forks source link

unable to parse pgns file #18

Closed cyrenaique closed 2 years ago

cyrenaique commented 2 years ago

Hello, very nicely done except the parsing of simple pgns. I got: "couldn't parse any games from PGN"... I have access to the list of pgn files but whatever is pgn look like I got this. Remarkable 2. Best, Arno

rmadhwal commented 2 years ago

Heya, Could you point me to the PGN that's giving you trouble ? I experimented with a few different PGNs across the internet. Maybe there is a format that I didn't cater for.

cyrenaique commented 2 years ago
  1. e4 c6 2. Nf3 (2. d4 d5 3. e5 c5 4. dxc5 e6 (4... Nc6 5. Bb5 Bf5 (5... e6 6. Be3 Nge7 7. Nf3 Nf5 8. Bd4 (
  2. b4 a5 9. c3 Bd7 10. Qd3 axb4 11. Bxc6 Bxc6 12. cxb4) 8... Nfxd4 9. Nxd4 (9. Qxd4 Qa5+ 10. Nc3 Qxb5 11. Nxb5 Nxd4 12. Nbxd4 (12. Nc7+ Ke7 (12... Kd7) 13. Nxd4)) 9... Qc7 10. O-O) 6. c4 dxc4 7. Qa4 Bd7 8. Qxc4) 5. Be3 (5. b4 a5 6. c3 axb4 7. cxb4 b6 8. Be3 bxc5 9. bxc5 Nd7 10. Qc2 Bxc5 11. Bxc5 Qa5+) (5. Nf3 Bxc5) 5... Nh6 6. c3 (6. g4 Nc6 7. Bb5 Bd7 8. Bxc6 Bxc6) 6... Nf5 7. Bd4) 2... d5 3. Nc3 dxe4 (3... d4 $2 4. Ne2 c5 5. c3 dxc3 (5... d3 $2 6. Nf4 c4 7. Qa4+ $1 $18 ) 6. Nxc3 $16 (6. bxc3 Nf6 7. Ng3 Nc6 8. Bb5 Bd7 9. Rb1) 6... Nf6
  3. d4 cxd4 8. Qxd4 Qxd4 9. Nxd4 e5 10. Ndb5) (3... Bg4 4. h3 Bxf3 5. Qxf3 e6 6. d3 Nd7 7. Bd2 $11) 4. Nxe4 Bg4 (4... Bf5 5. Ng3 Bg6 6. h4 h6 7. Ne5 Bh7 8. Qh5 g6 9. Bc4 $1 e6 (9... gxh5 $4 10. Bxf7# $1) 10. Qe2 Menace Cf7 Rf7 De6 Rg7 Df7#}) (4... Nf6 5. Qe2 Nxe4 (5... Nbd7 6. Nd6#) 6. Qxe4 Nd7 7. Bc4 Nf6 8. Ne5 e6 9. Qe2 Be7 10. c3 O-O 11. d4 Nd5 12. O-O c5 13. Rd1) 5. h3 Bxf3 (5... Bh5 6. Ng3 Bg6 7. h4 h6 8. Ne5 Bh7) 6. Qxf3 Nd7 7. d4 e6 8. Be2 Ngf6 9. O-O Nxe4 10. Qxe4 Nf6 11. Qd3
cyrenaique commented 2 years ago

pgns are from chessbase, this one I edited it to remove evaluation and so on... I can attach a pgn from chessbase if you want changing the extension to txt I guess?

rmadhwal commented 2 years ago

hmm if you can attach the unedited file you're trying to parse that would be perfect, seems like the formatting is getting destroyed here

cyrenaique commented 2 years ago

Caro 2C_Crushed guy_2021.txt

cyrenaique commented 2 years ago

hoping it's fine, I just changed the extension to upload it

rmadhwal commented 2 years ago

I converted that file to a PGN extenstion and dropped it in and it works fine for me IMG_2554 IMG_2555 (1)

cyrenaique commented 2 years ago

yep I can see it on this page but when I click on the file it gives me the error.

On Thu, Dec 9, 2021, 12:36 AM Rohan Madhwal @.***> wrote:

I converted that file to a PGN extenstion and dropped it in and it works fine for me ![IMG_2555]( https://user-images.githubusercontent.com/14342304/145308108-8ece65fc-a033-4b8b [image: IMG_2554] https://user-images.githubusercontent.com/14342304/145308136-1623332a-377d-4b5f-92f1-a020f8f41fde.jpg -9e09-bedf44cb3372.jpg) .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/LinusCDE/chessmarkable/issues/18#issuecomment-989314248, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMF2UGH75SZ3QMXCO3JVEDUP7TZPANCNFSM5JUZ4BHQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

rmadhwal commented 2 years ago

can I confirm that you are inserting the pgn as below ? reMarkable: ~/.config/chessmarkable/pgn/ ls


Anand.pgn              Levon.pgn              Tal_Memorial_2016.pgn
Bareev.pgn             Nepo.pgn               Test.pgn
Giri.pgn               Polgar.pgn             Timman.pgn
Grischuk.pgn           Radjabov.pgn           Topalov.pgn
Kramnik.pgn            Shirov.pgn
cyrenaique commented 2 years ago

yes, i just copy the file on the directory via scp, sorry I didn't see the 2nde picture.. congrats! so I don't know... I will give a try again tomorrow. thanks again, I will let you know asap

rmadhwal commented 2 years ago

sure, seems to run fine for my remarkable 2 so I'm out of ideas unless you're maybe trying with a different file

LinusCDE commented 2 years ago

It should print the full error to the console. If you have a launcher you can probably get it with journalctl -eu <remux/tarnish>. Alternatively try to start chessmarkable manually with rm2fb-client chessmarkable and it should print it into the console. Maybe there is something like a nasty "\r" or other character hidden.

cyrenaique commented 2 years ago

I will try with exact same file to check. also can u read multiple games in the same pgn?

rmadhwal commented 2 years ago

yep, it will load all the games in the menu like the one you see in my screenshot above

cyrenaique commented 2 years ago

still the same... strange. 20211209_082902.jpg20211209_082851.jpg

cyrenaique commented 2 years ago

reMarkable: ~/.config/chessmarkable/pgn/ chessmarkable [2021-12-09T07:27:14Z DEBUG chessmarkable] Debug Mode is enabled by default. To change this, set the env "RUST_LOG" something else (e.g. info, warn, error or comma separated list of "[module=]"). [2021-12-09T07:27:14Z WARN chessmarkable] You executed retris on a reMarkable 2 without having LD_PRELOAD set. This suggests that you didn't use/enable rm2fb. Without rm2fb you won't see anything on the display!

See https://github.com/ddvk/remarkable2-framebuffer/ on how to solve
this. Launchers (installed through toltec) should automatically do this.

[2021-12-09T07:27:14Z INFO libremarkable::input::ev] Init complete for "/dev/input/event0" [2021-12-09T07:27:14Z INFO libremarkable::input::ev] Init complete for "/dev/input/event2" [2021-12-09T07:27:15Z DEBUG libremarkable::input::scan] Closed initially opened evdev fds (if not used by now). [2021-12-09T07:27:34Z WARN libremarkable::input::multitouch] Unknown event code for multitouch [type: 3 code: 25 value: 0]

cyrenaique commented 2 years ago

reMarkable: ~/.config/chessmarkable/pgn/ ls -l -rw-r--r-- 1 root root 1472 Dec 8 15:19 Caro.pgn -rw-r--r-- 1 root root 1164 Dec 8 21:15 Caro2.pgn -rw-rw-rw- 1 root root 1472 Dec 9 07:21 Caro_2C_Crushed_guy_2021.pgn -rw-r--r-- 1 root root 11537 Oct 23 15:38 b_short.pgn -rw-r--r-- 1 root root 8750 Oct 23 15:40 w_short.pgn

I changed the right (rw) just in case... still

rmadhwal commented 2 years ago

when running chessmarkable without a launcher you need to run it with rm2fb-client.

So run something like this:

reMarkable: ~/ rm2fb-client chessmarkable

I'm guessing when you ran the above you didn't see anything on your remarkable ?

cyrenaique commented 2 years ago

I got the same results with this command. I got sometimes this crash: thread 'main' panicked at 'called Option::unwrap() on a None value', src/bin/chessmarkable/main.rs:275:79 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

LinusCDE commented 2 years ago

when running chessmarkable without a launcher you need to run it with rm2fb-client.

So run something like this:

reMarkable: ~/ rm2fb-client chessmarkable

I'm guessing when you ran the above you didn't see anything on your remarkable ?

It might have worked as there is some kind of elf-patching going on in the toltec packaging that could embed this behaviour if I'm not mistaken. Haven't looked into it too deep and therefore didn't update the warning.

(We will also probably not have the need for LD_PRELOAD or the original rm2fbclient anymore as I recently merged a built-in client for libremarkable. This will also enable musl builds btw.)

cyrenaique commented 2 years ago

I got sometimes this crash: thread 'main' panicked at 'called Option::unwrap() on a None value', src/bin/chessmarkable/main.rs:275:79

not sure you saw that like I edited after

LinusCDE commented 2 years ago

I got sometimes this crash: thread 'main' panicked at 'called Option::unwrap() on a None value', src/bin/chessmarkable/main.rs:275:79

not sure you saw that like I edited after

Right. Wasn't in the email notifications and hadn't seen it straight away. Seems related to managing the selected pgn. May get solved with the general issue it seems.

Edit: The source code line: https://github.com/LinusCDE/chessmarkable/blob/0.8.0-1/src/bin/chessmarkable/main.rs#L275

cyrenaique commented 2 years ago

Should I reinstall it or do I have access to the code in ssh on the rm2?

cyrenaique commented 2 years ago

I installed from packages so I guess I don't have access to the code, sorry I am really rusty in Rust :-)

LinusCDE commented 2 years ago

No worries. The link was just a "fyi". Not meant as a "do it yourself".

I don't think that this error will matter anyway. But better error handling in some places is something I definitely should do anyways.

rmadhwal commented 2 years ago

Hi, sorry I bricked my remarkable temporarily so couldn't follow up with this. It's fine now so I could maybe help more, did you have any luck afterwards ?

cyrenaique commented 2 years ago
Hi, no worries! Merry Christmas, no I didn’t have any luck.Arnaud  Sent from Mail for Windows From: Rohan MadhwalSent: Tuesday, December 28, 2021 8:48 AMTo: LinusCDE/chessmarkableCc: Arnaud Ogier; AuthorSubject: Re: [LinusCDE/chessmarkable] unable to parse pgns file (Issue #18) Hi, sorry I bricked my remarkable temporarily so couldn't follow up with this. It's fine now so I could maybe help more, did you have any luck afterwards ?—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***> 
rmadhwal commented 2 years ago

Okay, I seem to have found the issue. There's a zero width non breaking space at the start of your file which is giving the parsing libraries issues. For now, if you want to view your replays, simply opening them, copying them and pasting them into a new file and saving that should work (if this still doesnt work your text editor might be adding them, so try doing it in vim). I'll try to commit a fix for this when I find some time!

rmadhwal commented 2 years ago

Okay, digging a bit deeper with a hex editor showed me it's a UTF-8 BOM character

So a faster way to fix the issue is to open the file on vim and run :setlocal nobomb and remember to save/exit :wq

cyrenaique commented 2 years ago
Cool! No ideas what this command do but will give a try 😊I will let u know.Thanks again for the effort.Arnaud  Sent from Mail for Windows From: Rohan MadhwalSent: Wednesday, December 29, 2021 2:49 PMTo: LinusCDE/chessmarkableCc: Arnaud Ogier; AuthorSubject: Re: [LinusCDE/chessmarkable] unable to parse pgns file (Issue #18) Okay, digging a bit deeper with a hex editor showed me it's a UTF-8 BOM characterSo a faster way to fix the issue is to drop into the file on vim and run:setlocal nobomband remember to save/exit:wq—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***> 
cyrenaique commented 2 years ago
It works!!! Well done!  From: Rohan MadhwalSent: Wednesday, December 29, 2021 2:49 PMTo: LinusCDE/chessmarkableCc: Arnaud Ogier; AuthorSubject: Re: [LinusCDE/chessmarkable] unable to parse pgns file (Issue #18) Okay, digging a bit deeper with a hex editor showed me it's a UTF-8 BOM characterSo a faster way to fix the issue is to drop into the file on vim and run:setlocal nobomband remember to save/exit:wq—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***> 
rmadhwal commented 2 years ago

Glad to hear that :) Happy holidays!