[pyusb-users] The Candidates Buglet

2016-10-13 Thread Hermann Hamann

Hi guys,

now you can relax; this is my last submission.

It contains some wishes for a next release.

 



 

The Candidates Buglet


This buglet is not a real error but an example of poor programming style,
which makes the life of the application programmer more difficult than necessary.

Python is an object oriented language and the natural data type of the library candidates is the dictionary.

Since the days of Pascal we have learned, that it is a bad idea to litter program text with literals.

So put the candidates into a dictionary and export it to the application.

We have also learned in the Kindergarten that data belong into files and not into the program.

So provide a resource file with a dictionary-friendly structure to define the candidates;

something like:

libusb1:libusb-1.0.0,Libusb 1,usb

…

During initialization you should try to read this file and load the dictionary..

With this file you can fine tune the library search to the extend that only one library is to be used.

This would make the lambda quirk superfluous.

If you start the file search at the default directory you can define a dedicated library for each device.


Apropos lambda:

did you ever think of who sits at the far end of the USB cable?

Most probably it is an electronics engineer with a programming background of copying arduino sketches to his files.

Why should this guy have to change a program only to pass a string to pyusb?

And in a lambda _expression_!

Even after some 1 lines of python I have not understood how to use it.

Do not even dream of explaining to a hardware guy what lambda is!

If you want to keep the possibility of supplying the library name you should provide an easier way.

Simply permit a string as the backend= parameter which names the library.

And it would be nice to have a utility function find_installed_library.

 

--

 

So I want to thank you all for your patience in improving my understanding of this matter.

 

Hermann

 


--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] Finally found: the installed library

2016-10-13 Thread Hermann Hamann
Hi Jeff
 


 




[pyusb-users] Finally found: the installed library

2016-10-11 Thread Hermann Hamann


Hi,

The use of the pyusb0 service is a bit troublesome, because you have to specify the desired library by hand.
I always had the dream of automatically use the installed library.

Well, here is how.

You must know the Vid and Pid of your device. With that you can look up the registry for the installed service.
If it is winusb you need not care.

If it is pyusb0 then you get the device descriptor and extract the device name.
With it you go to the driverstore and scan the filerepository directory for a directory file name  
that starts with the device name.

Then you walk under this tree until you find a dll name.

This is the installed library.

Was not so hard.

I want to thank Xiaofan for his encouraging advice to dig deeper in this registry thingens.

Now there is no more any need to pick a wrong library.

 


 




find_linstalled_library.py
Description: Binary data
--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] Windows Installation Guide -1

2016-09-24 Thread Hermann Hamann
 


 





 

I agree.

Find attached a first draft of the Installation Guide.

The urls are wrong and only placeholders.

The remarks on the future of libusb0 are not a prejudice, it is your responsibility.

This text should demonstrate the level of detail, the area covered, and the style

of the guide.

Feel free to comment on everything.

 

This document is in libreoffice format, so that everyone can add comments (in red ink)

to it.

 

Sincerely Hermann Hamann




InstallationGuide.odt
Description: application/vnd.oasis.opendocument.text
--
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] Windows Installation Guide -1

2016-09-23 Thread Hermann Hamann
Hi,

To install or to not install, that is the question.


I was recently bitten by some lethal errors using pyusb. These were not in the pyusb code but came from lower layers as a consequence of misusing them.
The following correspondence with the maintenance crew was unsuccessful because the service aspect was not realized.
It turned out that the errors were a consequence of different installation requirements of the  different services.

I confess guilty of having too long ignored the features of the winusb service.

I have learned that DLLs need not be installed with winusb.

I have learned too that DLLs must be installed with the libusb0 service and the installed library must be used.
And it was the hard way to learn (using an apparently widely unknown technique called testing).

And that installation requirement is what you still have to learn!

I have enough logfiles to prove that.

This has consequences for the structure of pyusb, the features that can safely be provided, and the necessary restrictions that must be documented.

The good news is that for winusb served devices no changes are required.

Well, to proceed with my work on the installation guide, I need a formal agreement of the service thesis because that will dominate the bugfix procedure.

Who ever objects to this thesis should talk now or be silent for ever.

I agree [ ] I disagree [ ]

 


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


Re: [pyusb-users] Windows Installation Guide

2016-09-20 Thread Hermann Hamann
 Hi,



>> * Are there plans for a new version of pyusb1 in the near future?

> Maybe a minor bug fix version, but not big changes.

 

I am happy to learn about bug fixes. If you run short of bugs I will be ready to send you some.

>> * Are there plans for a Windows Installation Guide?
 

> a pull request is very welcome :)

 

