code-google-com / nxt-python

Automatically exported from code.google.com/p/nxt-python
GNU General Public License v3.0
1 stars 1 forks source link

bug in Hitechnic EOPD sensor class #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Attempt to instantiate nxt.sensor.hitechnic.EOPD:
     import nxt
     from nxt import sensor
     from nxt.sensor import hitechnic

     brick = nxt.find_one_brick()
     laser = hitechnic.EOPD(brick, sensor.PORT_3)

What is the expected output? What do you see instead?
An EOPD object should be created; instead, the following exception is raised:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "nxt/sensor/hitechnic.py", line 245, in __init__
    super(Light, self).__init__(brick, port)
NameError: global name 'Light' is not defined

What version of nxt-python are you using? On what operating system?
I'm using nxt-python version 2.0.1 on Ubuntu 10.10 64-bit. I also tested the 
latest source code from the Subversion repo (revision 273), with the same 
result.

Original issue reported on code.google.com by jerradge...@gmail.com on 22 Jan 2011 at 11:25

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Oh crap. This is embarrassing. Here's a patch to fix it (applicable to the 
trunk or stable v2.0.1). Let me know if it works, and whether the values 
returned are correct. It would also be nice if you could test switching between 
ranges.

This problem was due to lack of being able to actually test some of the sensors 
due to lack of hardware. If you have any other sensors marked as untested in 
the docstrings, it would be cool if you could make sure they work with 
nxt-python. Thanks!

Original comment by marcus@wanners.net on 23 Jan 2011 at 12:01

Attachments:

GoogleCodeExporter commented 9 years ago
The patch works, however, you forgot to import the math module(you're calling 
sqrt in EOPD.get_processed_value). After fixing this, the EOPD class works 
without raising exceptions - I don't think the values it's returning are 
correct, though I'm not sure what the units of measurement are for this sensor. 
I'll work some on this later to help fix it. I'll also test the other Hitechnic 
sensors that I have.

Thanks for writing nxt-python, and don't worry about bugs in code you can't 
test - I'm glad I can program my NXT in Python. You might want to try out 
Pylint sometime. I think it would have caught these bugs.   

Original comment by jerradge...@gmail.com on 23 Jan 2011 at 12:27

GoogleCodeExporter commented 9 years ago
Thank you. I'll be releasing a bugfix version once all the bugs in the sensors 
you have are ironed out. This is really helpful!

I'll look at pylint when I get some spare time. As I've told some other people, 
I'm currently rushing to get IPv6 up on my servers and home network before all 
the tunnel brokers are clogged with new accounts and it becomes hard to test 
things. Hurricane Electric is currently estimating 10 days to IPv4 exhaustion. 
What a nice birthday surprise.

Original comment by marcus@wanners.net on 23 Jan 2011 at 12:34

GoogleCodeExporter commented 9 years ago
Fixed in r275.

Original comment by marcus@wanners.net on 23 Jan 2011 at 1:18