Re: [pyusb-users] pyusb and root permissions "ValueError: The device has no langid"

2016-08-20 Thread Steven Michalske
Permissions deal with your Linux configuration.

Here is a general answer for Linux.
http://unix.stackexchange.com/questions/44308/understanding-udev-rules-and-permissions-in-libusb

You can google for libusb permissions for your distribution if this doesn't 
lead to a solution.



> On Aug 20, 2016, at 07:46, Jay Aurabind  wrote:
> 
> Hi,
> 
> I am a user of pyOCD, and I am having an issue related to pyusb which
> is what the former uses for talking to the USB device. The situation
> is that I need to use pyOCD through an eclipse plugin. Eclipse
> launches pyocd-gdbserver and normal user. But it will only work if
> launched as root.
> 
> My question is, how can I make pysb do its job without requiring root
> permissions? Here is the error I get when launching pyocd-gdbserver as
> normal user. The last lines suggests its pyusb having issues:
> 
> uncaught exception: The device has no langid
> Traceback (most recent call last):
>  File "build/bdist.linux-x86_64/egg/pyOCD/tools/gdb_server.py", line
> 262, in run
>frequency=self.args.frequency)
>  File "build/bdist.linux-x86_64/egg/pyOCD/board/mbed_board.py", line
> 210, in chooseBoard
>target_override, frequency)
>  File "build/bdist.linux-x86_64/egg/pyOCD/board/mbed_board.py", line
> 182, in getAllConnectedBoards
>connected_daps = dap_class.get_connected_devices()
>  File 
> "build/bdist.linux-x86_64/egg/pyOCD/pyDAPAccess/dap_access_cmsis_dap.py",
> line 352, in get_connected_devices
>all_interfaces = _get_interfaces()
>  File 
> "build/bdist.linux-x86_64/egg/pyOCD/pyDAPAccess/dap_access_cmsis_dap.py",
> line 44, in _get_interfaces
>return INTERFACE[usb_backend].getAllConnectedInterface()
>  File 
> "build/bdist.linux-x86_64/egg/pyOCD/pyDAPAccess/interface/pyusb_backend.py",
> line 88, in getAllConnectedInterface
>product = board.product
>  File "/usr/lib/python2.7/site-packages/usb/core.py", line 841, in product
>self._product = util.get_string(self, self.iProduct)
>  File "/usr/lib/python2.7/site-packages/usb/util.py", line 314, in get_string
>raise ValueError("The device has no langid")
> ValueError: The device has no langid
> 
> 
> Please let me know if there are any workarounds to make pyusb work
> without requiring root privilege.
> 
> -- 
> 
> Thanks and Regards,
> Aurabindo J
> 
> --
> ___
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users

--
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] Barcode Scanner

2016-04-24 Thread Steven Michalske
John,

Not knowing your exact barcode scanner is a real hindrance.
One good piece of information you forgot to provide was what exactly you were 
interfacing to.
USB barcode scanner is too generic,  you need read 
http://catb.org/esr/faqs/smart-questions.html

That being said the VID is from Honeywell, so here is on of their manuals for a 
2d barcode reader.
See page 2-4 of http://www.honeywellaidc.com/CatalogDocuments/Xenon-UG.pdf
Clearly it states that to enable the USB CDC mode you scan that barcode.

To enable USB-CDC mode of the barcode scanner.
Windows needs a driver, but mac and linux will use the generic USB-CDC driver.

Now you will connect with pySerial and communicate with your barcode scanner as 
a serial device.

Happy hacking,
Steve

> On Apr 24, 2016, at 7:22 AM, Dietmar Schwertberger 
>  wrote:
> 
> On 24.04.2016 14:34, John Thornton wrote:
>> I've established communications with it and added a udev rule and added
>> myself to the scanner group so I could talk to the scanner. And the
>> results so far are:
> A long way to go...
> 
>> On 4/24/2016 6:06 AM, Dietmar Schwertberger wrote:
>>> button and they send keystrokes.
>>> You should have info from the manufacturer of your scanner. Maybe he has
>>> implemented CDC (aka Virtual COM Port).
> For Windows, Honeywell offers a USB Serial Driver.
> So you may try CDC as well, either as serial port or via pyusb.
> 
> Regards,
> 
> Dietmar
> 
> --
> Find and fix application performance issues faster with Applications Manager
> Applications Manager provides deep performance insights into multiple tiers of
> your business applications. It resolves application problems quickly and
> reduces your MTTR. Get your free trial!
> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
> ___
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users


--
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] Change suggestion

2015-06-20 Thread Steven Michalske

> On Jun 20, 2015, at 2:10 AM, Tormod Volden  wrote:
> 
> On Fri, Jun 19, 2015 at 4:12 PM, Hermann Hamann wrote:
>> I am sorry, but I am too old and too stupid to learn on the fly how to use a
>> github pull request
>> to push some files.
>> 
>> So I use the stone age way to attach the modified files core.py and
>> libusb1.py to this mail, hoping,
>> that some kind soul will find them and treat them as required.
> 
> Hermann,
> 
> What version of pyusb are your changes based on? Without knowing this,
> it is difficult to figure out exactly what are your changes.
> 
> You are giving the maintainer a lot of extra work by just dumping your
> files on him. At least, use a "diff" utility to make a
> machine-readable diff instead. BTW, the original "diff" was made in
> the seventies, so age is no excuse.
> 
> Regards,
> Tormod
> 
> --
> ___
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users

Hermann,

Presuming that you used git to clone the source repository there is one of the 
few basic git commands to get a properly formatted patch that tracks the source 
revision.

Please use git format-patch to generate diffs based upon the checkout that you 
worked against.

`git format-patch origin/master`

As for pull requests in github, you are not too stupid nor too old.  Your self 
deprecation begs for mockery from others.  I accept no ageism, my grandmother 
was an avid computer user, that was self taught when she was 62, on a 8088 IBM 
PC clone.

1. Fork the pyusb repository.
2. Commit your changes to a branch in your new fork on your computer.
3. Push your changes to in the forked repository on github.
4. Submit a pull request for that new branch against the pyusb repository.

Please refer to this documentation from github.
https://help.github.com/articles/using-pull-requests/ 


Steve

--
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] Dual installation of Python in Raspberry Pi

2015-03-18 Thread Steven Michalske
I strongly suggest you read up on pip and also you may want to look into 
virtualenv 

Steve




> On Mar 18, 2015, at 12:37 PM, Michel Allaire  wrote:
> 
> Thank you
> 
> I have installed pyusb with the following command as shown in the readme file 
> of pyusb: 
> 
> sudo python setup.py install 
> 
> I am not familiar with the pip concept.
> 
> Regards 
> 
> Michel
> 
> 
> 
> 
> -Message d'origine-
> De : Jim Easterbrook [mailto:j...@jim-easterbrook.me.uk] 
> Envoyé : 18 mars 2015 08:42
> À : pyusb-users@lists.sourceforge.net
> Objet : Re: [pyusb-users] Dual installation of Python in Raspberry Pi
> 
>> On 18/03/15 12:18, Michel Allaire wrote:
>> 
>> I want to use pyusb in a Raspberry pi which come with two 
>> installations of Python: 2.x and 3.x.
>> 
>> The problem is that pyusb installs in a way that it is only working  
>> in version 2.X  and not in version 3.x in which I have the following 
>> error message
>> cd pi
> 
>> 
>> Is there a way to change the behavior of pyusb installer.
> 
> How are you installing pyusb? If you use pip to install from PyPI you just 
> need to run the python3 version of pip: 'sudo pip3 install pyusb'
> -- 
> Jim Easterbrook 
> 
> --
> Dive into the World of Parallel Programming The Go Parallel Website, 
> sponsored by Intel and developed in partnership with Slashdot Media, is your 
> hub for all things parallel software development, from weekly thought 
> leadership blogs to news, videos, case studies, tutorials and more. Take a 
> look and join the conversation now. http://goparallel.sourceforge.net/
> ___
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users
> 
> 
> --
> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for all
> things parallel software development, from weekly thought leadership blogs to
> news, videos, case studies, tutorials and more. Take a look and join the 
> conversation now. http://goparallel.sourceforge.net/
> ___
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users

--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] Detect device on Mac

2014-12-29 Thread Steven Michalske

> On Dec 26, 2014, at 8:41 PM, Wander Lairson Costa  
> wrote:
> 
> 2014-11-17 7:56 GMT-02:00 Oci Ocean :
>> Hallo together,
>> 
> 
> Hi, sorry for the delay.
> 
>> I have a problem  detecting my ir-reciever on Mac 10.8.
>> The ir-reciever is noticed by the oporating system and i can control
>> iTunes with a remote control but:
>> 
>> device = usb.core.find(find_all=True)
>> 
>> just finds USB-Mouse and Keyboard.
>> 
>> Where is my mistake or what can i do to have success?
>> 
> 
> So, I am not a Mac guy, does Mac have a lsusb like tool? Does your
> device appear there?
> 
The USB view under Hardware in the “System Information” app.

/Applications/Utilities/System Information

There are developer tools that provide some more information.
https://developer.apple.com/hardwaredrivers/ 


You have to register as a developer, and it should be available with the free 
developer account.  Although you probably don’t need these tools, it does 
include an optionaly logging USB kernel driver for OSX

> Best Regards,
> Wander Lairson Costa
> 
> --
> Dive into the World of Parallel Programming! The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net
> ___
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users

--
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] Significance of 'B' Character in Data Arrays

2014-09-29 Thread Steven Michalske
Jared,

You were close, 8.6 of the docs is what you were looking for.

See https://docs.python.org/2/library/array.html for full description of the 
python array standard library module.

If you don't have a need to run python 2.7, I suggest using Python 3  it copes 
with bytes and strings more explicitly.  Working with low level stuff i fond it 
more useful than coercing python 2 to work properly with bytes and strings 
(unicode)
Especially when I use utf-8 in my programs.

Steve

On Sep 29, 2014, at 8:06 PM, Jared Contrascere 
 wrote:

> Hello!
> 
> I've managed to read data! At this point, I need to decipher it. I wanted to 
> confirm my suspicion that the B in the following array:
> 
> array('B', [3, 4, 2, 0, 22, 0])
> 
> Signifies that an unsigned char is being received from the backend library, 
> similar to what is seen in the table section 7.3.2.2 at 
> https://docs.python.org/2/library/struct.html
> 
> Is this the case?
> 
> Thanks in advance!
> 
> Best,
> Jared
> 
> --
> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk___
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users

--
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] accessing DMM

2013-10-02 Thread Steven Michalske
The damn uses a USB to serial UART converter.  You can skip pyUSB and use 
pySERIAL on /dev/ttyUSB0.

Steve.


> On Oct 2, 2013, at 3:49 PM, ranzam ali  wrote:
> 
> hello frens,
> 
> I am having problem trying to read the data from my digital multimeter 
> http://www.appatech.com/upload/download/file11349831248683.pdf. Actually, I 
> am using PyUSB to access the DMM But, I am only able to open the port not 
> able to read anything. The kernel version I am using is Linux version 
> 3.6.11+. 
> The output of dmesg gives me this
> [  351.020927] cp210x 1-1.2:1.0: device disconnected
> [  353.563977] usb 1-1.2: new full-speed USB device number 5 using dwc_otg
> [  353.666404] usb 1-1.2: New USB device found, idVendor=10c4, idProduct=ea60
> [  353.666432] usb 1-1.2: New USB device strings: Mfr=1, Product=2, 
> SerialNumber=3
> [  353.666448] usb 1-1.2: Product: CP2102 USB to UART Bridge Controller
> [  353.666462] usb 1-1.2: Manufacturer: Silicon Labs
> [  353.666474] usb 1-1.2: SerialNumber: 0001
> [  353.668672] cp210x 1-1.2:1.0: cp210x converter detected
> [  353.764017] usb 1-1.2: reset full-speed USB device number 5 using dwc_otg
> [  353.865753] usb 1-1.2: cp210x converter now attached to ttyUSB0 
> 
> The PyUSB code i used was:
> import usb.backend
> import usb.core
> import usb.util
> 
> dev=usb.core.find(idVendor=0x10c4, idProduct=0xea60)
> 
> if dev is None:
> raise ValueError("Device not found")
> else:
> print ("Device found")
> dev.set_configuration()
> endpoint = dev[0][(0,0)][0]
> data = dev.read(0x81, 0x0040, 0,0)
> print(data)
> 
> Can anyone help me?
> 
> I have also attached the log of the SnoopyPro.
> 
> Thanks,
> -ryan(newbie)
> 
> “Do you love your creator? Love your fellow-beings first.”
> 
> 
> 
> 
> --
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
> ___
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users
--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] device not found

2013-05-03 Thread Steven Michalske
Use System Profiler (Lion or earlier) or System Information (Mountain lion) and 
go to the USB view.

It will show the information there.

Alternatively, the information is in iokit.


In terminal, run
system_profiler SPUSBDataType

Happy Hacking!

On May 3, 2013, at 7:57 PM, I Rabkina  wrote:

> Hi Karl,
> 
> Those are the numbers they gave me. Do you think converting the vendor ID to 
> hex (or product ID to decimal) could fix the problem?
> 
> Thanks,
> Irina
> 
> 
> On Fri, May 3, 2013 at 3:40 PM, Karl P  wrote:
> 
> 
> On 05/03/2013 06:48 PM, Wander Lairson Costa wrote:
> > 2013/5/3 I Rabkina :
> >> Hello,
> >>
> >> I am just getting started with pyusb. I need it to send an high/low signal
> >> to a DAQ box using USB. Unfortunately, I am coming across a problem within
> >> the first few lines of code. Specifically, pyusb can't find the device. I
> >> assumed that the error was from having incorrect IDs, but I've checked with
> >> the manufacturer and they are correct. Am I doing something incorrect with
> >> the code or does pyusb not support this kind of device? The code I'm using
> >> is below.
> >>
> >> import usb.core
> >> import usb.util
> >>
> >> #find the device
> >> dev = usb.core.find (idVendor=1307, idProduct=0x82)
> >>
> >> if dev is None:
> >> raise ValueError ('DAQ not found')
> >>
> >> dev.set_configuration()
> >>
> 
> Really?  You realy mean to use hex for one and decimal for the other?  You
> may have checked with the manufacturer, but that seems like a needlessly
> confusing way to do things if deliberate
> 
> Cheers,
> Karl P
> 
> 
> --
> Get 100% visibility into Java/.NET code with AppDynamics Lite
> It's a free troubleshooting tool designed for production
> Get down to code-level detail for bottlenecks, with <2% overhead.
> Download for free and get started troubleshooting in minutes.
> http://p.sf.net/sfu/appdyn_d2d_ap2
> ___
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users
> 
> --
> Get 100% visibility into Java/.NET code with AppDynamics Lite
> It's a free troubleshooting tool designed for production
> Get down to code-level detail for bottlenecks, with <2% overhead.
> Download for free and get started troubleshooting in minutes.
> http://p.sf.net/sfu/appdyn_d2d_ap2___
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users

--
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] [PATCH] Fix: keep compatibility with Python 3.3.

2013-01-27 Thread Steven Michalske


On Jan 27, 2013, at 3:35 PM, Wander Lairson Costa  
wrote:

> _interop.as_array(s.encode('ut8'))

Ahh, I read the _ and thought it was a private module.--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] [PATCH] Fix: keep compatibility with Python 3.3.

2013-01-27 Thread Steven Michalske

On Jan 26, 2013, at 11:04 AM, wander.lair...@gmail.com wrote:

> From: Wander Lairson Costa 
> 
> In usb/_interop.py in the as_array function, the array typecodes 'c' and
> 'u' are used. The 'c' typecode was removed from python 3.3 and 'u' will
> is deprecated. The solution is to use the fromstring array method, but
> it has the side effect of adding only the first byte of Unicode strings.
> ---
> usb/_interop.py |7 +++
> 1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/usb/_interop.py b/usb/_interop.py
> index 5abdcdb..d6d0a6c 100644
> --- a/usb/_interop.py
> +++ b/usb/_interop.py
> @@ -131,8 +131,7 @@ def as_array(data=None):
> except TypeError:
> # When you pass a unicode string or a character sequence,
> # you get a TypeError if first parameter does not match
> -try:
> -return array.array('c', data)
> -except TypeError:
> -return array.array('u', data)
> +a = array.array('B')
> +a.fromstring(data)
> +return a
> 

