Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 17th, 2012, 11:26 AM
jshook jshook is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Location: Winsted, CT
Posts: 1 jshook User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 53 m 32 sec
Reputation Power: 0
Reading USB Device Data via Python Code

Hello all,

I am new to this forum and to python as well. I do have to say that I do have some C, MATLAB, and Igor programming experience that is helping me with my current project but not enough though. Let me explain first and then I will provide an example of my code and what is doing. Where I work (a science instructor at Talcott Mountain Science Center in Avon CT), we have a weather station that we would like to send data to the web from the console that is collecting data. The weather station is nothing elaborate at the time being, it is an Ambient Weather WS-2080 setup. The program will first find the station console and then read the current data. Then it will apply any and all conversions before writing the data to a file that can then be uploaded to wunderground.com. I currently have had progress in getting the program to find the weather station but then that is all. I have, of course PyUSB and LibUSBWin32 for a 64 bit OS installed on my system.

This is the code I have so far that works:

#USB Test.py

import sys
import usb.core
import usb.util
import usb.control
import usb.legacy

print "Checking for USB"
#find the device/ In this instance my HP Flash Drive.
dev = usb.core.find(idVendor=0x03f0, idProduct=0x3d07)

#dev1 is the weather station console
dev1 = usb.core.find(idVendor=0x1941, idProduct=0x8021)

dev1.set_configuration()

if dev is None:
# raise ValueError('HP 4Gb Flash drive not found!')
print "USB Flash Drive not found"
else:
print "USB Flash Drive found"

if dev1 is None:
#raise ValueError('MSG')
print "Check USB conection to Weather Station"
else:
print "Weather Station found"


#read the usb?
devread = usb.core.Device.read(dev1,0xA1,256)

The program will work up to the last line and then it will produce the following error:

"Traceback (most recent calls last):
File 'test_usb.py', line #in <module>
devread = usb.core.Device.read(dev1,0xA1,256)
File 'C:\Python27\lib\site-packages\usb\core.py', line 646 in read fn = fn_map[self.ctx.get_endpoint_type(self,endpoint,intf)]
File 'C:\Python27\lib\site-packages\usb\core.py', line 181 in get_end_point_type etype = util.endpoint_type(e.bmAttributes)
AttributeError: 'NoneType' object has no attribute 'bmAttributes'
".

I am not sure what the error means or how to fix it. I have looked at code for pywws and the tutorial for PyUSB but it doesn't help. At least for me it doesn't.

If I can get to where I can read data off the console right now, I believe I will be in good shape for a while on this project. It is just getting the USB communication horse **** figured out. Also, I apologize if this has already been addressed on this forum and if so please point me to the post. I have been searching the web and forums for the past couple of weeks to no avail. Thank you in advance.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Reading USB Device Data via Python Code

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap