From: Saeed M. <s.m...@gm...> - 2021-01-18 07:49:32
|
Hi Xiaofan, Thanks for your response and for sending me all the resources. I have actually put my hand on every piece of information that I could get from your github page and also other websites. libusb and pyusb have been installed in the virtual environment but I can not import it. As I mentioned before, I can import pyusb in the general directory, just not in my virtual environment. Can you think of anything else? Another thing is in regards to the write() method. When I try to send a number, I have to put it in a list and the largest number I can send is 255 (1 byte). If I go beyond 255, I get this error: *OverflowError: unsigned byte integer is greater than maximum* But when I send the numbers as a string, for example '12345689', I can go as big as I want without any errors as long as on the receiver side I have set the number of bytes correctly in the read() method. Now, in my application, I have to send a list of numbers via the USB port. A list that contains between 9 to 35 numbers and each number is not going to take up more than 2 bytes. I know that I can put the numbers in a loop, but is there a way to send them all at once in number format, not string? Speed is a critical element in my application and I have to avoid loops and conversions at all costs. Thanks, Saeed On Thu, Jan 14, 2021 at 4:54 PM Xiaofan Chen <xia...@gm...> wrote: > On Thu, Jan 14, 2021 at 1:52 PM Xiaofan Chen <xia...@gm...> wrote: > > > > On Thu, Jan 14, 2021 at 1:44 PM Saeed Mirghasemi <s.m...@gm...> > wrote: > > > I have already done that and it does not work. Does anything else come > to your mind? > > > > > > Also, where do I get a list of commands and their arguments in pysub? > I am trying to > > > set the baud rate and I do not know where to start. > > > > > > > Obviously you need to install libusb as well. Please read the FAQ here. > > https://github.com/pyusb/pyusb/blob/master/docs/faq.rst > > > > As for baud rate or things like that, that is not part of pyusb. You > have to > > understand the communication protocol of your USB device in order to > > use libusb/pyusb. > > > > I suggest you read some basics of USB first. > > http://www.usbmadesimple.co.uk/ > > > > Then if you do not know the communication protocol, you have to reverse > > engineering. > > http://www.usbmadesimple.co.uk/ > > Sorry the link is not correct. > > https://slomkowski.eu/tutorials/eavesdropping-usb-and-writing-driver-in-python/ > > > And if your device is a standard USB class device like USB to Serial > port, > > then it is better not to use pyusb but rather pyserial. > > > > -- > > Xiaofan > > > _______________________________________________ > pyusb-users mailing list > pyu...@li... > https://lists.sourceforge.net/lists/listinfo/pyusb-users > |