I can't the ink cartridge levels

Bug #1354731 reported by ALBATROS_L
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
HPLIP
New
Undecided
Unassigned
Gentoo Linux
Unknown
Medium

Bug Description

Hi!
I use HP Device Manager for my HP photosmart C4180. At "Supplies", I should read the ink levels of my two ink cartridges, but it's empty.
My linux is Mint 17. Other information coming by a 'hp-levels -g' command is:

    xxxx@HpLinux ~ $ hp-levels -g

    HP Linux Imaging and Printing System (ver. 3.14.6)
    Supply Levels Utility ver. 2.0

    Copyright (c) 2001-13 Hewlett-Packard Development Company, LP
    This software comes with ABSOLUTELY NO WARRANTY.
    This is free software, and you are welcome to distribute it
    under certain conditions. See COPYING file for more details.

    hp-levels[5371]: debug: getDeviceUri(None, None, ('hp',), None, , True)
    hp-levels[5371]: debug: Mode=0
    hp-levels[5371]: debug: Cache miss: photosmart_c4100_series
    hp-levels[5371]: debug: Reading file: /usr/share/hplip/data/models/models.dat
    hp-levels[5371]: debug: Searching for section [photosmart_c4100_series] in file /usr/share/hplip/data/models/models.dat
    hp-levels[5371]: debug: Found section [photosmart_c4100_series] in file /usr/share/hplip/data/models/models.dat
    hp-levels[5371]: debug: {'hp:/usb/Photosmart_C4100_series?serial=MY78FJ141R04J7': ['HP-Photosmart-C4100-series']}
    Using device: hp:/usb/Photosmart_C4100_series?serial=MY78FJ141R04J7

    hp-levels[5371]: debug: num_pens = 2
    hp-levels[5371]: debug: pen 0 {'index': 0, 'kind': 3L, 'level': 194, 'ack': True, 'hp-ink': False, 'dvc': 7958L, 'level-trigger': 0, 'virgin': True, 'health': 0, 'known': False, 'type': 5, 'id': 0}
    hp-levels[5371]: debug: pen 1 {'index': 1, 'kind': 0L, 'level': 53, 'ack': True, 'hp-ink': False, 'dvc': 5580L, 'level-trigger': 0, 'virgin': True, 'health': 0, 'known': False, 'type': 0, 'id': 17}
    error: Error attempting to read r-value (2).

    Done.

Can't you see what is wrong pls?
Regards.

Revision history for this message
arakelov (nabadvin) wrote :

It also happens to me with Ubuntu 14.04, HP Photosmart C3180, and hplip version 3.14.3. Both ink cartridges are genuine.

Revision history for this message
lucge (luc-loiseau) wrote :

Same for me with photosmart c4180 and ubuntu 14.04.
But now OK with ubuntu 14.10.

Revision history for this message
In , Netfab (netfab) wrote :

I have a HP photosmart C4190. Everything works fine except that hplip is unable to read ink cartridge levels. I remember old versions that were able to.

Upstream bug : https://bugs.launchpad.net/hplip/+bug/1354731
Exactly same behavior and error output.

Reproducible: Always

Revision history for this message
In , Billie-gentoo (billie-gentoo) wrote :

I can not confirm this behavior with a HP Photosmart 6510. Lets wait for upstream comments on this issue.

Revision history for this message
In , Billie-gentoo (billie-gentoo) wrote :

I found the error! I bet you are using python3 as default python interpreter. Try switching back to python2 and try again.

Revision history for this message
Daniel Pielmeier (daniel-pielmeier) wrote :

For the developers @hplip. This is a python2 vs. python3 issue.

The problem is the range function used in base/status.py.

From python2 to python python3 the range function got deprecated and the xrange function got renamed to range. So the behaviour changed between the two versions.

python2:
>>> range(1)
[0]
>>> type(range(1))
<type 'list'>
>>> len(range(1))
1

python3:
>>> range(1)
range(0, 1)
>>> type(range(1))
<class 'range'>
>>> len(range(1))
1

In python2 range returned a list. In python3 the function got it's own type.

This is no problem when used in a for loop as you do, but in python2 the last item of the list is one below the number specified for range() and in python3 the last one is the number specified in range() so it tries to iterate over an item which does not exist.

So if you want the same behaviour as in python2 you should probably use list(range(num_pens)) in base/status.py