Sorry, I have no internet and cannot use github (:

This mail account is my only contact to the web wide world.

But I will volunteer to provide a Windows Installation chapter for the tutorial.

This will however depend on the way the installation related bugs will be handeled.

So the first thing to do is to make a plan for the removal of the bugs.

 

I will make some suggestions later.



 Sincerely Hermann
 




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


Re: [pyusb-users] pyusb1 picks wrong driver on Windows

2016-08-31 Thread Hermann Hamann





< I have edited libusb wiki to warn against using libusb0.sys
< with libusb Windows.
Thank you.

One likeand one follower!


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


Re: [pyusb-users] pyusb1 picks wrong driver on Windows

2016-08-27 Thread Hermann Hamann
 
 


Hi Xiaofan Chen



 

I will try that.

H.H.




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


[pyusb-users] find_library considered harmful

2016-08-24 Thread Hermann Hamann

Hi dear maintainers.

 

I have compiled the results of the pick wrong library issue and some investigations in an issue on github.

However I could not attach the PDF file and therefore provide it here.

 

Please study it carefully.

 

I will not be here until september, so you have enough time to think and try to verify or falsify my thesis

before you respond.

 

The game is not over.

I will be back!

I will find these f.. installed libraries!

 

Hermann



 




WrongLibrary.pdf
Description: Adobe PDF document
--
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] pyusb1 picks wrong driver on Windows. Asking for help

2016-08-24 Thread Hermann Hamann
 

Hi Jeff,

I have opened an issue on this topic. Please read it and try to falsify or verfy my thesis.

I will not be back to my mailbox before september, so you have ample time.


So long

Hermann

 




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


Re: [pyusb-users] pyusb1 picks wrong driver on Windows. Asking for help

2016-08-23 Thread Hermann Hamann

 

Hi, thank you



 







Well, why then the library search? It is completely superfluous if I fix anything at installation.
 Sincerely

Hermann





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


Re: [pyusb-users] pyusb1 picks wrong driver on Windows. Asking for help

2016-08-20 Thread Hermann Hamann



Hi

>  ..and debug the real problem
What is my real problem?

H.H.




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


Re: [pyusb-users] pyusb1 picks wrong driver on Windows

2016-08-19 Thread Hermann Hamann



Hi Tormod,

thank you for your expertise; now I see clearer.


> < Why it crashed?
> I don't know.

 

I will send you a crash dump later.


> 
> 
>
> I want the backend that is in the registry.

>pyusb by default looks for libusb1 first

 

<  you must select backend explicitly.

 

Well how can I? I do not know which backend is available on my clients' machines.

I can only rely on the driver that was installed for my device and which is displayed 

in the control panel. I suppose the control panel gets it through the registry.


<< Flexibility comes at a cost.

And what is the cost of reliability?





Re: [pyusb-users] pyusb1 picks wrong driver on Windows. Asking for help

2016-08-18 Thread Hermann Hamann







Hi Chris,



Yes.

 



Re: [pyusb-users] pyusb1 picks wrong driver on Windows

2016-08-18 Thread Hermann Hamann
 
Hi



I have read so in the internet. I will post reference later.




If it helps you:


C:\Program Files\RTLSDR Scanner>dir lib*.*
Volume in Laufwerk C: hat keine Bezeichnung.
Volumeseriennummer: ECEC-C891

Verzeichnis von C:\Program Files\RTLSDR Scanner

12.04.2013 20:04 68.608 libusb-1.0.dll
1 Datei(en), 68.608 Bytes
0 Verzeichnis(se), 70.811.631.616 Bytes frei

C:\Program Files\RTLSDR Scanner>

< Why it crashed?

I don't know.





I want the backend that is in the registry.

Sincerely H. H.




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


Re: [pyusb-users] pyusb1 picks wrong driver on Windows. Asking for help

2016-08-17 Thread Hermann Hamann



Hi

< would you mind opening a issue?

I will do so, but it may take some time.

I have absolutely no background in Windows and there will be a lot of googling before

I can present hard facts.

 

Therefore I ask the Window gurus among the users to answer me some questions:

1. What is the registry for?

2. Is it valid programming style to disregard registry entries?

3. Has anyone succesfully used a non registered driver?

 

Thank you in advance

Hermann Hamann

 




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


[pyusb-users] pyusb1 picks wrong driver on Windows

2016-08-13 Thread Hermann Hamann


Dear maintainers,

my client and I have the same USB-Device. I have written a program for it.
It runs fine on both Linux systems. It runs fine on my Windows but crashes on my client's.

Both have installed the driver with inf-wizard and the system control shows libusb0.dll on
both machines.

 

However, pyusb1 does not care about it; there is no single line related to the registry in the code.

Instead pyusb started searching with pyusb1 backend and finds some libusb1 in some private direcory
of some other device. And crashed.

 

This is not acceptable.

I have written a demo to fetch the correct service from the registry, it follows here:

-

from __future__ import print_function

# call this only on Windows

try:
    from _winreg import *
except:
    from winreg import *

def getService(vid,pid):
    vidpid = r"\VID_%04x_%04x" % (vid,pid)
    path = r"SYSTEM\ControlSet002\ENUM\USB" + vidpid
    key = OpenKey(HKEY_LOCAL_MACHINE,path,0,KEY_READ)

    try:
    i = 0
    enumkey = EnumKey(key,i)
    i = i + 1
    except Exception as message:
    pass # print("enumkey",message)
    
    newkey = OpenKeyEx(key,enumkey,0,KEY_READ)
    service,Size = QueryValueEx(newkey,"Service")
    return service

