Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 05-24-2020, 04:19 PM   #1
pazos
cosiñeiro
pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.
 
Posts: 1,406
Karma: 2451781
Join Date: Apr 2014
Device: BQ Cervantes 4
Smart Device App questions

Hi. I'm playing a bit with the API of "smart device app" to improve KOReader wirelessly connection with calibre. So far so good but I have a couple of questions related to free space on disk:

1. It seems that the smart device app ignores reported free space. It does not raise FreeSpaceError as indicated in https://github.com/kovidgoyal/calibr...erface.py#L389

2. I can live with (1) because calibre reports the length in bytes of each file, so I can compare it with device free space. I don't know if there's a way to tell calibre that one or more specific files were not received by the client.

In the best case scenario I would want the server to report issues like "connect to folder" device is doing (in attachment) but I'm fine if the server doesn't report any error as long as it could report the files already on-device.

This is my first attempt to look at calibre/python code. Please forgive me if I mis something obvious. Also please forgive my english. I hope my question can be understood.
Attached Thumbnails
Click image for larger version

Name:	2020-05-24_22-03.png
Views:	219
Size:	21.8 KB
ID:	179486  
pazos is offline   Reply With Quote
Old 05-24-2020, 07:32 PM   #2
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,408
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
It is true that the smart device driver does not raise that exception. It is possible that it could, but I need to look at what the implications are.

I am not sure what question you are asking. It is up to the device to report what files are on the device.
chaley is offline   Reply With Quote
Old 05-25-2020, 08:12 AM   #3
pazos
cosiñeiro
pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.
 
Posts: 1,406
Karma: 2451781
Join Date: Apr 2014
Device: BQ Cervantes 4
Hi chaley, thanks for your help.

When calibre sends the opcode "SEND_BOOK" I check if the book fits in the device. If it fits then I store it on disk and update my local database accordly.

calibre expects a client response per book. I send an opcode "OK" and no data if the book was stored fine. I would like to know how to notify calibre that a specific book in a batch was not received by the client. I tried to send "NOOP" but calibre thinks the book is on device until I disconnect the client and connect it again.
pazos is offline   Reply With Quote
Old 05-25-2020, 10:02 AM   #4
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,408
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by pazos View Post
Hi chaley, thanks for your help.

When calibre sends the opcode "SEND_BOOK" I check if the book fits in the device. If it fits then I store it on disk and update my local database accordly.

calibre expects a client response per book. I send an opcode "OK" and no data if the book was stored fine. I would like to know how to notify calibre that a specific book in a batch was not received by the client. I tried to send "NOOP" but calibre thinks the book is on device until I disconnect the client and connect it again.
The protocol is weak here. The response to SEND_BOOK is processed before the book is actually sent and there is no way to tell the driver not to send the book. FYI: the response is used to tell calibre the device path (lpath) in case the device changes it.

I have to be very careful about what I change in order to avoid breaking other clients. That said, I can do two things, tested using CC:
  • If the client returns ERROR (val 20) to SEND_BOOK then the driver will raise a ControlError exception. The return dict can contain an entry 'message' that will be included in the exception. In this case the driver will not start sending the book data.
  • Add the sanity check that checks device free space against the book size(s)
I have committed the above changes. Once Kovid accepts them then they will be in calibre source for you to test.
chaley is offline   Reply With Quote
Old 05-26-2020, 09:13 AM   #5
pazos
cosiñeiro
pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.
 
Posts: 1,406
Karma: 2451781
Join Date: Apr 2014
Device: BQ Cervantes 4
Quote:
Originally Posted by chaley View Post
  • If the client returns ERROR (val 20) to SEND_BOOK then the driver will raise a ControlError exception. The return dict can contain an entry 'message' that will be included in the exception. In this case the driver will not start sending the book data.
  • Add the sanity check that checks device free space against the book size(s)
I have committed the above changes. Once Kovid accepts them then they will be in calibre source for you to test.
Thank you!!!

With the sanity check in place everything seems to work just fine. In order to test the user feedback I modified the reported free disk space in response to FREE_SPACE opcode. It works too (attachment #1)

For legacy calibre versions I didn't found a better way to handle no disk space than send all binary data to the void and report a message asking the user for disconnect and connect again (attachment #2). Obviously it would be better if I could manage to send the book count again without reconnecting, but I'm fine with the solution.

Again, thanks for your work!
Attached Thumbnails
Click image for larger version

Name:	2020-05-26_15-00.png
Views:	228
Size:	28.3 KB
ID:	179521   Click image for larger version

Name:	2020-05-26_15-07.png
Views:	226
Size:	65.7 KB
ID:	179522  
pazos is offline   Reply With Quote
Old 05-28-2020, 12:41 PM   #6
pazos
cosiñeiro
pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.
 
Posts: 1,406
Karma: 2451781
Join Date: Apr 2014
Device: BQ Cervantes 4
Another thing I noticed: the wireless server doesn't notify clients when its "ejecting" the drive. It just closes the socket.

It would be amazing to send a new opcode to figure out that the user intention is to disconnect the "disk" and it isn't just a temporarily failure on talking with the server.
pazos is offline   Reply With Quote
Old 05-28-2020, 01:00 PM   #7
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,408
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by pazos View Post
Another thing I noticed: the wireless server doesn't notify clients when its "ejecting" the drive. It just closes the socket.

It would be amazing to send a new opcode to figure out that the user intention is to disconnect the "disk" and it isn't just a temporarily failure on talking with the server.
This one is more difficult because a new opcode coming from calibre could break all the existing clients. We got away with ERROR because calibre never sends it.

What I can do: when calibre tells the device to eject, send a NOOP with an argument {'ejecting': True} just before I close the socket. Existing clients shouldn't break (CC won't). This won't prevent calibre from simply closing the socket sometimes because there are ways for the driver to be shutdown without being told why.

Is this OK? If so I will submit changes.
chaley is offline   Reply With Quote
Old 05-28-2020, 02:32 PM   #8
pazos
cosiñeiro
pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.
 
Posts: 1,406
Karma: 2451781
Join Date: Apr 2014
Device: BQ Cervantes 4
Quote:
Originally Posted by chaley View Post
This one is more difficult because a new opcode coming from calibre could break all the existing clients. We got away with ERROR because calibre never sends it.

What I can do: when calibre tells the device to eject, send a NOOP with an argument {'ejecting': True} just before I close the socket. Existing clients shouldn't break (CC won't). This won't prevent calibre from simply closing the socket sometimes because there are ways for the driver to be shutdown without being told why.

Is this OK? If so I will submit changes.
Totally OK!

Thank you!!!
pazos is offline   Reply With Quote
Old 05-28-2020, 02:47 PM   #9
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,408
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by pazos View Post
Totally OK!

Thank you!!!
Submitted. Kovid will probably merge the change tomorrow.
chaley is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question: Smart Audiobook Player app for Android haertig Audiobook Hardware & Software 18 10-24-2018 02:23 PM
found more than one calibre: smart device / wireless device? nikoski Calibre Companion 3 08-04-2016 05:23 AM
Smart Punctuation v7.38, quick questions jackie_w Calibre 6 01-08-2011 04:25 PM
Seriously thoughtful Who is YOUR Smart Mobile Device Pundit? Nate the great Lounge 7 02-11-2010 11:05 AM
How would you rate the Smart Q7 as a E-Book Reading Device ONLY (and which OS) rana Alternative Devices 0 09-21-2009 02:33 AM


All times are GMT -4. The time now is 10:24 PM.


MobileRead.com is a privately owned, operated and funded community.