Revision history for this message
In , Billie-gentoo (billie-gentoo) wrote :

See the upstream bug if want to know the details of this issue.

Changed in gentoo:
importance: Unknown → Medium
Revision history for this message
In , Netfab (netfab) wrote :

Yes, I'm using python3 as default python interpreter, but after switching back to python2.7, the error is still the same, even after reloading my desktop session.
Are you able to reproduce with python3 but not with python2 ? Thanks.

Revision history for this message
In , Billie-gentoo (billie-gentoo) wrote :

(In reply to Fab from comment #4)
> Yes, I'm using python3 as default python interpreter, but after switching
> back to python2.7, the error is still the same, even after reloading my
> desktop session.
> Are you able to reproduce with python3 but not with python2 ? Thanks.

Here it works regardless of the default interpreter. After thinking about it this is the way it should be. hplip currently only works with python2, so the setup forces python2 regardless of the default interpreter.

From the error message you get it looks like the issue is caused by the python2 vs python3 issue I mentioned on the upstream bug however.

Can you check if the python files in /usr/share/hplip/ have the correct shebangs? They should read:
#!/usr/bin/env python2.7
or
#!/usr/bin/python2.7

Revision history for this message
In , Netfab (netfab) wrote :

Created attachment 400546
find . -name '*.py' -type f -print | xargs head -n 1

Seems ok. Only *.py files in subdirs doesn't have any shebang, but I guess it's normal.

Revision history for this message
In , Billie-gentoo (billie-gentoo) wrote :

(In reply to Fab from comment #6)
> Created attachment 400546 [details]
> find . -name '*.py' -type f -print | xargs head -n 1
>
> Seems ok. Only *.py files in subdirs doesn't have any shebang, but I guess
> it's normal.

Looks okay!

Please check if the range function is the culprit. Change line 198 from /usr/share/hplip/base/status.py to

for p in len(range(num_pens)):

and check if this fixes the issue.

If this does not fix the issue I am out of options. If it does I still wonder why it works here.

From the upstream bug someone mentioned having the problem with Ubuntu 14.04 but with 14.10 anymore. Probably some dependency versions changed which solved the issue. Can you attach the output of hp-check to identify your the dependency versions.

Revision history for this message
In , Netfab (netfab) wrote :

Created attachment 400552
hp-check output

(In reply to Daniel Pielmeier from comment #7)
> Please check if the range function is the culprit. Change line 198 from
> /usr/share/hplip/base/status.py to
>
> for p in len(range(num_pens)):
>
> and check if this fixes the issue.
>

When doing this modification in hplip-3.14.10, an exception is catched, the output of hp-levels -g is changing from :

> hp-levels[7759]: debug: num_pens = 2
> hp-levels[7759]: debug: pen 0 {'index': 0, 'kind': 3L, 'level': 194, 'ack': True,
> 'hp-ink': False, 'dvc': 36480L, 'level-trigger': 0, 'virgin': True, 'health': 0,
> 'known': False, 'type': 0, 'id': 0}
> hp-levels[7759]: debug: pen 1 {'index': 1, 'kind': 0L, 'level': 66, 'ack': True,
> 'hp-ink': False, 'dvc': 5580L, 'level-trigger': 0, 'virgin': True, 'health': 0,
> 'known': False, 'type': 0, 'id': 17}
> error: Error attempting to read r-value (2).

To :

> hp-levels[7730]: debug: num_pens = 2
> warning: Status parsing error: 'int' object is not iterable
> error: Error attempting to read r-value (2).

I can also try hplip-3.15.2 to see if it makes any difference.

Revision history for this message
In , Billie-gentoo (billie-gentoo) wrote :

(In reply to Fab from comment #8)
>
> When doing this modification in hplip-3.14.10, an exception is catched, the
> output of hp-levels -g is changing from :
>
> > hp-levels[7759]: debug: num_pens = 2
> > hp-levels[7759]: debug: pen 0 {'index': 0, 'kind': 3L, 'level': 194, 'ack': True,
> > 'hp-ink': False, 'dvc': 36480L, 'level-trigger': 0, 'virgin': True, 'health': 0,
> > 'known': False, 'type': 0, 'id': 0}
> > hp-levels[7759]: debug: pen 1 {'index': 1, 'kind': 0L, 'level': 66, 'ack': True,
> > 'hp-ink': False, 'dvc': 5580L, 'level-trigger': 0, 'virgin': True, 'health': 0,
> > 'known': False, 'type': 0, 'id': 17}
> > error: Error attempting to read r-value (2).
>
> To :
>
> > hp-levels[7730]: debug: num_pens = 2
> > warning: Status parsing error: 'int' object is not iterable
> > error: Error attempting to read r-value (2).
>

Sorry, my fault. The change should look like this (using list instead of length, this should result in he same behavior for python2 and python3 ):

for p in list(range(num_pens)):

Revision history for this message
In , Billie-gentoo (billie-gentoo) wrote :

(In reply to Fab from comment #8)
> Created attachment 400552 [details]
> hp-check output
>

Does not look different from mine, except that I do not have avahi installed and I am already on gcc 4.8.4.

> I can also try hplip-3.15.2 to see if it makes any difference.

You can try this. I have checked with hplip-3.14.10 and hplip-3.15.2. Both work fine here.

Revision history for this message
In , Netfab (netfab) wrote :

(In reply to Daniel Pielmeier from comment #9)
> for p in list(range(num_pens)):

With this, the error is the same on version 3.14.10 :
> hp-levels[8834]: debug: num_pens = 2
> hp-levels[8834]: debug: pen 0 {'index': 0, 'kind': 3L, 'level': 194, 'ack': True,
> 'hp-ink': False, 'dvc': 36480L, 'level-trigger': 0, 'virgin': True, 'health': 0,
> 'known': False, 'type': 0, 'id': 0}
> hp-levels[8834]: debug: pen 1 {'index': 1, 'kind': 0L, 'level': 66, 'ack': True,
> 'hp-ink': False, 'dvc': 5580L, 'level-trigger': 0, 'virgin': True, 'health': 0,
> 'known': False, 'type': 0, 'id': 17}
> error: Error attempting to read r-value (2).

I tried 3.15.2 and it changes nothing.

Revision history for this message
Daniel Pielmeier (daniel-pielmeier) wrote :

Looks like it has nothing to to with the range function. I checked for python2 and python3 and the behaviour is the same.

Revision history for this message
Daniel Pielmeier (daniel-pielmeier) wrote :

However the issue was already resolved for hplip-3.13.4, see the changelog. Looks like the same issue popped up again.

Revision history for this message
In , Billie-gentoo (billie-gentoo) wrote :

(In reply to Fab from comment #11)
> (In reply to Daniel Pielmeier from comment #9)
> > for p in list(range(num_pens)):
>
> With this, the error is the same on version 3.14.10 :
> > hp-levels[8834]: debug: num_pens = 2
> > hp-levels[8834]: debug: pen 0 {'index': 0, 'kind': 3L, 'level': 194, 'ack': True,
> > 'hp-ink': False, 'dvc': 36480L, 'level-trigger': 0, 'virgin': True, 'health': 0,
> > 'known': False, 'type': 0, 'id': 0}
> > hp-levels[8834]: debug: pen 1 {'index': 1, 'kind': 0L, 'level': 66, 'ack': True,
> > 'hp-ink': False, 'dvc': 5580L, 'level-trigger': 0, 'virgin': True, 'health': 0,
> > 'known': False, 'type': 0, 'id': 17}
> > error: Error attempting to read r-value (2).
>
> I tried 3.15.2 and it changes nothing.

Okay so this was not the issue. I found the same problem was already fixed in hplip-3.13.4 and now it popped up again.

Revision history for this message
Gaurav Sood (gaurav-sood) wrote :

Can you provide syslog/messages file to help us analyze the issue. Clear the syslog/messages first, then run hp-align on terminal and attach the log files here

Revision history for this message
Gaurav Sood (gaurav-sood) wrote :

Please install the latest 3.15.4 from hplipopensource.com and check.

if issue still presists, Follow the steps

1) Navigate to hplip-3.15.4 directory in Downloads folder by running

               cd ~/Downloads/hplip-3.15.4/

2) open hpmudi.h file

                vi io/hpmud/hpmudi.h

3) Uncomment the following line and save the file

       // #define HPMUD_DEBUG

4) At the prompt run
           make
          sudo make install

5) Clear the syslog/messages file.

         sudo cp /dev/null /var/log/syslog

6) Run "hp-levels -g" at the terminal.

8) Attach the syslog/messages and output seen at terminal

Revision history for this message
ALBATROS_L (philippe-gay11) wrote : Re: [Bug 1354731] Re: I can't the ink cartridge levels
Download full text (5.1 KiB)

Hello,

Thanks for your mail.

I get this on the screen :

HpLinux hplip-3.15.4 # hp-levels -g
warning: hp-levels should not be run as root/superuser.

HP Linux Imaging and Printing System (ver. 3.15.4)
Supply Levels Utility ver. 2.0

Copyright (c) 2001-15 Hewlett-Packard Development Company, LP
This software comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to distribute it
under certain conditions. See COPYING file for more details.

hp-levels[11816]: debug: getDeviceUri(None, None, ('hp',), None, , True)
hp-levels[11816]: debug: Mode=0
hp-levels[11816]: debug: Cache miss: photosmart_c4100_series
hp-levels[11816]: debug: Reading file: /usr/share/hplip/data/models/models.dat
hp-levels[11816]: debug: Searching for section [photosmart_c4100_series] in file /usr/share/hplip/data/models/models.dat
hp-levels[11816]: debug: Found section [photosmart_c4100_series] in file /usr/share/hplip/data/models/models.dat
hp-levels[11816]: debug: {'hp:/usb/Photosmart_C4100_series?serial=MY78FJ141R04J7': ['HP-Photosmart-C4100-series', 'Photosmart_C4100', 'Photosmart_C4100_2']}
Using device : hp:/usb/Photosmart_C4100_series?serial=MY78FJ141R04J7

hp-levels[11816]: debug: num_pens = 2
hp-levels[11816]: debug: pen 0 {'index': 0, 'kind': 3L, 'level': 194, 'ack': False, 'hp-ink': True, 'dvc': 60909, 'level-trigger': 0, 'virgin': True, 'health': 1, 'known': True, 'type': 0, 'id': 0}
hp-levels[11816]: debug: pen 1 {'index': 1, 'kind': 0L, 'level': 0, 'ack': True, 'hp-ink': True, 'dvc': 36885, 'level-trigger': 0, 'virgin': False, 'health': 0, 'known': False, 'type': 0, 'id': 17}

Done.
HpLinux hplip-3.15.4 #

The syslog's content is the following:

May 25 16:00:53 HpLinux python: io/hpmud/hpmud.c 387: [11816] hpmud_init()
May 25 16:00:53 HpLinux hp-levels: hp-levels[11816]: warning: hp-levels should not be run as root/superuser.
May 25 16:00:53 HpLinux hp-levels: io/hpmud/hpmud.c 530: [11816,9633,0,0,0,0] hpmud_device_open() uri=hp:/usb/Photosmart_C4100_series?serial=MY78FJ141R04J7 iomode=3
May 25 16:00:53 HpLinux hp-levels: io/hpmud/musb.c 426: Found interface conf=0, iface=1, altset=0, index=1
May 25 16:00:53 HpLinux hp-levels: io/hpmud/musb.c 388: Active kernel driver on interface=1 ret=1
May 25 16:00:53 HpLinux hp-levels: io/hpmud/musb.c 392: Detaching kernel driver on interface=1 ret=0
May 25 16:00:53 HpLinux hp-levels: io/hpmud/musb.c 531: claimed 7/1/2 interface
May 25 16:00:53 HpLinux hp-levels: io/hpmud/musb.c 775: read actual device_id successfully fd=1 len=216
May 25 16:00:53 HpLinux hp-levels: io/hpmud/musb.c 557: released 7/1/2 interface
May 25 16:00:53 HpLinux hp-levels: io/hpmud/hpmud.c 577: [11816] hpmud_get_device_id() dd=1
May 25 16:00:53 HpLinux hp-levels: io/hpmud/musb.c 426: Found interface conf=0, iface=1, altset=0, index=1
May 25 16:00:53 HpLinux hp-levels: io/hpmud/musb.c 388: Active kernel driver on interface=1 ret=0
May 25 16:00:53 HpLinux hp-levels: io/hpmud/musb.c 531: claimed 7/1/2 interface
May 25 16:00:53 HpLinux kernel: [31618.827233] usblp0: removed
May 25 16:00:53 HpLinux kernel: [31618.827518] Did not find alt setting 1 for intf 0, config 1
May 25 16:00:53 HpLinux hp-levels: io/hpmud/musb.c 775: read act...

Read more...

Revision history for this message
Gaurav Sood (gaurav-sood) wrote :

Please run hp-levels -g in normal user mode (not in root mode) and attach the syslog file and the output on the terminal

Revision history for this message
ALBATROS_L (philippe-gay11) wrote :
Download full text (12.6 KiB)

hello,

Here is the terminal:

papa@HpLinux ~/Downloads/hplip-3.15.4 $ hp-levels -g

HP Linux Imaging and Printing System (ver. 3.15.4)
Supply Levels Utility ver. 2.0

Copyright (c) 2001-15 Hewlett-Packard Development Company, LP
This software comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to distribute it
under certain conditions. See COPYING file for more details.

hp-levels[3463]: debug: getDeviceUri(None, None, ('hp',), None, , True)
hp-levels[3463]: debug: Mode=0
hp-levels[3463]: debug: Cache miss: photosmart_c4100_series
hp-levels[3463]: debug: Reading file: /usr/share/hplip/data/models/models.dat
hp-levels[3463]: debug: Searching for section [photosmart_c4100_series] in file /usr/share/hplip/data/models/models.dat
hp-levels[3463]: debug: Found section [photosmart_c4100_series] in file /usr/share/hplip/data/models/models.dat
hp-levels[3463]: debug: {'hp:/usb/Photosmart_C4100_series?serial=MY78FJ141R04J7': ['HP-Photosmart-C4100-series', 'Photosmart_C4100', 'Photosmart_C4100_2']}
Using device : hp:/usb/Photosmart_C4100_series?serial=MY78FJ141R04J7

hp-levels[3463]: debug: num_pens = 2
hp-levels[3463]: debug: pen 0 {'index': 0, 'kind': 3L, 'level': 194, 'ack': False, 'hp-ink': True, 'dvc': 60909, 'level-trigger': 0, 'virgin': True, 'health': 1, 'known': True, 'type': 0, 'id': 0}
hp-levels[3463]: debug: pen 1 {'index': 1, 'kind': 0L, 'level': 0, 'ack': True, 'hp-ink': True, 'dvc': 36885, 'level-trigger': 0, 'virgin': False, 'health': 0, 'known': False, 'type': 0, 'id': 17}
error: Error attempting to read r-value (2).

Done.

And the log:

papa@HpLinux ~/Downloads/hplip-3.15.4 $ cat /var/log/syslog
May 26 19:14:48 HpLinux python: io/hpmud/hpmud.c 387: [3463] hpmud_init()
May 26 19:14:48 HpLinux python: io/hpmud/hpmud.c 530: [3463,3272,1000,1000,1000,1000] hpmud_device_open() uri=hp:/usb/Photosmart_C4100_series?serial=MY78FJ141R04J7 iomode=3
May 26 19:14:48 HpLinux python: io/hpmud/musb.c 426: Found interface conf=0, iface=1, altset=0, index=1
May 26 19:14:48 HpLinux python: io/hpmud/musb.c 388: Active kernel driver on interface=1 ret=0
May 26 19:14:48 HpLinux python: io/hpmud/musb.c 531: claimed 7/1/2 interface
May 26 19:14:48 HpLinux python: io/hpmud/musb.c 775: read actual device_id successfully fd=1 len=216
May 26 19:14:48 HpLinux python: io/hpmud/musb.c 557: released 7/1/2 interface
May 26 19:14:48 HpLinux python: io/hpmud/hpmud.c 577: [3463] hpmud_get_device_id() dd=1
May 26 19:14:48 HpLinux python: io/hpmud/musb.c 426: Found interface conf=0, iface=1, altset=0, index=1
May 26 19:14:48 HpLinux python: io/hpmud/musb.c 388: Active kernel driver on interface=1 ret=0
May 26 19:14:48 HpLinux python: io/hpmud/musb.c 531: claimed 7/1/2 interface
May 26 19:14:48 HpLinux python: io/hpmud/musb.c 775: read actual device_id successfully fd=1 len=216
May 26 19:14:48 HpLinux python: io/hpmud/musb.c 557: released 7/1/2 interface
May 26 19:14:48 HpLinux python: io/hpmud/hpmud.c 577: [3463] hpmud_get_device_id() dd=1
May 26 19:14:48 HpLinux python: io/hpmud/musb.c 426: Found interface conf=0, iface=1, altset=0, index=1
May 26 19:14:48 HpLinux python: io/hpmud/musb.c 388: Active kernel driver on interface=1 ret=0
May 26 19...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.