if __name__ == "__main__":
    print ("service for 0x5656 0x0834 is",getService(0x5656,0x0834))

-

The output is
"service for 0x5656 0x0834 is libusb0"

 

I am aware of the backend=xxx switches and the findlibrary hooks.

They are useful to override defaults in special cases.

 

However this does not answer the question which defaults are appropiate in the normal case.

On Windows the registry entry is the most appropriate default.

 

I hope this can help you to amend pyusb1 (which is a great tool anyway).

 

Sincerely Hermann Hamann

 


 




--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. http://sdm.link/zohodev2dev___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


[pyusb-users] no end to no backend?

2016-08-02 Thread Hermann Hamann
Hello dear maintainers,

Google finds now about 5 hits on "no backend". So it is time to make an end to this problem.

 

The Problem is two missing lines in the (excellent!) tutorial:

 

---

If you encounter "no backend found" messages on Windows (re-)install a driver for your device

using infwizard from Sourceforge. Otherwise you will fail.

---

 

This info would have saved me a month of fruitless poking around.

 

Sincerely H. Hamann

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


Re: [pyusb-users] Change suggestion

2015-07-01 Thread Hermann Hamann




Hi,
sorry for my late answer.

Well, everyone has to carry his burden, not only maintainers (as opposed to
Galather 6.2).

My burden is my 99 years old mum, who suffers from dementia and other pains of
old age and needs attention around the clock.

This leaves me 1 or 2 hours a week for concentrated programming work.
Furthermore, I have no internet at home and have to ride to the public library
for net access. I have to ask my neighbor to keep an eye on my mum while I am
absent.

So I am not keen on spending my sparse time acquiring skills which I do not
need. I am currently stuck with opening a window on a remote cpu using Tkinter.

This results in very low productivity and sluggish response.

This is not facebook and so I will close this social thread.



Well, identifying the version of a source file would be very easy if you put a
comment at the beginning containing the modification date. Back in the 70s we
were able to fully automate this using available tools (this was not on Unix).

I feel, sed (available since the 70s) could do this for you.



I finally succeeded in getting a basic understanding of diff, but could not
find out if patch needs a diff original modified or a diff modified
original to work properly.

The original is from walac-pyusb-39816be.
I was astonished to learn, that the sourceforge files are from 2014.

I hope you can proceed with the modifications. There are 4 lines to change and
20 lines to insert. Back in the 70s we could do this within 15 minutes.

Do not hesitate to contact me if there are any questions left.

Sincerely yours HH







core.diff
Description: Binary data


libusb1.diff
Description: Binary data
--
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


Re: [pyusb-users] Change suggestion

2015-06-19 Thread Hermann Hamann

Hi,

Could you please open a Pull Request or, if you are not willing to
supply a patch, an issue detailing your proposal?



--
Best Regards,
Wander Lairson Costa

--
Hi,

thank you for your reply.



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.



Sincerely

Hermann Hamann

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

core.py
Description: Binary data


libusb1.py
Description: Binary data
--
___
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users


[pyusb-users] Change suggestion

2015-06-17 Thread Hermann Hamann



I want to suggest a small change to pyusb to improve speed.

Currently you can only provide an array.array buffer to put the USB data into.
I use the multiprocessing feature and the final destination of the USB data is a mmap.mmap
Object. I would like to specify this as a receive buffer to save a pickle and
unpickle operation.

It is not so difficult to use the pyapi.PyObject_GetBuffer function to retrieve address and length
of any buffer protocol compliant object.

So this array restriction should be lifted, I assume there are more users who would
appreciate this change. I would not like to distribute my software with a modified pyusb.

Sincerely
Hermann Hamann


Here follows the modifications I made:

-

# in backend1.py, similar for other backends

from ctypes import *
from struct import unpack

getBuffer = pythonapi.PyObject_GetBuffer

getBuffer.argtypes = [py_object, c_void_p, c_int]

view = create_string_buffer(11*sizeof(int))

def getBufferInfo(someObject):

 pointer_to_sO = py_object(someObject)

 result = getBuffer(pointer_to_sO,view,1) # flag writeable

 ### this call can raise an Exception. However this would be a consequence
 ### of an invalid caller, so no recovery is possible and simply let it
 ### crash, the message is helpful.

 if result != 0 : return None,None

 bufadr,objadr,buflen,itemsize,readonly,ndim,bformat,shape,strides,
 suboffsets,internal = unpack(11I,view)

 result = pythonapi.PyBuffer_Release(string_buffer)

 return (bufadr,buflen)

# and some lines later

 def __read(self, fn, dev_handle, ep, intf, buff, timeout):
 ###  changed address, length = buff.buffer_info()
 address,length = getBufferInfo(buff)
 ##length *= buff.itemsize changed

--
# in core.py

 if isinstance(size_or_buffer,int):



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