This code when run in python 2.7.4 raises an exception with unicode text as 
data.

In [12]: import array

In [13]: a=array.array('B')

In [14]: s=u"abcꬨ"

In [15]: a.fromstring(s)
---
UnicodeEncodeErrorTraceback (most recent call last)
 in ()
> 1 a.fromstring(s)

UnicodeEncodeError: 'ascii' codec can't encode character u'\uab28' in position 
3: ordinal not in range(128)

In [16]:

> -- 
> 1.7.10.4
> 
> 
> --
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnnow-d2d
> ___
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users


--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] [PATCH] Fix: keep compatibility with Python 3.3.

2013-01-27 Thread Steven Michalske
How can the user decide in your method?  I don't see it.

Steve




On Jan 27, 2013, at 3:15 AM, Wander Lairson Costa  
wrote:

> 2013/1/26 Steven Michalske :
>> What about this?
>> Tested in python 2.7 and 3.3
>> 
>> a = array.array("B")
>> s=u"abcꬦ"
>> try:
>>a.fromstring(s.encode('ascii'))
>> except UnicodeEncodeError:
>>a.fromstring(s.encode('utf8'))
>> print(a)
>> array('B', [97, 98, 99, 234, 172, 166])
>> 
>> a = array.array("B")
>> s="abc"
>> try:
>>a.fromstring(s.encode('ascii'))
>> except UnicodeEncodeError:
>>a.fromstring(s.encode('utf8'))
> 
> I think is better to let the user decides which encoding he prefers.
> 
> -- 
> Best Regards,
> Wander Lairson Costa
> 
> --
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnnow-d2d
> ___
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] [PATCH] Fix: keep compatibility with Python 3.3.

2013-01-26 Thread Steven Michalske
What about this?
Tested in python 2.7 and 3.3

a = array.array("B")
s=u"abcꬦ"
try:
a.fromstring(s.encode('ascii'))
except UnicodeEncodeError:
a.fromstring(s.encode('utf8'))
print(a)
array('B', [97, 98, 99, 234, 172, 166])

a = array.array("B")
s="abc"
try:
a.fromstring(s.encode('ascii'))
except UnicodeEncodeError:
a.fromstring(s.encode('utf8'))


On Jan 26, 2013, at 11:04 AM, wander.lair...@gmail.com wrote:

> From: Wander Lairson Costa 
> 
> In usb/_interop.py in the as_array function, the array typecodes 'c' and
> 'u' are used. The 'c' typecode was removed from python 3.3 and 'u' will
> is deprecated. The solution is to use the fromstring array method, but
> it has the side effect of adding only the first byte of Unicode strings.
> ---
> usb/_interop.py |7 +++
> 1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/usb/_interop.py b/usb/_interop.py
> index 5abdcdb..d6d0a6c 100644
> --- a/usb/_interop.py
> +++ b/usb/_interop.py
> @@ -131,8 +131,7 @@ def as_array(data=None):
> except TypeError:
> # When you pass a unicode string or a character sequence,
> # you get a TypeError if first parameter does not match
> -try:
> -return array.array('c', data)
> -except TypeError:
> -return array.array('u', data)
> +a = array.array('B')
> +a.fromstring(data)
> +return a
> 
> -- 
> 1.7.10.4
> 
> 
> --
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnnow-d2d
> ___
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users


--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] bulkWrite of character sequence

2012-03-29 Thread Steven Michalske





On Mar 29, 2012, at 7:47 PM, Wander Lairson Costa  
wrote:

> 2012/3/29 Tormod Volden :
>> On Thu, Mar 29, 2012 at 12:32 PM, Wander Lairson Costa wrote:
>>> Yes, this is a known problem that was already reported before. PyUSB
>>> 0.4 was very flexible in managing the buffer types, and PyUSB 1.0 is
>>> not that so. I could not find yet a simple and elegant solution for
>>> this problem, but try to mimic to behavior of the C version of PyUSB.
>> 
>> Thanks. I could not find it in the bug tracker, but I found a post
>> from Sarah Messer seeing the same problem here:
>> http://sourceforge.net/mailarchive/message.php?msg_id=27131804
>> 
> 
> There it is.
> 
>> Maybe we should just try return array.array('c', data) before or after
>> trying array.array('u', data)?
>> 
> 
> This maybe a workaround for this specific case, but I mimic the
> behavior of the C version, things get more complicated. Anyway, if you
> provide a patch, I will accept, it is better than nothing.
> 
>> BTW, how is the use of unicode strings meant to work? Each string
>> character LSB is sent to the device?
>> 
> 
> I don't remember for sure right now, but I think all bytes are sent as
> a linear buffer...
> 
I Just read the Wikipedia page on utf-16 and the default is big endian if no 
bom is present.

Although apparently windows defaults to little endian.  In other words with 
utf>8. I'd force a bom and output the data.  Unless a byte order is specified.

The utf-16 decoder should understand the BOM as a zero width non breakable 
space.  And automatically do endian conversion based on the result of 0xFFFE or 
0xFEFF. 

> -- 
> Best Regards,
> Wander Lairson Costa
> 
> --
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here 
> http://p.sf.net/sfu/sfd2d-msazure
> ___
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users

--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] bulkWrite of character sequence

2012-03-29 Thread Steven Michalske





On Mar 29, 2012, at 7:30 PM, Tormod Volden  wrote:

> On Thu, Mar 29, 2012 at 12:32 PM, Wander Lairson Costa wrote:
>> Yes, this is a known problem that was already reported before. PyUSB
>> 0.4 was very flexible in managing the buffer types, and PyUSB 1.0 is
>> not that so. I could not find yet a simple and elegant solution for
>> this problem, but try to mimic to behavior of the C version of PyUSB.
> 
> Thanks. I could not find it in the bug tracker, but I found a post
> from Sarah Messer seeing the same problem here:
> http://sourceforge.net/mailarchive/message.php?msg_id=27131804
> 
> Maybe we should just try return array.array('c', data) before or after
> trying array.array('u', data)?
> 
> BTW, how is the use of unicode strings meant to work? Each string
> character LSB is sent to the device?
> 
My recommendation is that UTF16 and UTF32 be an exception unless a byte order 
is specified or BOM is present.

Other option is to default to little endian, as USB is intel driven.  Then let 
it be overridden to big endian.

Steve
--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] interruptWrite gives unknown USB error

2010-06-02 Thread Steven Michalske
Hi,

2 things.

1. Read the USB TMC specification, it has a structure that must wrap the 
commands to the device.
See test measurement class on this page 

2. The Agilent USB DAQ devices I have used in the past use a cypress EZ-usb 
chip.  This means that when the device is first plugged into the computer it 
gets it's firmware boot loaded.
What this means for you is that you need to boot load the firmware 
first then you will get a USB-TMC device.

Also,  neglecting the firmware boot loading issue, have a look at this.


Steve


On Jun 2, 2010, at 8:56 AM, Ct Chev wrote:

> Hello,
>  
> I am trying to send SCPI (text) commands to an Agilent U2100A Digital IO via 
> USB.  I have used Python to send SCPI commands to other equipment 
> successfully in the past using the parallel port or over ethernet.  However 
> this is my first time working with a USB device and Python.
> I can successfully run usbenum.py and the results are shown at the bottom for 
> the device of interest.
>  
> I then add the following lines within the 'for dev in devices' loop:
>  
> if dev.idVendor == 2391:
> handle=dev.open()
> handle.setConfiguration(1)
> handle.setAltInterface(0)
> handle.interruptWrite(2, "*IDN?\n")
> handle.releaseInterface()
>  
> (*IDN? is a standard IEEE-488 command to return the instrument's 
> identification string.  I'm just using this to test the ability to send a 
> command)
>  
> and I get the following error:
> Traceback (most recent call last):
> File "usbenum.py", line 46, in 
> handle.interruptWrite(2, "*IDN?\n")
> usb.USBError: Unknown error
>  
> Do you have any suggestions for what I am doing wrong? 
> I tried using bulkWrite instead but that also gives the same error.
> Previously when sending SCPI commands over the LPT I had to add \n after each 
> command.  I also tried removing that here, but I get the same error.
>  
> I would greatly appreciate any suggestions you have.
>  
> Thank you!
> Chris
>  
> Output from usbenum.py:
>  
> Device: /dev/ugen2.3
>  Device class: 0
>  Device sub class: 0
>  Device protocol: 0
>  Max packet size: 64
>  idVendor: 2391
>  idProduct: 2328
>  Device Version: 01.00
>   Configuration: 1
>Total Length: 39
>selfPowered: 1
>remoteWakeup: 0
>maxPower: 0
>   Interface: 0
>Alternate Setting: 0
> Interface class: 254
> Interface sub class: 3
> Interface protocol: 1
> Endpoint: 0x2L
>  Type: 2
>  Max packet size: 64
>  Interval: 0
> Endpoint: 0x86L
>  Type: 2
>  Max packet size: 64
>  Interval: 0
> Endpoint: 0x81L
>  Type: 3
>  Max packet size: 2
>  Interval: 1
> 
> --
> 
> ___
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


[Pyusb-users] Interesting error with 1.0 interface and OS X.5

2009-11-08 Thread Steven Michalske
Howdy,

Under Mac OS X.5 Leopard I get the following error.  with latest SVN
pyUSB and libusb 1.0 driver.


Traceback (most recent call last):
  File "USBTMC.py", line 72, in 
tmd = usb.core.find(find_all=1, custom_match=match_usb_tmc(),
idVendor=0x0699 )
  File "usb/core.py", line 789, in find
  File "usb/core.py", line 762, in device_iter
  File "USBTMC.py", line 9, in __call__
for cfg in device:
  File "usb/core.py", line 662, in __iter__
  File "usb/core.py", line 360, in __init__
  File 
"/Users/hardkrash/Documents/projects/usbtmc/pyUSB/usb/backend/libusb10.py",
line 363, in get_configuration_descriptor
config, byref(cfg)))
  File 
"/Users/hardkrash/Documents/projects/usbtmc/pyUSB/usb/backend/libusb10.py",
line 300, in _check
raise USBError(_str_error[retval.value])
usb.core.USBError: Input/output error


and this error case too

Traceback (most recent call last):
  File "USBTMC.py", line 80, in 
tmd.set_configuration()
  File "usb/core.py", line 483, in set_configuration
  File "usb/core.py", line 48, in managed_set_configuration
  File "usb/core.py", line 666, in __getitem__
  File "usb/core.py", line 360, in __init__
  File 
"/Users/hardkrash/Documents/projects/usbtmc/pyUSB/usb/backend/libusb10.py",
line 363, in get_configuration_descriptor
config, byref(cfg)))
  File 
"/Users/hardkrash/Documents/projects/usbtmc/pyUSB/usb/backend/libusb10.py",
line 300, in _check
raise USBError(_str_error[retval.value])
usb.core.USBError: Input/output error


when trying to use this code. ( simplified from original source. )

<< snip >
import usb

class match_usb_tmc(object):
def __call__(self, device):
#if device.is_kernel_driver_active(0):
#   return False
for cfg in device:   # fails!
print( cfg )
intf = usb.util.find_descriptor( cfg, 
bInterfaceClass=0xFE,
bInterfaceSubClass=0x03 )
if intf:
return True

if __name__ == "__main__":
from pprint import pprint
tmd = usb.core.find(find_all=1, custom_match=match_usb_tmc(),
idVendor=0x0699 ) # ( line 72 )
#tmd = usb.core.find( idVendor=0x0699 ) # comment out above to
workaround my issue, and uncomment this to find a single device.

if not tmd:
raise ValueError('Device not found')

#print tmd.is_kernel_driver_active(0)   # uncomment to fix error when
the device is found.

tmd.set_configuration()  # fails if above is commented   (line 80)

< /snip 

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Pyusb-users mailing list
Pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users